Skip to content

Commit

Permalink
PLANNER-383 @CustomShadowVariable sources parameter type changed for …
Browse files Browse the repository at this point in the history
…consistency
  • Loading branch information
ge0ffrey committed Jul 1, 2016
1 parent 4f3a69d commit fe2fbcf
Show file tree
Hide file tree
Showing 15 changed files with 44 additions and 59 deletions.
Expand Up @@ -58,30 +58,6 @@ interface NullVariableListener extends VariableListener {}
* The source variables (masters) that trigger a change to this shadow variable (slave). * The source variables (masters) that trigger a change to this shadow variable (slave).
* @return never null (unless {@link #variableListenerRef()} is not null), at least 1 * @return never null (unless {@link #variableListenerRef()} is not null), at least 1
*/ */
Source[] sources() default {}; PlanningVariableReference[] sources() default {};

/**
* Declares which genuine variable (or other shadow variable) causes the shadow variable to change.
*/
// TODO Replace with @PlanningVariableReference when upgrading to 7.0
public static @interface Source {

/**
* Specified if the source variable is on a different {@link Class} than the shadow variable.
* @return {@link NullEntityClass} when it is null (workaround for annotation limitation).
* Defaults to the same {@link Class} as the one that contains the {@link CustomShadowVariable} annotation.
*/
Class<?> entityClass() default NullEntityClass.class;

/** Workaround for annotation limitation in {@link #entityClass()}. */
interface NullEntityClass {}

/**
* A source variable that causes the shadow variable to change.
* @return never null, a genuine or shadow variable
*/
String variableName();

}


} }
Expand Up @@ -65,7 +65,7 @@ private void processPropertyAnnotations(DescriptorPolicy descriptorPolicy) {
if (variableListenerClass == CustomShadowVariable.NullVariableListener.class) { if (variableListenerClass == CustomShadowVariable.NullVariableListener.class) {
variableListenerClass = null; variableListenerClass = null;
} }
CustomShadowVariable.Source[] sources = shadowVariableAnnotation.sources(); PlanningVariableReference[] sources = shadowVariableAnnotation.sources();
if (variableListenerRef != null) { if (variableListenerRef != null) {
if (variableListenerClass != null || sources.length > 0) { if (variableListenerClass != null || sources.length > 0) {
throw new IllegalArgumentException("The entityClass (" + entityDescriptor.getEntityClass() throw new IllegalArgumentException("The entityClass (" + entityDescriptor.getEntityClass()
Expand Down Expand Up @@ -147,12 +147,12 @@ public void linkShadowSources(DescriptorPolicy descriptorPolicy) {
} }
refVariableDescriptor.registerSinkVariableDescriptor(this); refVariableDescriptor.registerSinkVariableDescriptor(this);
} else { } else {
CustomShadowVariable.Source[] sources = shadowVariableAnnotation.sources(); PlanningVariableReference[] sources = shadowVariableAnnotation.sources();
sourceVariableDescriptorList = new ArrayList<>(sources.length); sourceVariableDescriptorList = new ArrayList<>(sources.length);
for (CustomShadowVariable.Source source : sources) { for (PlanningVariableReference source : sources) {
EntityDescriptor<Solution_> sourceEntityDescriptor; EntityDescriptor<Solution_> sourceEntityDescriptor;
Class<?> sourceEntityClass = source.entityClass(); Class<?> sourceEntityClass = source.entityClass();
if (sourceEntityClass.equals(CustomShadowVariable.Source.NullEntityClass.class)) { if (sourceEntityClass.equals(PlanningVariableReference.NullEntityClass.class)) {
sourceEntityDescriptor = entityDescriptor; sourceEntityDescriptor = entityDescriptor;
} else { } else {
sourceEntityDescriptor = entityDescriptor.getSolutionDescriptor() sourceEntityDescriptor = entityDescriptor.getSolutionDescriptor()
Expand Down
Expand Up @@ -19,6 +19,7 @@
import org.optaplanner.core.api.domain.entity.PlanningEntity; import org.optaplanner.core.api.domain.entity.PlanningEntity;
import org.optaplanner.core.api.domain.variable.CustomShadowVariable; import org.optaplanner.core.api.domain.variable.CustomShadowVariable;
import org.optaplanner.core.api.domain.variable.PlanningVariable; import org.optaplanner.core.api.domain.variable.PlanningVariable;
import org.optaplanner.core.api.domain.variable.PlanningVariableReference;
import org.optaplanner.core.impl.domain.entity.descriptor.EntityDescriptor; import org.optaplanner.core.impl.domain.entity.descriptor.EntityDescriptor;
import org.optaplanner.core.impl.domain.solution.descriptor.SolutionDescriptor; import org.optaplanner.core.impl.domain.solution.descriptor.SolutionDescriptor;
import org.optaplanner.core.impl.domain.variable.descriptor.GenuineVariableDescriptor; import org.optaplanner.core.impl.domain.variable.descriptor.GenuineVariableDescriptor;
Expand Down Expand Up @@ -72,7 +73,7 @@ public void setValue(TestdataValue value) {
} }


@CustomShadowVariable(variableListenerClass = VariableListenerAdapter.class, @CustomShadowVariable(variableListenerClass = VariableListenerAdapter.class,
sources = {@CustomShadowVariable.Source(variableName = "secondShadow")}) sources = {@PlanningVariableReference(variableName = "secondShadow")})
public String getThirdShadow() { public String getThirdShadow() {
return thirdShadow; return thirdShadow;
} }
Expand All @@ -82,7 +83,7 @@ public void setThirdShadow(String thirdShadow) {
} }


@CustomShadowVariable(variableListenerClass = VariableListenerAdapter.class, @CustomShadowVariable(variableListenerClass = VariableListenerAdapter.class,
sources = {@CustomShadowVariable.Source(variableName = "fourthShadow")}) sources = {@PlanningVariableReference(variableName = "fourthShadow")})
public String getFifthShadow() { public String getFifthShadow() {
return fifthShadow; return fifthShadow;
} }
Expand All @@ -92,7 +93,7 @@ public void setFifthShadow(String fifthShadow) {
} }


@CustomShadowVariable(variableListenerClass = VariableListenerAdapter.class, @CustomShadowVariable(variableListenerClass = VariableListenerAdapter.class,
sources = {@CustomShadowVariable.Source(variableName = "value")}) sources = {@PlanningVariableReference(variableName = "value")})
public String getFirstShadow() { public String getFirstShadow() {
return firstShadow; return firstShadow;
} }
Expand All @@ -102,7 +103,7 @@ public void setFirstShadow(String firstShadow) {
} }


@CustomShadowVariable(variableListenerClass = VariableListenerAdapter.class, @CustomShadowVariable(variableListenerClass = VariableListenerAdapter.class,
sources = {@CustomShadowVariable.Source(variableName = "thirdShadow")}) sources = {@PlanningVariableReference(variableName = "thirdShadow")})
public String getFourthShadow() { public String getFourthShadow() {
return fourthShadow; return fourthShadow;
} }
Expand All @@ -112,7 +113,7 @@ public void setFourthShadow(String fourthShadow) {
} }


@CustomShadowVariable(variableListenerClass = VariableListenerAdapter.class, @CustomShadowVariable(variableListenerClass = VariableListenerAdapter.class,
sources = {@CustomShadowVariable.Source(variableName = "firstShadow")}) sources = {@PlanningVariableReference(variableName = "firstShadow")})
public String getSecondShadow() { public String getSecondShadow() {
return secondShadow; return secondShadow;
} }
Expand All @@ -122,7 +123,7 @@ public void setSecondShadow(String secondShadow) {
} }


@CustomShadowVariable(variableListenerClass = VariableListenerAdapter.class, @CustomShadowVariable(variableListenerClass = VariableListenerAdapter.class,
sources = {@CustomShadowVariable.Source(variableName = "sixthShadow")}) sources = {@PlanningVariableReference(variableName = "sixthShadow")})
public String getSeventhShadow() { public String getSeventhShadow() {
return seventhShadow; return seventhShadow;
} }
Expand All @@ -132,7 +133,7 @@ public void setSeventhShadow(String seventhShadow) {
} }


@CustomShadowVariable(variableListenerClass = VariableListenerAdapter.class, @CustomShadowVariable(variableListenerClass = VariableListenerAdapter.class,
sources = {@CustomShadowVariable.Source(variableName = "fifthShadow")}) sources = {@PlanningVariableReference(variableName = "fifthShadow")})
public String getSixthShadow() { public String getSixthShadow() {
return sixthShadow; return sixthShadow;
} }
Expand Down
Expand Up @@ -68,8 +68,8 @@ public void setValue(TestdataValue value) {
} }


@CustomShadowVariable(variableListenerClass = BarberAndCutsOwnHairUpdatingVariableListener.class, @CustomShadowVariable(variableListenerClass = BarberAndCutsOwnHairUpdatingVariableListener.class,
sources = {@CustomShadowVariable.Source(variableName = "value"), sources = {@PlanningVariableReference(variableName = "value"),
@CustomShadowVariable.Source(variableName = "cutsOwnHair")}) @PlanningVariableReference(variableName = "cutsOwnHair")})
public boolean isBarber() { public boolean isBarber() {
return barber; return barber;
} }
Expand Down
Expand Up @@ -19,6 +19,7 @@
import org.optaplanner.core.api.domain.entity.PlanningEntity; import org.optaplanner.core.api.domain.entity.PlanningEntity;
import org.optaplanner.core.api.domain.variable.CustomShadowVariable; import org.optaplanner.core.api.domain.variable.CustomShadowVariable;
import org.optaplanner.core.api.domain.variable.PlanningVariable; import org.optaplanner.core.api.domain.variable.PlanningVariable;
import org.optaplanner.core.api.domain.variable.PlanningVariableReference;
import org.optaplanner.core.impl.domain.entity.descriptor.EntityDescriptor; import org.optaplanner.core.impl.domain.entity.descriptor.EntityDescriptor;
import org.optaplanner.core.impl.domain.solution.descriptor.SolutionDescriptor; import org.optaplanner.core.impl.domain.solution.descriptor.SolutionDescriptor;
import org.optaplanner.core.impl.domain.variable.descriptor.GenuineVariableDescriptor; import org.optaplanner.core.impl.domain.variable.descriptor.GenuineVariableDescriptor;
Expand Down Expand Up @@ -68,7 +69,7 @@ public void setValue(TestdataValue value) {
} }


@CustomShadowVariable(variableListenerClass = RockShadowUpdatingVariableListener.class, @CustomShadowVariable(variableListenerClass = RockShadowUpdatingVariableListener.class,
sources = {@CustomShadowVariable.Source(variableName = "scissorsShadow")}) sources = {@PlanningVariableReference(variableName = "scissorsShadow")})
public String getRockShadow() { public String getRockShadow() {
return rockShadow; return rockShadow;
} }
Expand All @@ -78,7 +79,7 @@ public void setRockShadow(String rockShadow) {
} }


@CustomShadowVariable(variableListenerClass = PaperShadowUpdatingVariableListener.class, @CustomShadowVariable(variableListenerClass = PaperShadowUpdatingVariableListener.class,
sources = {@CustomShadowVariable.Source(variableName = "rockShadow")}) sources = {@PlanningVariableReference(variableName = "rockShadow")})
public String getPaperShadow() { public String getPaperShadow() {
return paperShadow; return paperShadow;
} }
Expand All @@ -88,7 +89,7 @@ public void setPaperShadow(String paperShadow) {
} }


@CustomShadowVariable(variableListenerClass = ScissorsShadowUpdatingVariableListener.class, @CustomShadowVariable(variableListenerClass = ScissorsShadowUpdatingVariableListener.class,
sources = {@CustomShadowVariable.Source(variableName = "paperShadow")}) sources = {@PlanningVariableReference(variableName = "paperShadow")})
public String getScissorsShadow() { public String getScissorsShadow() {
return scissorsShadow; return scissorsShadow;
} }
Expand Down
Expand Up @@ -18,6 +18,7 @@


import org.optaplanner.core.api.domain.entity.PlanningEntity; import org.optaplanner.core.api.domain.entity.PlanningEntity;
import org.optaplanner.core.api.domain.variable.CustomShadowVariable; import org.optaplanner.core.api.domain.variable.CustomShadowVariable;
import org.optaplanner.core.api.domain.variable.PlanningVariableReference;
import org.optaplanner.core.impl.domain.entity.descriptor.EntityDescriptor; import org.optaplanner.core.impl.domain.entity.descriptor.EntityDescriptor;
import org.optaplanner.core.impl.domain.solution.descriptor.SolutionDescriptor; import org.optaplanner.core.impl.domain.solution.descriptor.SolutionDescriptor;
import org.optaplanner.core.impl.domain.variable.listener.VariableListenerAdapter; import org.optaplanner.core.impl.domain.variable.listener.VariableListenerAdapter;
Expand Down Expand Up @@ -46,7 +47,7 @@ public TestdataExtendedShadowedChildEntity(String code, TestdataValue value) {
} }


@CustomShadowVariable(variableListenerClass = SecondShadowUpdatingVariableListener.class, @CustomShadowVariable(variableListenerClass = SecondShadowUpdatingVariableListener.class,
sources = {@CustomShadowVariable.Source(variableName = "firstShadow")}) sources = {@PlanningVariableReference(variableName = "firstShadow")})
public String getSecondShadow() { public String getSecondShadow() {
return secondShadow; return secondShadow;
} }
Expand Down
Expand Up @@ -19,6 +19,7 @@
import org.optaplanner.core.api.domain.entity.PlanningEntity; import org.optaplanner.core.api.domain.entity.PlanningEntity;
import org.optaplanner.core.api.domain.variable.CustomShadowVariable; import org.optaplanner.core.api.domain.variable.CustomShadowVariable;
import org.optaplanner.core.api.domain.variable.PlanningVariable; import org.optaplanner.core.api.domain.variable.PlanningVariable;
import org.optaplanner.core.api.domain.variable.PlanningVariableReference;
import org.optaplanner.core.impl.domain.entity.descriptor.EntityDescriptor; import org.optaplanner.core.impl.domain.entity.descriptor.EntityDescriptor;
import org.optaplanner.core.impl.domain.solution.descriptor.SolutionDescriptor; import org.optaplanner.core.impl.domain.solution.descriptor.SolutionDescriptor;
import org.optaplanner.core.impl.domain.variable.descriptor.GenuineVariableDescriptor; import org.optaplanner.core.impl.domain.variable.descriptor.GenuineVariableDescriptor;
Expand Down Expand Up @@ -67,7 +68,7 @@ public void setValue(TestdataValue value) {
} }


@CustomShadowVariable(variableListenerClass = FirstShadowUpdatingVariableListener.class, @CustomShadowVariable(variableListenerClass = FirstShadowUpdatingVariableListener.class,
sources = {@CustomShadowVariable.Source(variableName = "value")}) sources = {@PlanningVariableReference(variableName = "value")})
public String getFirstShadow() { public String getFirstShadow() {
return firstShadow; return firstShadow;
} }
Expand All @@ -77,7 +78,7 @@ public void setFirstShadow(String firstShadow) {
} }


@CustomShadowVariable(variableListenerClass = ThirdShadowUpdatingVariableListener.class, @CustomShadowVariable(variableListenerClass = ThirdShadowUpdatingVariableListener.class,
sources = {@CustomShadowVariable.Source( sources = {@PlanningVariableReference(
entityClass = TestdataExtendedShadowedChildEntity.class, variableName = "secondShadow")}) entityClass = TestdataExtendedShadowedChildEntity.class, variableName = "secondShadow")})
public String getThirdShadow() { public String getThirdShadow() {
return thirdShadow; return thirdShadow;
Expand Down
Expand Up @@ -72,8 +72,8 @@ public void setSecondaryValue(TestdataValue secondaryValue) {
} }


@CustomShadowVariable(variableListenerClass = ComposedValuesUpdatingVariableListener.class, @CustomShadowVariable(variableListenerClass = ComposedValuesUpdatingVariableListener.class,
sources = {@CustomShadowVariable.Source(variableName = "primaryValue"), sources = {@PlanningVariableReference(variableName = "primaryValue"),
@CustomShadowVariable.Source(variableName = "secondaryValue")}) @PlanningVariableReference(variableName = "secondaryValue")})
public String getComposedCode() { public String getComposedCode() {
return composedCode; return composedCode;
} }
Expand Down
Expand Up @@ -1287,7 +1287,7 @@ public class Customer {
} }


@CustomShadowVariable(variableListenerClass = VehicleUpdatingVariableListener.class, @CustomShadowVariable(variableListenerClass = VehicleUpdatingVariableListener.class,
sources = {@CustomShadowVariable.Source(variableName = "previousStandstill")}) sources = {@PlanningVariableReference(variableName = "previousStandstill")})
public Vehicle getVehicle() { public Vehicle getVehicle() {
return vehicle; return vehicle;
}</programlisting> }</programlisting>
Expand All @@ -1297,7 +1297,7 @@ public class Customer {


<note> <note>
<para>If the class of the trigger variable is different than the shadow variable, also specify the <para>If the class of the trigger variable is different than the shadow variable, also specify the
<literal>entityClass</literal> on <literal>@CustomShadowVariable.Source</literal>. In that case, make sure <literal>entityClass</literal> on <literal>@PlanningVariableReference</literal>. In that case, make sure
that that <literal>entityClass</literal> is also properly configured as a planning entity class in the solver that that <literal>entityClass</literal> is also properly configured as a planning entity class in the solver
config, or the <literal>VariableListener</literal> will simply never trigger.</para> config, or the <literal>VariableListener</literal> will simply never trigger.</para>
</note> </note>
Expand Down Expand Up @@ -1352,7 +1352,7 @@ public class Customer {
} }


@CustomShadowVariable(variableListenerClass = TransportTimeAndCapacityUpdatingVariableListener.class, @CustomShadowVariable(variableListenerClass = TransportTimeAndCapacityUpdatingVariableListener.class,
sources = {@CustomShadowVariable.Source(variableName = "previousStandstill")}) sources = {@PlanningVariableReference(variableName = "previousStandstill")})
public Integer getTransportTime() { public Integer getTransportTime() {
return transportTime; return transportTime;
} }
Expand Down
Expand Up @@ -24,6 +24,7 @@
import org.optaplanner.core.api.domain.variable.CustomShadowVariable; import org.optaplanner.core.api.domain.variable.CustomShadowVariable;
import org.optaplanner.core.api.domain.variable.PlanningVariable; import org.optaplanner.core.api.domain.variable.PlanningVariable;
import org.optaplanner.core.api.domain.variable.PlanningVariableGraphType; import org.optaplanner.core.api.domain.variable.PlanningVariableGraphType;
import org.optaplanner.core.api.domain.variable.PlanningVariableReference;
import org.optaplanner.examples.coachshuttlegathering.domain.location.RoadLocation; import org.optaplanner.examples.coachshuttlegathering.domain.location.RoadLocation;
import org.optaplanner.examples.coachshuttlegathering.domain.solver.DepotAngleBusStopDifficultyWeightFactory; import org.optaplanner.examples.coachshuttlegathering.domain.solver.DepotAngleBusStopDifficultyWeightFactory;
import org.optaplanner.examples.coachshuttlegathering.domain.solver.TransportTimeToHubUpdatingVariableListener; import org.optaplanner.examples.coachshuttlegathering.domain.solver.TransportTimeToHubUpdatingVariableListener;
Expand Down Expand Up @@ -122,9 +123,9 @@ public void setTransferShuttleList(List<Shuttle> transferShuttleList) {
} }


@CustomShadowVariable(variableListenerClass = TransportTimeToHubUpdatingVariableListener.class, @CustomShadowVariable(variableListenerClass = TransportTimeToHubUpdatingVariableListener.class,
sources = {@CustomShadowVariable.Source(variableName = "nextStop"), sources = {@PlanningVariableReference(variableName = "nextStop"),
@CustomShadowVariable.Source(variableName = "bus"), @PlanningVariableReference(variableName = "bus"),
@CustomShadowVariable.Source(entityClass = Shuttle.class, variableName = "destination")}) @PlanningVariableReference(entityClass = Shuttle.class, variableName = "destination")})
@Override @Override
public Integer getTransportTimeToHub() { public Integer getTransportTimeToHub() {
return transportTimeToHub; return transportTimeToHub;
Expand Down
Expand Up @@ -19,6 +19,7 @@
import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamAlias;
import org.optaplanner.core.api.domain.entity.PlanningEntity; import org.optaplanner.core.api.domain.entity.PlanningEntity;
import org.optaplanner.core.api.domain.variable.CustomShadowVariable; import org.optaplanner.core.api.domain.variable.CustomShadowVariable;
import org.optaplanner.core.api.domain.variable.PlanningVariableReference;
import org.optaplanner.examples.examination.domain.solver.PeriodUpdatingVariableListener; import org.optaplanner.examples.examination.domain.solver.PeriodUpdatingVariableListener;


@PlanningEntity @PlanningEntity
Expand All @@ -40,7 +41,7 @@ public void setLeadingExam(LeadingExam leadingExam) {


@Override @Override
@CustomShadowVariable(variableListenerClass = PeriodUpdatingVariableListener.class, @CustomShadowVariable(variableListenerClass = PeriodUpdatingVariableListener.class,
sources = {@CustomShadowVariable.Source(entityClass = LeadingExam.class, variableName = "period")}) sources = {@PlanningVariableReference(entityClass = LeadingExam.class, variableName = "period")})
public Period getPeriod() { public Period getPeriod() {
return period; return period;
} }
Expand Down
Expand Up @@ -25,6 +25,7 @@
import org.optaplanner.core.api.domain.valuerange.ValueRangeProvider; import org.optaplanner.core.api.domain.valuerange.ValueRangeProvider;
import org.optaplanner.core.api.domain.variable.CustomShadowVariable; import org.optaplanner.core.api.domain.variable.CustomShadowVariable;
import org.optaplanner.core.api.domain.variable.PlanningVariable; import org.optaplanner.core.api.domain.variable.PlanningVariable;
import org.optaplanner.core.api.domain.variable.PlanningVariableReference;
import org.optaplanner.examples.common.domain.AbstractPersistable; import org.optaplanner.examples.common.domain.AbstractPersistable;
import org.optaplanner.examples.projectjobscheduling.domain.solver.DelayStrengthComparator; import org.optaplanner.examples.projectjobscheduling.domain.solver.DelayStrengthComparator;
import org.optaplanner.examples.projectjobscheduling.domain.solver.ExecutionModeStrengthWeightFactory; import org.optaplanner.examples.projectjobscheduling.domain.solver.ExecutionModeStrengthWeightFactory;
Expand Down Expand Up @@ -110,8 +111,8 @@ public void setDelay(Integer delay) {
} }


@CustomShadowVariable(variableListenerClass = PredecessorsDoneDateUpdatingVariableListener.class, @CustomShadowVariable(variableListenerClass = PredecessorsDoneDateUpdatingVariableListener.class,
sources = {@CustomShadowVariable.Source(variableName = "executionMode"), sources = {@PlanningVariableReference(variableName = "executionMode"),
@CustomShadowVariable.Source(variableName = "delay")}) @PlanningVariableReference(variableName = "delay")})
public Integer getPredecessorsDoneDate() { public Integer getPredecessorsDoneDate() {
return predecessorsDoneDate; return predecessorsDoneDate;
} }
Expand Down
Expand Up @@ -35,8 +35,8 @@ public class ScrabbleCell extends AbstractPersistable {
private int y; private int y;


@CustomShadowVariable(variableListenerClass = CellUpdatingVariableListener.class, @CustomShadowVariable(variableListenerClass = CellUpdatingVariableListener.class,
sources = {@CustomShadowVariable.Source(entityClass = ScrabbleWordAssignment.class, variableName = "startCell"), sources = {@PlanningVariableReference(entityClass = ScrabbleWordAssignment.class, variableName = "startCell"),
@CustomShadowVariable.Source(entityClass = ScrabbleWordAssignment.class, variableName = "direction"),}) @PlanningVariableReference(entityClass = ScrabbleWordAssignment.class, variableName = "direction"),})
@DeepPlanningClone // TODO Why is this needed? This is already a shadow var @DeepPlanningClone // TODO Why is this needed? This is already a shadow var
private Set<ScrabbleWordAssignment> wordSet; private Set<ScrabbleWordAssignment> wordSet;


Expand Down
Expand Up @@ -24,6 +24,7 @@
import org.optaplanner.core.api.domain.variable.CustomShadowVariable; import org.optaplanner.core.api.domain.variable.CustomShadowVariable;
import org.optaplanner.core.api.domain.variable.PlanningVariable; import org.optaplanner.core.api.domain.variable.PlanningVariable;
import org.optaplanner.core.api.domain.variable.PlanningVariableGraphType; import org.optaplanner.core.api.domain.variable.PlanningVariableGraphType;
import org.optaplanner.core.api.domain.variable.PlanningVariableReference;
import org.optaplanner.examples.common.swingui.components.Labeled; import org.optaplanner.examples.common.swingui.components.Labeled;
import org.optaplanner.examples.taskassigning.domain.solver.MovableTaskSelectionFilter; import org.optaplanner.examples.taskassigning.domain.solver.MovableTaskSelectionFilter;
import org.optaplanner.examples.taskassigning.domain.solver.StartTimeUpdatingVariableListener; import org.optaplanner.examples.taskassigning.domain.solver.StartTimeUpdatingVariableListener;
Expand Down Expand Up @@ -53,7 +54,7 @@ public class Task extends TaskOrEmployee implements Labeled {
@CustomShadowVariable(variableListenerClass = StartTimeUpdatingVariableListener.class, @CustomShadowVariable(variableListenerClass = StartTimeUpdatingVariableListener.class,
// Arguable, to adhere to API specs (although this works), nextTask and employee should also be a source, // Arguable, to adhere to API specs (although this works), nextTask and employee should also be a source,
// because this shadow must be triggered after nextTask and employee (but there is no need to be triggered by those) // because this shadow must be triggered after nextTask and employee (but there is no need to be triggered by those)
sources = {@CustomShadowVariable.Source(variableName = "previousTaskOrEmployee")}) sources = {@PlanningVariableReference(variableName = "previousTaskOrEmployee")})
private Integer startTime; // In minutes private Integer startTime; // In minutes


public TaskType getTaskType() { public TaskType getTaskType() {
Expand Down
Expand Up @@ -19,6 +19,7 @@
import com.thoughtworks.xstream.annotations.XStreamAlias; import com.thoughtworks.xstream.annotations.XStreamAlias;
import org.optaplanner.core.api.domain.entity.PlanningEntity; import org.optaplanner.core.api.domain.entity.PlanningEntity;
import org.optaplanner.core.api.domain.variable.CustomShadowVariable; import org.optaplanner.core.api.domain.variable.CustomShadowVariable;
import org.optaplanner.core.api.domain.variable.PlanningVariableReference;
import org.optaplanner.examples.vehiclerouting.domain.Customer; import org.optaplanner.examples.vehiclerouting.domain.Customer;
import org.optaplanner.examples.vehiclerouting.domain.timewindowed.solver.ArrivalTimeUpdatingVariableListener; import org.optaplanner.examples.vehiclerouting.domain.timewindowed.solver.ArrivalTimeUpdatingVariableListener;


Expand Down Expand Up @@ -73,7 +74,7 @@ public void setServiceDuration(long serviceDuration) {
@CustomShadowVariable(variableListenerClass = ArrivalTimeUpdatingVariableListener.class, @CustomShadowVariable(variableListenerClass = ArrivalTimeUpdatingVariableListener.class,
// Arguable, to adhere to API specs (although this works), nextCustomer should also be a source, // Arguable, to adhere to API specs (although this works), nextCustomer should also be a source,
// because this shadow must be triggered after nextCustomer (but there is no need to be triggered by nextCustomer) // because this shadow must be triggered after nextCustomer (but there is no need to be triggered by nextCustomer)
sources = {@CustomShadowVariable.Source(variableName = "previousStandstill")}) sources = {@PlanningVariableReference(variableName = "previousStandstill")})
public Long getArrivalTime() { public Long getArrivalTime() {
return arrivalTime; return arrivalTime;
} }
Expand Down

0 comments on commit fe2fbcf

Please sign in to comment.