Interface ProblemChangeDirector
-
- All Known Implementing Classes:
DefaultProblemChangeDirector,MockProblemChangeDirector
public interface ProblemChangeDirectorAllows external changes to theworking solution. Should be used only from aProblemChangeimplementation.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <Entity> voidaddEntity(Entity entity, Consumer<Entity> entityConsumer)Add a newPlanningEntityinstance into theworking solution.<ProblemFact>
voidaddProblemFact(ProblemFact problemFact, Consumer<ProblemFact> problemFactConsumer)Add a new problem fact into theworking solution.<EntityOrProblemFact>
voidchangeProblemProperty(EntityOrProblemFact problemFactOrEntity, Consumer<EntityOrProblemFact> problemFactOrEntityConsumer)Change a property of either aPlanningEntityor a problem fact.<Entity> voidchangeVariable(Entity entity, String variableName, Consumer<Entity> entityConsumer)Change aPlanningVariablevalue of aPlanningEntity.<EntityOrProblemFact>
Optional<EntityOrProblemFact>lookUpWorkingObject(EntityOrProblemFact externalObject)As defined bylookUpWorkingObjectOrFail(Object), but doesn't fail fast if no workingObject was ever added for the externalObject.<EntityOrProblemFact>
EntityOrProblemFactlookUpWorkingObjectOrFail(EntityOrProblemFact externalObject)Translate an entity or fact instance (often from anotherThreador JVM) to thisProblemChangeDirector's internal working instance.<Entity> voidremoveEntity(Entity entity, Consumer<Entity> entityConsumer)Remove an existingPlanningEntityinstance from theworking solution.<ProblemFact>
voidremoveProblemFact(ProblemFact problemFact, Consumer<ProblemFact> problemFactConsumer)Remove an existing problem fact from theworking solution.
-
-
-
Method Detail
-
addEntity
<Entity> void addEntity(Entity entity, Consumer<Entity> entityConsumer)Add a newPlanningEntityinstance into theworking solution.- Type Parameters:
Entity- the planning entity object type- Parameters:
entity- never null; thePlanningEntityinstanceentityConsumer- never null; adds the entity to theworking solution
-
removeEntity
<Entity> void removeEntity(Entity entity, Consumer<Entity> entityConsumer)Remove an existingPlanningEntityinstance from theworking solution. Translates the entity to a working planning entity by performing a lookup as defined bylookUpWorkingObjectOrFail(Object).- Type Parameters:
Entity- the planning entity object type- Parameters:
entity- never null; thePlanningEntityinstanceentityConsumer- never null; removes the working entity from theworking solution
-
changeVariable
<Entity> void changeVariable(Entity entity, String variableName, Consumer<Entity> entityConsumer)Change aPlanningVariablevalue of aPlanningEntity. Translates the entity to a working planning entity by performing a lookup as defined bylookUpWorkingObjectOrFail(Object).- Type Parameters:
Entity- the planning entity object type- Parameters:
entity- never null; thePlanningEntityinstancevariableName- never null; name of thePlanningVariableentityConsumer- never null; updates the value of the thePlanningVariableinside thePlanningEntity
-
addProblemFact
<ProblemFact> void addProblemFact(ProblemFact problemFact, Consumer<ProblemFact> problemFactConsumer)Add a new problem fact into theworking solution.- Type Parameters:
ProblemFact- the problem fact object type- Parameters:
problemFact- never null; the problem fact instanceproblemFactConsumer- never null; removes the working problem fact from theworking solution
-
removeProblemFact
<ProblemFact> void removeProblemFact(ProblemFact problemFact, Consumer<ProblemFact> problemFactConsumer)Remove an existing problem fact from theworking solution. Translates the problem fact to a working problem fact by performing a lookup as defined bylookUpWorkingObjectOrFail(Object).- Type Parameters:
ProblemFact- the problem fact object type- Parameters:
problemFact- never null; the problem fact instanceproblemFactConsumer- never null; removes the working problem fact from theworking solution
-
changeProblemProperty
<EntityOrProblemFact> void changeProblemProperty(EntityOrProblemFact problemFactOrEntity, Consumer<EntityOrProblemFact> problemFactOrEntityConsumer)Change a property of either aPlanningEntityor a problem fact. Translates the entity or the problem fact to itsworking solutioncounterpart by performing a lookup as defined bylookUpWorkingObjectOrFail(Object).- Type Parameters:
EntityOrProblemFact- the planning entity or problem fact object type- Parameters:
problemFactOrEntity- never null; thePlanningEntityor the problem fact instanceproblemFactOrEntityConsumer- never null; updates the property of thePlanningEntityor the problem fact
-
lookUpWorkingObjectOrFail
<EntityOrProblemFact> EntityOrProblemFact lookUpWorkingObjectOrFail(EntityOrProblemFact externalObject)
Translate an entity or fact instance (often from anotherThreador JVM) to thisProblemChangeDirector's internal working instance.Matching is determined by the
LookUpStrategyTypeonPlanningSolution. Matching uses aPlanningIdby default.- Type Parameters:
EntityOrProblemFact- the object type- Parameters:
externalObject- sometimes null- Returns:
- null if externalObject is null
- Throws:
IllegalArgumentException- if there is no workingObject for externalObject, if it cannot be looked up or if the externalObject's class is not supportedIllegalStateException- if it cannot be looked up
-
lookUpWorkingObject
<EntityOrProblemFact> Optional<EntityOrProblemFact> lookUpWorkingObject(EntityOrProblemFact externalObject)
As defined bylookUpWorkingObjectOrFail(Object), but doesn't fail fast if no workingObject was ever added for the externalObject. It's recommended to uselookUpWorkingObjectOrFail(Object)instead.- Type Parameters:
EntityOrProblemFact- the object type- Parameters:
externalObject- sometimes null- Returns:
Optional.empty()if externalObject is null or if there is no workingObject for externalObject- Throws:
IllegalArgumentException- if it cannot be looked up or if the externalObject's class is not supportedIllegalStateException- if it cannot be looked up
-
-