@@ -20,10 +20,9 @@ final class ListVariableState<Solution_> {
2020
2121 private ExternalizedIndexVariableProcessor <Solution_ > externalizedIndexProcessor = null ;
2222 private ExternalizedListInverseVariableProcessor <Solution_ > externalizedInverseProcessor = null ;
23- private AbstractExternalizedNextPrevElementVariableProcessor <Solution_ > externalizedPreviousElementProcessor = null ;
24- private AbstractExternalizedNextPrevElementVariableProcessor <Solution_ > externalizedNextElementProcessor = null ;
23+ private ExternalizedNextPrevElementVariableProcessor <Solution_ > externalizedPreviousElementProcessor = null ;
24+ private ExternalizedNextPrevElementVariableProcessor <Solution_ > externalizedNextElementProcessor = null ;
2525
26- private boolean canUseExternalizedLocation = false ;
2726 private boolean requiresLocationMap = true ;
2827 private InnerScoreDirector <Solution_ , ?> scoreDirector ;
2928 private int unassignedCount = 0 ;
@@ -33,30 +32,29 @@ public ListVariableState(ListVariableDescriptor<Solution_> sourceVariableDescrip
3332 this .sourceVariableDescriptor = sourceVariableDescriptor ;
3433 }
3534
36- public void linkDescriptor (IndexShadowVariableDescriptor <Solution_ > shadowVariableDescriptor ) {
35+ public void linkShadowVariable (IndexShadowVariableDescriptor <Solution_ > shadowVariableDescriptor ) {
3736 this .externalizedIndexProcessor = new ExternalizedIndexVariableProcessor <>(shadowVariableDescriptor );
3837 }
3938
40- public void linkDescriptor (InverseRelationShadowVariableDescriptor <Solution_ > shadowVariableDescriptor ) {
39+ public void linkShadowVariable (InverseRelationShadowVariableDescriptor <Solution_ > shadowVariableDescriptor ) {
4140 this .externalizedInverseProcessor =
4241 new ExternalizedListInverseVariableProcessor <>(shadowVariableDescriptor , sourceVariableDescriptor );
4342 }
4443
45- public void linkDescriptor (PreviousElementShadowVariableDescriptor <Solution_ > shadowVariableDescriptor ) {
44+ public void linkShadowVariable (PreviousElementShadowVariableDescriptor <Solution_ > shadowVariableDescriptor ) {
4645 this .externalizedPreviousElementProcessor =
47- new ExternalizedPreviousElementVariableProcessor <> (shadowVariableDescriptor );
46+ ExternalizedNextPrevElementVariableProcessor . ofPrevious (shadowVariableDescriptor );
4847 }
4948
50- public void linkDescriptor (NextElementShadowVariableDescriptor <Solution_ > shadowVariableDescriptor ) {
51- this .externalizedNextElementProcessor = new ExternalizedNextElementVariableProcessor <> (shadowVariableDescriptor );
49+ public void linkShadowVariable (NextElementShadowVariableDescriptor <Solution_ > shadowVariableDescriptor ) {
50+ this .externalizedNextElementProcessor = ExternalizedNextPrevElementVariableProcessor . ofNext (shadowVariableDescriptor );
5251 }
5352
5453 public void initialize (InnerScoreDirector <Solution_ , ?> scoreDirector , int initialUnassignedCount ) {
5554 this .scoreDirector = scoreDirector ;
5655 this .unassignedCount = initialUnassignedCount ;
5756
58- this .canUseExternalizedLocation = externalizedIndexProcessor != null && externalizedInverseProcessor != null ;
59- this .requiresLocationMap = !canUseExternalizedLocation
57+ this .requiresLocationMap = externalizedIndexProcessor == null || externalizedInverseProcessor == null
6058 || externalizedPreviousElementProcessor == null || externalizedNextElementProcessor == null ;
6159 if (requiresLocationMap ) {
6260 if (elementLocationMap == null ) {
@@ -220,14 +218,14 @@ private enum ChangeType {
220218 }
221219
222220 public ElementLocation getLocationInList (Object planningValue ) {
223- if (! canUseExternalizedLocation ) {
221+ if (requiresLocationMap ) {
224222 return Objects .requireNonNullElse (elementLocationMap .get (planningValue ), ElementLocation .unassigned ());
225- } else {
226- var inverse = getInverseSingleton (planningValue );
223+ } else { // At this point, both inverse and index are externalized.
224+ var inverse = externalizedInverseProcessor . getInverseSingleton (planningValue );
227225 if (inverse == null ) {
228226 return ElementLocation .unassigned ();
229227 }
230- return ElementLocation .of (inverse , getIndex (planningValue ));
228+ return ElementLocation .of (inverse , externalizedIndexProcessor . getIndex (planningValue ));
231229 }
232230 }
233231
0 commit comments