11package ai .timefold .solver .core .api .solver .change ;
22
3- import java .util .Optional ;
43import java .util .function .Consumer ;
54
6- import ai .timefold .solver .core .api .domain .common .PlanningId ;
5+ import ai .timefold .solver .core .api .domain .common .Lookup ;
76import ai .timefold .solver .core .api .domain .entity .PlanningEntity ;
87import ai .timefold .solver .core .api .domain .solution .PlanningSolution ;
98import ai .timefold .solver .core .api .domain .variable .PlanningVariable ;
109import ai .timefold .solver .core .api .domain .variable .ShadowVariable ;
1110
1211import org .jspecify .annotations .NullMarked ;
13- import org .jspecify .annotations .Nullable ;
1412
1513/**
1614 * Allows external changes to the {@link PlanningSolution working solution}. If the changes are not applied through
1917 * never notified about them, resulting to inconsistencies in the {@link PlanningSolution working solution}.
2018 * Should be used only from a {@link ProblemChange} implementation.
2119 * To see an example implementation, please refer to the {@link ProblemChange} Javadoc.
20+ *
21+ * @see Lookup You may need to perform lookups of working objects from external objects.
2222 */
2323@ NullMarked
24- public interface ProblemChangeDirector {
24+ public interface ProblemChangeDirector
25+ extends Lookup {
2526
2627 /**
2728 * Add a new {@link PlanningEntity} instance into the {@link PlanningSolution working solution}.
@@ -35,7 +36,7 @@ public interface ProblemChangeDirector {
3536 /**
3637 * Remove an existing {@link PlanningEntity} instance from the {@link PlanningSolution working solution}.
3738 * Translates the entity to a working planning entity by performing a lookup as defined by
38- * {@link #lookUpWorkingObjectOrFail (Object)}.
39+ * {@link #lookUpWorkingObject (Object)}.
3940 *
4041 * @param entity the {@link PlanningEntity} instance
4142 * @param entityConsumer removes the working entity from the {@link PlanningSolution working solution}
@@ -45,7 +46,7 @@ public interface ProblemChangeDirector {
4546
4647 /**
4748 * Change a {@link PlanningVariable} value of a {@link PlanningEntity}. Translates the entity to a working
48- * planning entity by performing a lookup as defined by {@link #lookUpWorkingObjectOrFail (Object)}.
49+ * planning entity by performing a lookup as defined by {@link #lookUpWorkingObject (Object)}.
4950 *
5051 * @param entity the {@link PlanningEntity} instance
5152 * @param variableName name of the {@link PlanningVariable}
@@ -66,7 +67,7 @@ public interface ProblemChangeDirector {
6667
6768 /**
6869 * Remove an existing problem fact from the {@link PlanningSolution working solution}. Translates the problem fact
69- * to a working problem fact by performing a lookup as defined by {@link #lookUpWorkingObjectOrFail (Object)}.
70+ * to a working problem fact by performing a lookup as defined by {@link #lookUpWorkingObject (Object)}.
7071 *
7172 * @param problemFact the problem fact instance
7273 * @param problemFactConsumer removes the working problem fact from the
@@ -78,7 +79,7 @@ public interface ProblemChangeDirector {
7879 /**
7980 * Change a property of either a {@link PlanningEntity} or a problem fact. Translates the entity or the problem fact
8081 * to its {@link PlanningSolution working solution} counterpart by performing a lookup as defined by
81- * {@link #lookUpWorkingObjectOrFail (Object)}.
82+ * {@link #lookUpWorkingObject (Object)}.
8283 *
8384 * @param problemFactOrEntity the {@link PlanningEntity} or the problem fact instance
8485 * @param problemFactOrEntityConsumer updates the property of the {@link PlanningEntity}
@@ -88,32 +89,6 @@ public interface ProblemChangeDirector {
8889 <EntityOrProblemFact > void changeProblemProperty (EntityOrProblemFact problemFactOrEntity ,
8990 Consumer <EntityOrProblemFact > problemFactOrEntityConsumer );
9091
91- /**
92- * Translate an entity or fact instance (often from another {@link Thread} or JVM)
93- * to this {@link ProblemChangeDirector}'s internal working instance.
94- * <p>
95- * Matching uses {@link PlanningId}.
96- *
97- * @return null if externalObject is null
98- * @throws IllegalArgumentException if there is no workingObject for externalObject, if it cannot be looked up
99- * or if the externalObject's class is not supported
100- * @throws IllegalStateException if it cannot be looked up
101- * @param <EntityOrProblemFact> the object type
102- */
103- <EntityOrProblemFact > @ Nullable EntityOrProblemFact lookUpWorkingObjectOrFail (@ Nullable EntityOrProblemFact externalObject );
104-
105- /**
106- * As defined by {@link #lookUpWorkingObjectOrFail(Object)},
107- * but doesn't fail fast if no workingObject was ever added for the externalObject.
108- * It's recommended to use {@link #lookUpWorkingObjectOrFail(Object)} instead.
109- *
110- * @return {@link Optional#empty()} if there is no workingObject for externalObject, or if externalObject is null
111- * @throws IllegalArgumentException if it cannot be looked up or if the externalObject's class is not supported
112- * @throws IllegalStateException if it cannot be looked up
113- * @param <EntityOrProblemFact> the object type
114- */
115- <EntityOrProblemFact > Optional <EntityOrProblemFact > lookUpWorkingObject (@ Nullable EntityOrProblemFact externalObject );
116-
11792 /**
11893 * Calls variable listeners on the external changes submitted so far.
11994 *
0 commit comments