Interface Notification<Solution_,T extends AbstractVariableListener<Solution_,Object>>
-
- Type Parameters:
Solution_
- the solution type, the class with thePlanningSolution
annotationT
- the variable listener type
- All Known Subinterfaces:
BasicVariableNotification<Solution_>
,EntityNotification<Solution_>
,ListVariableNotification<Solution_>
public interface Notification<Solution_,T extends AbstractVariableListener<Solution_,Object>>
A notification represents some kind of change of a planning variable. When a score director is notified about a change, one notification is created for eachNotifiable
registered for the subject of the change. Each implementation is tailored to a specificAbstractVariableListener
and triggers on the listener the pair of "before/after" methods corresponding to the type of change it represents. For example, if there is a shadow variable sourced on theProcess.computer
genuine planning variable, then there is a notifiableF
registered for theProcess.computer
planning variable, and it holds a basic variable listenerL
. WhenProcess X
is moved fromComputer A
toComputer B
, a notificationN
is created and added to notifiableF
's queue. The notificationN
triggersL.beforeVariableChanged(scoreDirector, Process X)
immediately. Later, whenF.triggerAllNotifications()
is called,N
is taken from the queue and triggersVariableListener.afterVariableChanged(org.optaplanner.core.api.score.director.ScoreDirector<Solution_>, Entity_)
.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static <Solution_>
ListVariableNotification<Solution_>elementAdded(Object entity, int index)
An element was added toentity
's list variable atindex
.static <Solution_>
ListVariableNotification<Solution_>elementMoved(Object sourceEntity, int sourceIndex, Object destinationEntity, int destinationIndex)
An element was moved fromsourceEntity[sourceIndex]
todestinationEntity[destinationIndex]
.static <Solution_>
ListVariableNotification<Solution_>elementRemoved(Object entity, int index)
An element was removed fromentity
's list variable atindex
.static <Solution_>
EntityNotification<Solution_>entityAdded(Object entity)
Theentity
was added.static <Solution_>
EntityNotification<Solution_>entityRemoved(Object entity)
Theentity
was removed.void
triggerAfter(T variableListener, ScoreDirector<Solution_> scoreDirector)
TriggervariableListener
's after method corresponding to this notification.void
triggerBefore(T variableListener, ScoreDirector<Solution_> scoreDirector)
TriggervariableListener
's before method corresponding to this notification.static <Solution_>
BasicVariableNotification<Solution_>variableChanged(Object entity)
Basic genuine or shadow planning variable changed onentity
.
-
-
-
Method Detail
-
entityAdded
static <Solution_> EntityNotification<Solution_> entityAdded(Object entity)
Theentity
was added.
-
entityRemoved
static <Solution_> EntityNotification<Solution_> entityRemoved(Object entity)
Theentity
was removed.
-
variableChanged
static <Solution_> BasicVariableNotification<Solution_> variableChanged(Object entity)
Basic genuine or shadow planning variable changed onentity
.
-
elementAdded
static <Solution_> ListVariableNotification<Solution_> elementAdded(Object entity, int index)
An element was added toentity
's list variable atindex
.
-
elementRemoved
static <Solution_> ListVariableNotification<Solution_> elementRemoved(Object entity, int index)
An element was removed fromentity
's list variable atindex
.
-
elementMoved
static <Solution_> ListVariableNotification<Solution_> elementMoved(Object sourceEntity, int sourceIndex, Object destinationEntity, int destinationIndex)
An element was moved fromsourceEntity[sourceIndex]
todestinationEntity[destinationIndex]
.
-
triggerBefore
void triggerBefore(T variableListener, ScoreDirector<Solution_> scoreDirector)
TriggervariableListener
's before method corresponding to this notification.
-
triggerAfter
void triggerAfter(T variableListener, ScoreDirector<Solution_> scoreDirector)
TriggervariableListener
's after method corresponding to this notification.
-
-