Class ExternalizedIndexVariableSupply<Solution_>
- java.lang.Object
-
- org.optaplanner.core.impl.domain.variable.index.ExternalizedIndexVariableSupply<Solution_>
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,VariableListener<Solution_,Object>
,IndexVariableSupply
,SourcedVariableListener<Solution_,Object>
,Supply
public class ExternalizedIndexVariableSupply<Solution_> extends Object implements SourcedVariableListener<Solution_,Object>, IndexVariableSupply
Alternative toIndexVariableListener
.
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<Object,Integer>
indexMap
protected ListVariableDescriptor<Solution_>
sourceVariableDescriptor
-
Constructor Summary
Constructors Constructor Description ExternalizedIndexVariableSupply(ListVariableDescriptor<Solution_> sourceVariableDescriptor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterEntityAdded(ScoreDirector<Solution_> scoreDirector, Object entity)
void
afterEntityRemoved(ScoreDirector<Solution_> scoreDirector, Object entity)
void
afterVariableChanged(ScoreDirector<Solution_> scoreDirector, Object entity)
void
beforeEntityAdded(ScoreDirector<Solution_> scoreDirector, Object entity)
void
beforeEntityRemoved(ScoreDirector<Solution_> scoreDirector, Object entity)
void
beforeVariableChanged(ScoreDirector<Solution_> scoreDirector, Object entity)
void
close()
Called before thisVariableListener
is thrown away and not used anymore.Integer
getIndex(Object planningValue)
GetplanningValue
's index in thelist variable
it is an element of.VariableDescriptor<Solution_>
getSourceVariableDescriptor()
boolean
requiresUniqueEntityEvents()
When set totrue
, this has a slight performance loss in Planner.void
resetWorkingSolution(ScoreDirector<Solution_> scoreDirector)
Called when the entire working solution changes.String
toString()
-
-
-
Field Detail
-
sourceVariableDescriptor
protected final ListVariableDescriptor<Solution_> sourceVariableDescriptor
-
-
Constructor Detail
-
ExternalizedIndexVariableSupply
public ExternalizedIndexVariableSupply(ListVariableDescriptor<Solution_> sourceVariableDescriptor)
-
-
Method Detail
-
getSourceVariableDescriptor
public VariableDescriptor<Solution_> getSourceVariableDescriptor()
- Specified by:
getSourceVariableDescriptor
in interfaceSourcedVariableListener<Solution_,Object>
-
resetWorkingSolution
public void resetWorkingSolution(ScoreDirector<Solution_> scoreDirector)
Description copied from interface:VariableListener
Called when the entire working solution changes. In this event, the other before..()/after...() methods will not be called. At this point, implementations should clear state, if any.- Specified by:
resetWorkingSolution
in interfaceVariableListener<Solution_,Object>
- Parameters:
scoreDirector
- never null
-
close
public void close()
Description copied from interface:VariableListener
Called before thisVariableListener
is thrown away and not used anymore.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceVariableListener<Solution_,Object>
-
requiresUniqueEntityEvents
public boolean requiresUniqueEntityEvents()
Description copied from interface:VariableListener
When set totrue
, this has a slight performance loss in Planner. When set tofalse
, it's often easier to make the listener implementation correct and fast.- Specified by:
requiresUniqueEntityEvents
in interfaceVariableListener<Solution_,Object>
- Returns:
- true to guarantee that each of the before/after methods will only be called once per entity instance per operation type (add, change or remove).
-
beforeEntityAdded
public void beforeEntityAdded(ScoreDirector<Solution_> scoreDirector, Object entity)
- Specified by:
beforeEntityAdded
in interfaceVariableListener<Solution_,Object>
- Parameters:
scoreDirector
- never nullentity
- never null
-
afterEntityAdded
public void afterEntityAdded(ScoreDirector<Solution_> scoreDirector, Object entity)
- Specified by:
afterEntityAdded
in interfaceVariableListener<Solution_,Object>
- Parameters:
scoreDirector
- never nullentity
- never null
-
beforeVariableChanged
public void beforeVariableChanged(ScoreDirector<Solution_> scoreDirector, Object entity)
- Specified by:
beforeVariableChanged
in interfaceVariableListener<Solution_,Object>
- Parameters:
scoreDirector
- never nullentity
- never null
-
afterVariableChanged
public void afterVariableChanged(ScoreDirector<Solution_> scoreDirector, Object entity)
- Specified by:
afterVariableChanged
in interfaceVariableListener<Solution_,Object>
- Parameters:
scoreDirector
- never nullentity
- never null
-
beforeEntityRemoved
public void beforeEntityRemoved(ScoreDirector<Solution_> scoreDirector, Object entity)
- Specified by:
beforeEntityRemoved
in interfaceVariableListener<Solution_,Object>
- Parameters:
scoreDirector
- never nullentity
- never null
-
afterEntityRemoved
public void afterEntityRemoved(ScoreDirector<Solution_> scoreDirector, Object entity)
- Specified by:
afterEntityRemoved
in interfaceVariableListener<Solution_,Object>
- Parameters:
scoreDirector
- never nullentity
- never null
-
getIndex
public Integer getIndex(Object planningValue)
Description copied from interface:IndexVariableSupply
GetplanningValue
's index in thelist variable
it is an element of.- Specified by:
getIndex
in interfaceIndexVariableSupply
- Parameters:
planningValue
- never null- Returns:
planningValue
's index in the list variable it is an element of ornull
if the value is unassigned
-
-