@@ -89,8 +89,7 @@ public class EntityDescriptor<Solution_> {
8989 ShadowVariable .List .class ,
9090 PiggybackShadowVariable .class ,
9191 CustomShadowVariable .class ,
92- CascadingUpdateShadowVariable .class ,
93- CascadingUpdateShadowVariable .List .class };
92+ CascadingUpdateShadowVariable .class };
9493
9594 private static final Logger LOGGER = LoggerFactory .getLogger (EntityDescriptor .class );
9695
@@ -217,7 +216,6 @@ public void processAnnotations(DescriptorPolicy descriptorPolicy) {
217216 + ") should have at least 1 getter method or 1 field with a "
218217 + PlanningVariable .class .getSimpleName () + " annotation or a shadow variable annotation." );
219218 }
220- processPiggyBackForCascadingUpdateShadowVariables ();
221219 processVariableAnnotations (descriptorPolicy );
222220 }
223221
@@ -292,8 +290,7 @@ private void processPlanningVariableAnnotation(MutableInt variableDescriptorCoun
292290 || variableAnnotationClass .equals (ShadowVariable .class )
293291 || variableAnnotationClass .equals (ShadowVariable .List .class )
294292 || variableAnnotationClass .equals (PiggybackShadowVariable .class )
295- || variableAnnotationClass .equals (CascadingUpdateShadowVariable .class )
296- || variableAnnotationClass .equals (CascadingUpdateShadowVariable .List .class )) {
293+ || variableAnnotationClass .equals (CascadingUpdateShadowVariable .class )) {
297294 memberAccessorType = FIELD_OR_GETTER_METHOD ;
298295 } else {
299296 memberAccessorType = FIELD_OR_GETTER_METHOD_WITH_SETTER ;
@@ -305,38 +302,6 @@ private void processPlanningVariableAnnotation(MutableInt variableDescriptorCoun
305302 }
306303 }
307304
308- private void processPiggyBackForCascadingUpdateShadowVariables () {
309- if (!declaredCascadingUpdateShadowVariableDecriptorMap .isEmpty ()) {
310- var piggybackShadowVariableDescriptorList = declaredShadowVariableDescriptorMap
311- .values ()
312- .stream ()
313- .filter (v -> PiggybackShadowVariableDescriptor .class .isAssignableFrom (v .getClass ()))
314- .map (v -> (PiggybackShadowVariableDescriptor <Solution_ >) v )
315- .toList ();
316- for (var descriptor : piggybackShadowVariableDescriptorList ) {
317- var cascadingUpdateShadowVariableDescriptor =
318- findNotifiableCascadingUpdateDescriptor (descriptor .getShadowVariableName ());
319- if (cascadingUpdateShadowVariableDescriptor != null ) {
320- cascadingUpdateShadowVariableDescriptor .addTargetVariable (descriptor .getEntityDescriptor (),
321- descriptor .getMemberAccessor ());
322- }
323- }
324- }
325- }
326-
327- private CascadingUpdateShadowVariableDescriptor <Solution_ >
328- findNotifiableCascadingUpdateDescriptor (String variableName ) {
329- var descriptor = declaredShadowVariableDescriptorMap .get (variableName );
330- var isCascadingUpdateDescriptor =
331- descriptor != null && CascadingUpdateShadowVariableDescriptor .class .isAssignableFrom (descriptor .getClass ());
332- if (isCascadingUpdateDescriptor && !descriptor .hasVariableListener ()) {
333- descriptor =
334- declaredCascadingUpdateShadowVariableDecriptorMap
335- .get (((CascadingUpdateShadowVariableDescriptor <Solution_ >) descriptor ).getTargetMethodName ());
336- }
337- return isCascadingUpdateDescriptor ? (CascadingUpdateShadowVariableDescriptor <Solution_ >) descriptor : null ;
338- }
339-
340305 private void registerVariableAccessor (int nextVariableDescriptorOrdinal ,
341306 Class <? extends Annotation > variableAnnotationClass , MemberAccessor memberAccessor ) {
342307 var memberName = memberAccessor .getName ();
@@ -392,24 +357,17 @@ The entityClass (%s) has a @%s annotated member (%s) that has an unsupported typ
392357 || variableAnnotationClass .equals (ShadowVariable .List .class )) {
393358 var variableDescriptor = new CustomShadowVariableDescriptor <>(nextVariableDescriptorOrdinal , this , memberAccessor );
394359 declaredShadowVariableDescriptorMap .put (memberName , variableDescriptor );
395- } else if (variableAnnotationClass .equals (CascadingUpdateShadowVariable .class )
396- || variableAnnotationClass .equals (CascadingUpdateShadowVariable .List .class )) {
360+ } else if (variableAnnotationClass .equals (CascadingUpdateShadowVariable .class )) {
397361 var variableDescriptor =
398362 new CascadingUpdateShadowVariableDescriptor <>(nextVariableDescriptorOrdinal , this , memberAccessor );
399363 declaredShadowVariableDescriptorMap .put (memberName , variableDescriptor );
400364 if (declaredCascadingUpdateShadowVariableDecriptorMap .containsKey (variableDescriptor .getTargetMethodName ())) {
401365 // If the target method is already set,
402366 // it means that multiple fields define the cascading shadow variable
403367 // and point to the same target method.
404- // As a result, only one listener will be created for the related target method,
405- // which will include all sources from all fields.
406- // This specific shadow variable will not be notifiable,
407- // and no listener will be created from CascadingUpdateVariableListenerDescriptor#buildVariableListeners.
408- variableDescriptor .setNotifiable (false );
409368 declaredCascadingUpdateShadowVariableDecriptorMap .get (variableDescriptor .getTargetMethodName ())
410369 .addTargetVariable (this , memberAccessor );
411370 } else {
412- // The first shadow variable read is notifiable and will generate a listener.
413371 declaredCascadingUpdateShadowVariableDecriptorMap .put (variableDescriptor .getTargetMethodName (),
414372 variableDescriptor );
415373 }
@@ -608,6 +566,10 @@ public boolean hasEffectiveMovableEntitySelectionFilter() {
608566 return effectiveMovableEntitySelectionFilter != null ;
609567 }
610568
569+ public boolean hasCascadingShadowVariables () {
570+ return !declaredShadowVariableDescriptorMap .isEmpty ();
571+ }
572+
611573 public boolean supportsPinning () {
612574 return hasEffectiveMovableEntitySelectionFilter () || effectivePlanningPinToIndexReader != null ;
613575 }
@@ -691,6 +653,11 @@ public Collection<ShadowVariableDescriptor<Solution_>> getDeclaredShadowVariable
691653 return declaredShadowVariableDescriptorMap .values ();
692654 }
693655
656+ public Collection <CascadingUpdateShadowVariableDescriptor <Solution_ >>
657+ getDeclaredCascadingUpdateShadowVariableDescriptors () {
658+ return declaredCascadingUpdateShadowVariableDecriptorMap .values ();
659+ }
660+
694661 public Collection <VariableDescriptor <Solution_ >> getDeclaredVariableDescriptors () {
695662 Collection <VariableDescriptor <Solution_ >> variableDescriptors = new ArrayList <>(
696663 declaredGenuineVariableDescriptorMap .size () + declaredShadowVariableDescriptorMap .size ());
0 commit comments