Interface ElementPosition
- All Known Subinterfaces:
PositionInList,UnassignedElement
PositionInList and UnassignedElement.
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 UnassignedElement to represent this null value,
and user code must explicitly decide how to handle this case.
This prevents accidental use of UnassignedElement in places where PositionInList 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 PositionInListReturnsPositionInListif this position is assigned, otherwise throws an exception.ensureAssigned(Supplier<String> messageSupplier) ReturnsPositionInListif this position is assigned, otherwise throws an exception.static PositionInListCreate a new instance ofPositionInList.static UnassignedElementReturns a singleton instance ofUnassignedElement.
-
Method Details
-
of
Create a new instance ofPositionInList. 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 ofUnassignedElement. User code should never need to call this method.- Returns:
- never null
-
ensureAssigned
ReturnsPositionInListif this position is assigned, otherwise throws an exception.- Returns:
- Position of the value in an entity's
PlanningListVariable. - Throws:
IllegalStateException- If this position is unassigned.
-
ensureAssigned
ReturnsPositionInListif this position is assigned, otherwise throws an exception.- Parameters:
messageSupplier- The message to give the exception.- Returns:
- Position of the value in an entity's
PlanningListVariable. - Throws:
IllegalStateException- If this position is unassigned.
-