Package org.opt4j.core.config
Class Task
- java.lang.Object
-
- org.opt4j.core.config.Task
-
- All Implemented Interfaces:
java.util.concurrent.Callable<java.lang.Void>
- Direct Known Subclasses:
Opt4JTask
public abstract class Task extends java.lang.Object implements java.util.concurrent.Callable<java.lang.Void>
TheTask
is an abstract class for optimization tasks.- See Also:
ExecutionEnvironment
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Task.State
TheTask.State
of a task.
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Exception
e
protected boolean
isInit
protected java.util.Set<TaskStateListener>
listeners
protected java.util.List<com.google.inject.Module>
modules
protected Task.State
state
-
Constructor Summary
Constructors Constructor Description Task()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addStateListener(TaskStateListener listener)
Adds aTaskStateListener
.java.lang.Void
call()
abstract void
execute()
Executes theTask
.java.lang.Exception
getException()
Returns theException
that was thrown during theTask
execution if an error occurred.java.util.Collection<com.google.inject.Module>
getModules()
Returns a copy of theModule
s of thisTask
.Task.State
getState()
Returns the state of theTask
.void
init(com.google.inject.Module... modules)
Initializes theTask
with modules.void
init(java.util.Collection<com.google.inject.Module> modules)
Initializes theTask
with modules.void
removeStateListener(TaskStateListener listener)
Removes aTaskStateListener
.protected void
setState(Task.State state)
Sets the state of theTask
.java.lang.String
toString()
-
-
-
Field Detail
-
state
protected Task.State state
-
e
protected java.lang.Exception e
-
modules
protected final java.util.List<com.google.inject.Module> modules
-
isInit
protected boolean isInit
-
listeners
protected final java.util.Set<TaskStateListener> listeners
-
-
Method Detail
-
init
public void init(com.google.inject.Module... modules)
Initializes theTask
with modules.- Parameters:
modules
- the modules for the task- See Also:
init(Collection)
-
init
public void init(java.util.Collection<com.google.inject.Module> modules)
Initializes theTask
with modules. Note that if a module is aPropertyModule
, a copy is made with thePropertyModule.clone()
method. If theModule
is not aPropertyModule
, the module is copied as a reference, i.e., it can be changed until theexecute()
is called.- Parameters:
modules
- the modules for the task
-
execute
public abstract void execute() throws java.lang.Exception
Executes theTask
.- Throws:
java.lang.Exception
-
call
public java.lang.Void call() throws java.lang.Exception
- Specified by:
call
in interfacejava.util.concurrent.Callable<java.lang.Void>
- Throws:
java.lang.Exception
-
getException
public java.lang.Exception getException()
Returns theException
that was thrown during theTask
execution if an error occurred.- Returns:
- the occurred exception
-
getState
public Task.State getState()
Returns the state of theTask
.- Returns:
- the state of the task
-
setState
protected void setState(Task.State state)
Sets the state of theTask
.- Parameters:
state
- the state of the task to be set
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
addStateListener
public void addStateListener(TaskStateListener listener)
Adds aTaskStateListener
.- Parameters:
listener
- the listener to be added- See Also:
removeStateListener(org.opt4j.core.config.TaskStateListener)
-
removeStateListener
public void removeStateListener(TaskStateListener listener)
Removes aTaskStateListener
.- Parameters:
listener
- the listener to be removed- See Also:
addStateListener(org.opt4j.core.config.TaskStateListener)
-
getModules
public java.util.Collection<com.google.inject.Module> getModules()
Returns a copy of theModule
s of thisTask
.- Returns:
- a set of modules
-
-