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 ;
2120 * To see an example implementation, please refer to the {@link ProblemChange} Javadoc.
2221 */
2322@ NullMarked
24- public interface ProblemChangeDirector {
23+ public interface ProblemChangeDirector
24+ extends Lookup {
2525
2626 /**
2727 * Add a new {@link PlanningEntity} instance into the {@link PlanningSolution working solution}.
@@ -35,7 +35,7 @@ public interface ProblemChangeDirector {
3535 /**
3636 * Remove an existing {@link PlanningEntity} instance from the {@link PlanningSolution working solution}.
3737 * Translates the entity to a working planning entity by performing a lookup as defined by
38- * {@link #lookUpWorkingObjectOrFail (Object)}.
38+ * {@link #lookUpWorkingObject (Object)}.
3939 *
4040 * @param entity the {@link PlanningEntity} instance
4141 * @param entityConsumer removes the working entity from the {@link PlanningSolution working solution}
@@ -45,7 +45,7 @@ public interface ProblemChangeDirector {
4545
4646 /**
4747 * 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)}.
48+ * planning entity by performing a lookup as defined by {@link #lookUpWorkingObject (Object)}.
4949 *
5050 * @param entity the {@link PlanningEntity} instance
5151 * @param variableName name of the {@link PlanningVariable}
@@ -66,7 +66,7 @@ public interface ProblemChangeDirector {
6666
6767 /**
6868 * 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)}.
69+ * to a working problem fact by performing a lookup as defined by {@link #lookUpWorkingObject (Object)}.
7070 *
7171 * @param problemFact the problem fact instance
7272 * @param problemFactConsumer removes the working problem fact from the
@@ -78,7 +78,7 @@ public interface ProblemChangeDirector {
7878 /**
7979 * Change a property of either a {@link PlanningEntity} or a problem fact. Translates the entity or the problem fact
8080 * to its {@link PlanningSolution working solution} counterpart by performing a lookup as defined by
81- * {@link #lookUpWorkingObjectOrFail (Object)}.
81+ * {@link #lookUpWorkingObject (Object)}.
8282 *
8383 * @param problemFactOrEntity the {@link PlanningEntity} or the problem fact instance
8484 * @param problemFactOrEntityConsumer updates the property of the {@link PlanningEntity}
@@ -88,31 +88,8 @@ public interface ProblemChangeDirector {
8888 <EntityOrProblemFact > void changeProblemProperty (EntityOrProblemFact problemFactOrEntity ,
8989 Consumer <EntityOrProblemFact > problemFactOrEntityConsumer );
9090
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 );
91+ @ Override
92+ <EntityOrProblemFact > @ Nullable EntityOrProblemFact lookUpWorkingObject (@ Nullable EntityOrProblemFact externalObject );
11693
11794 /**
11895 * Calls variable listeners on the external changes submitted so far.
0 commit comments