Interface ElementLocation
- All Known Subinterfaces:
LocationInList,UnassignedLocation
LocationInList and UnassignedLocation.
PlanningListVariable.allowsUnassignedValues() allows for a value to not be part of any entity's list.
This introduces null into user code, and makes it harder to reason about the code.
Therefore, we introduce UnassignedLocation to represent this null value,
and user code must explicitly decide how to handle this case.
This prevents accidental use of UnassignedLocation in places where LocationInList is expected,
catching this error as early as possible.
This package and all of its contents are part of the Move Streams API, which is under development and is only offered as a preview feature. There are no guarantees for backward compatibility; any class, method or field may change or be removed without prior notice, although we will strive to avoid this as much as possible.
We encourage you to try the API and give us feedback on your experience with it, before we finalize the API. Please direct your feedback to Timefold Solver Github.
-
Method Summary
Modifier and TypeMethodDescriptiondefault @NonNull LocationInListReturnsLocationInListif this location is assigned, otherwise throws an exception.@NonNull LocationInListensureAssigned(@NonNull Supplier<String> messageSupplier) ReturnsLocationInListif this location is assigned, otherwise throws an exception.static @NonNull LocationInListCreate a new instance ofLocationInList.static @NonNull UnassignedLocationReturns a singleton instance ofUnassignedLocation.
-
Method Details
-
of
Create a new instance ofLocationInList. User code should never need to call this method.- Parameters:
entity- Entity whosePlanningListVariablecontains the value.index- 0 or higher- Returns:
- never null
-
unassigned
Returns a singleton instance ofUnassignedLocation. User code should never need to call this method.- Returns:
- never null
-
ensureAssigned
ReturnsLocationInListif this location is assigned, otherwise throws an exception.- Returns:
- Location of the value in an entity's
PlanningListVariable. - Throws:
IllegalStateException- If this location is unassigned.
-
ensureAssigned
ReturnsLocationInListif this location is assigned, otherwise throws an exception.- Parameters:
messageSupplier- The message to give the exception.- Returns:
- Location of the value in an entity's
PlanningListVariable. - Throws:
IllegalStateException- If this location is unassigned.
-