proj_name
stringclasses
131 values
relative_path
stringlengths
30
228
class_name
stringlengths
1
68
func_name
stringlengths
1
48
masked_class
stringlengths
78
9.82k
func_body
stringlengths
46
9.61k
len_input
int64
29
2.01k
len_output
int64
14
1.94k
total
int64
55
2.05k
relevant_context
stringlengths
0
38.4k
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-constraint-streams-drools/src/main/java/org/optaplanner/constraint/streams/drools/tri/DroolsExistsTriConstraintStream.java
DroolsExistsTriConstraintStream
toString
class DroolsExistsTriConstraintStream<Solution_, A, B, C> extends DroolsAbstractTriConstraintStream<Solution_, A, B, C> { private final DroolsAbstractTriConstraintStream<Solution_, A, B, C> parent; private final Supplier<TriLeftHandSide<A, B, C>> leftHandSide; private final String streamName; public <D> DroolsExistsTriConstraintStream(DroolsConstraintFactory<Solution_> constraintFactory, DroolsAbstractTriConstraintStream<Solution_, A, B, C> parent, boolean shouldExist, boolean shouldIncludeNullVars, Class<D> otherClass, QuadJoiner<A, B, C, D>... joiners) { super(constraintFactory, parent.getRetrievalSemantics()); this.parent = parent; Predicate<D> nullityFilter = shouldIncludeNullVars ? null : constraintFactory.getNullityFilter(otherClass); this.leftHandSide = () -> shouldExist ? parent.createLeftHandSide().andExists(otherClass, joiners, nullityFilter) : parent.createLeftHandSide().andNotExists(otherClass, joiners, nullityFilter); this.streamName = shouldExist ? "TriIfExists()" : "TriIfNotExists()"; } @Override public boolean guaranteesDistinct() { return parent.guaranteesDistinct(); } // ************************************************************************ // Pattern creation // ************************************************************************ @Override public TriLeftHandSide<A, B, C> createLeftHandSide() { return leftHandSide.get(); } @Override public String toString() {<FILL_FUNCTION_BODY>} }
return streamName + " with " + getChildStreams().size() + " children";
440
24
464
<methods>public void <init>(DroolsConstraintFactory<Solution_>, org.optaplanner.constraint.streams.common.RetrievalSemantics) ,public TriConstraintStream<A,B,C> filter(TriPredicate<A,B,C>) ,public TriConstraintStream<A,B,ResultC_> flattenLast(Function<C,Iterable<ResultC_>>) ,public UniConstraintStream<Result_> groupBy(TriConstraintCollector<A,B,C,ResultContainer_,Result_>) ,public BiConstraintStream<ResultA_,ResultB_> groupBy(TriConstraintCollector<A,B,C,ResultContainerA_,ResultA_>, TriConstraintCollector<A,B,C,ResultContainerB_,ResultB_>) ,public TriConstraintStream<ResultA_,ResultB_,ResultC_> groupBy(TriConstraintCollector<A,B,C,ResultContainerA_,ResultA_>, TriConstraintCollector<A,B,C,ResultContainerB_,ResultB_>, TriConstraintCollector<A,B,C,ResultContainerC_,ResultC_>) ,public QuadConstraintStream<ResultA_,ResultB_,ResultC_,ResultD_> groupBy(TriConstraintCollector<A,B,C,ResultContainerA_,ResultA_>, TriConstraintCollector<A,B,C,ResultContainerB_,ResultB_>, TriConstraintCollector<A,B,C,ResultContainerC_,ResultC_>, TriConstraintCollector<A,B,C,ResultContainerD_,ResultD_>) ,public UniConstraintStream<GroupKey_> groupBy(TriFunction<A,B,C,GroupKey_>) ,public BiConstraintStream<GroupKey_,Result_> groupBy(TriFunction<A,B,C,GroupKey_>, TriConstraintCollector<A,B,C,ResultContainer_,Result_>) ,public TriConstraintStream<GroupKey_,ResultB_,ResultC_> groupBy(TriFunction<A,B,C,GroupKey_>, TriConstraintCollector<A,B,C,ResultContainerB_,ResultB_>, TriConstraintCollector<A,B,C,ResultContainerC_,ResultC_>) ,public QuadConstraintStream<GroupKey_,ResultB_,ResultC_,ResultD_> groupBy(TriFunction<A,B,C,GroupKey_>, TriConstraintCollector<A,B,C,ResultContainerB_,ResultB_>, TriConstraintCollector<A,B,C,ResultContainerC_,ResultC_>, TriConstraintCollector<A,B,C,ResultContainerD_,ResultD_>) ,public BiConstraintStream<GroupKeyA_,GroupKeyB_> groupBy(TriFunction<A,B,C,GroupKeyA_>, TriFunction<A,B,C,GroupKeyB_>) ,public TriConstraintStream<GroupKeyA_,GroupKeyB_,Result_> groupBy(TriFunction<A,B,C,GroupKeyA_>, TriFunction<A,B,C,GroupKeyB_>, TriConstraintCollector<A,B,C,ResultContainer_,Result_>) ,public QuadConstraintStream<GroupKeyA_,GroupKeyB_,ResultC_,ResultD_> groupBy(TriFunction<A,B,C,GroupKeyA_>, TriFunction<A,B,C,GroupKeyB_>, TriConstraintCollector<A,B,C,ResultContainerC_,ResultC_>, TriConstraintCollector<A,B,C,ResultContainerD_,ResultD_>) ,public TriConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_> groupBy(TriFunction<A,B,C,GroupKeyA_>, TriFunction<A,B,C,GroupKeyB_>, TriFunction<A,B,C,GroupKeyC_>) ,public QuadConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_,ResultD_> groupBy(TriFunction<A,B,C,GroupKeyA_>, TriFunction<A,B,C,GroupKeyB_>, TriFunction<A,B,C,GroupKeyC_>, TriConstraintCollector<A,B,C,ResultContainerD_,ResultD_>) ,public QuadConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_,GroupKeyD_> groupBy(TriFunction<A,B,C,GroupKeyA_>, TriFunction<A,B,C,GroupKeyB_>, TriFunction<A,B,C,GroupKeyC_>, TriFunction<A,B,C,GroupKeyD_>) ,public final transient TriConstraintStream<A,B,C> ifExists(Class<D>, QuadJoiner<A,B,C,D>[]) ,public final transient TriConstraintStream<A,B,C> ifExistsIncludingNullVars(Class<D>, QuadJoiner<A,B,C,D>[]) ,public final transient TriConstraintStream<A,B,C> ifNotExists(Class<D>, QuadJoiner<A,B,C,D>[]) ,public final transient TriConstraintStream<A,B,C> ifNotExistsIncludingNullVars(Class<D>, QuadJoiner<A,B,C,D>[]) ,public TriConstraintBuilder<A,B,C,Score_> innerImpact(Score_, ToIntTriFunction<A,B,C>, org.optaplanner.constraint.streams.common.ScoreImpactType) ,public TriConstraintBuilder<A,B,C,Score_> innerImpact(Score_, ToLongTriFunction<A,B,C>, org.optaplanner.constraint.streams.common.ScoreImpactType) ,public TriConstraintBuilder<A,B,C,Score_> innerImpact(Score_, TriFunction<A,B,C,java.math.BigDecimal>, org.optaplanner.constraint.streams.common.ScoreImpactType) ,public final transient QuadConstraintStream<A,B,C,D> join(UniConstraintStream<D>, QuadJoiner<A,B,C,D>[]) ,public UniConstraintStream<ResultA_> map(TriFunction<A,B,C,ResultA_>) <variables>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-constraint-streams-drools/src/main/java/org/optaplanner/constraint/streams/drools/tri/DroolsFilterTriConstraintStream.java
DroolsFilterTriConstraintStream
toString
class DroolsFilterTriConstraintStream<Solution_, A, B, C> extends DroolsAbstractTriConstraintStream<Solution_, A, B, C> { private final DroolsAbstractTriConstraintStream<Solution_, A, B, C> parent; private final Supplier<TriLeftHandSide<A, B, C>> leftHandSide; public DroolsFilterTriConstraintStream(DroolsConstraintFactory<Solution_> constraintFactory, DroolsAbstractTriConstraintStream<Solution_, A, B, C> parent, TriPredicate<A, B, C> triPredicate) { super(constraintFactory, parent.getRetrievalSemantics()); this.parent = parent; this.leftHandSide = () -> parent.createLeftHandSide().andFilter(triPredicate); } @Override public boolean guaranteesDistinct() { return parent.guaranteesDistinct(); } // ************************************************************************ // Pattern creation // ************************************************************************ @Override public TriLeftHandSide<A, B, C> createLeftHandSide() { return leftHandSide.get(); } @Override public String toString() {<FILL_FUNCTION_BODY>} }
return "TriFilter() with " + getChildStreams().size() + " children";
313
24
337
<methods>public void <init>(DroolsConstraintFactory<Solution_>, org.optaplanner.constraint.streams.common.RetrievalSemantics) ,public TriConstraintStream<A,B,C> filter(TriPredicate<A,B,C>) ,public TriConstraintStream<A,B,ResultC_> flattenLast(Function<C,Iterable<ResultC_>>) ,public UniConstraintStream<Result_> groupBy(TriConstraintCollector<A,B,C,ResultContainer_,Result_>) ,public BiConstraintStream<ResultA_,ResultB_> groupBy(TriConstraintCollector<A,B,C,ResultContainerA_,ResultA_>, TriConstraintCollector<A,B,C,ResultContainerB_,ResultB_>) ,public TriConstraintStream<ResultA_,ResultB_,ResultC_> groupBy(TriConstraintCollector<A,B,C,ResultContainerA_,ResultA_>, TriConstraintCollector<A,B,C,ResultContainerB_,ResultB_>, TriConstraintCollector<A,B,C,ResultContainerC_,ResultC_>) ,public QuadConstraintStream<ResultA_,ResultB_,ResultC_,ResultD_> groupBy(TriConstraintCollector<A,B,C,ResultContainerA_,ResultA_>, TriConstraintCollector<A,B,C,ResultContainerB_,ResultB_>, TriConstraintCollector<A,B,C,ResultContainerC_,ResultC_>, TriConstraintCollector<A,B,C,ResultContainerD_,ResultD_>) ,public UniConstraintStream<GroupKey_> groupBy(TriFunction<A,B,C,GroupKey_>) ,public BiConstraintStream<GroupKey_,Result_> groupBy(TriFunction<A,B,C,GroupKey_>, TriConstraintCollector<A,B,C,ResultContainer_,Result_>) ,public TriConstraintStream<GroupKey_,ResultB_,ResultC_> groupBy(TriFunction<A,B,C,GroupKey_>, TriConstraintCollector<A,B,C,ResultContainerB_,ResultB_>, TriConstraintCollector<A,B,C,ResultContainerC_,ResultC_>) ,public QuadConstraintStream<GroupKey_,ResultB_,ResultC_,ResultD_> groupBy(TriFunction<A,B,C,GroupKey_>, TriConstraintCollector<A,B,C,ResultContainerB_,ResultB_>, TriConstraintCollector<A,B,C,ResultContainerC_,ResultC_>, TriConstraintCollector<A,B,C,ResultContainerD_,ResultD_>) ,public BiConstraintStream<GroupKeyA_,GroupKeyB_> groupBy(TriFunction<A,B,C,GroupKeyA_>, TriFunction<A,B,C,GroupKeyB_>) ,public TriConstraintStream<GroupKeyA_,GroupKeyB_,Result_> groupBy(TriFunction<A,B,C,GroupKeyA_>, TriFunction<A,B,C,GroupKeyB_>, TriConstraintCollector<A,B,C,ResultContainer_,Result_>) ,public QuadConstraintStream<GroupKeyA_,GroupKeyB_,ResultC_,ResultD_> groupBy(TriFunction<A,B,C,GroupKeyA_>, TriFunction<A,B,C,GroupKeyB_>, TriConstraintCollector<A,B,C,ResultContainerC_,ResultC_>, TriConstraintCollector<A,B,C,ResultContainerD_,ResultD_>) ,public TriConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_> groupBy(TriFunction<A,B,C,GroupKeyA_>, TriFunction<A,B,C,GroupKeyB_>, TriFunction<A,B,C,GroupKeyC_>) ,public QuadConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_,ResultD_> groupBy(TriFunction<A,B,C,GroupKeyA_>, TriFunction<A,B,C,GroupKeyB_>, TriFunction<A,B,C,GroupKeyC_>, TriConstraintCollector<A,B,C,ResultContainerD_,ResultD_>) ,public QuadConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_,GroupKeyD_> groupBy(TriFunction<A,B,C,GroupKeyA_>, TriFunction<A,B,C,GroupKeyB_>, TriFunction<A,B,C,GroupKeyC_>, TriFunction<A,B,C,GroupKeyD_>) ,public final transient TriConstraintStream<A,B,C> ifExists(Class<D>, QuadJoiner<A,B,C,D>[]) ,public final transient TriConstraintStream<A,B,C> ifExistsIncludingNullVars(Class<D>, QuadJoiner<A,B,C,D>[]) ,public final transient TriConstraintStream<A,B,C> ifNotExists(Class<D>, QuadJoiner<A,B,C,D>[]) ,public final transient TriConstraintStream<A,B,C> ifNotExistsIncludingNullVars(Class<D>, QuadJoiner<A,B,C,D>[]) ,public TriConstraintBuilder<A,B,C,Score_> innerImpact(Score_, ToIntTriFunction<A,B,C>, org.optaplanner.constraint.streams.common.ScoreImpactType) ,public TriConstraintBuilder<A,B,C,Score_> innerImpact(Score_, ToLongTriFunction<A,B,C>, org.optaplanner.constraint.streams.common.ScoreImpactType) ,public TriConstraintBuilder<A,B,C,Score_> innerImpact(Score_, TriFunction<A,B,C,java.math.BigDecimal>, org.optaplanner.constraint.streams.common.ScoreImpactType) ,public final transient QuadConstraintStream<A,B,C,D> join(UniConstraintStream<D>, QuadJoiner<A,B,C,D>[]) ,public UniConstraintStream<ResultA_> map(TriFunction<A,B,C,ResultA_>) <variables>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-constraint-streams-drools/src/main/java/org/optaplanner/constraint/streams/drools/tri/DroolsFlatteningTriConstraintStream.java
DroolsFlatteningTriConstraintStream
guaranteesDistinct
class DroolsFlatteningTriConstraintStream<Solution_, A, B, NewC> extends DroolsAbstractTriConstraintStream<Solution_, A, B, NewC> { private final Supplier<TriLeftHandSide<A, B, NewC>> leftHandSide; public <C> DroolsFlatteningTriConstraintStream(DroolsConstraintFactory<Solution_> constraintFactory, DroolsAbstractTriConstraintStream<Solution_, A, B, C> parent, Function<C, Iterable<NewC>> triMapping) { super(constraintFactory, parent.getRetrievalSemantics()); this.leftHandSide = () -> parent.createLeftHandSide().andFlattenLast(triMapping); } @Override public boolean guaranteesDistinct() {<FILL_FUNCTION_BODY>} // ************************************************************************ // Pattern creation // ************************************************************************ @Override public TriLeftHandSide<A, B, NewC> createLeftHandSide() { return leftHandSide.get(); } @Override public String toString() { return "TriFlatten() with " + getChildStreams().size() + " children"; } }
return false; // flattening can never guarantee distinct tuples, as we do not see inside the Iterable.
308
30
338
<methods>public void <init>(DroolsConstraintFactory<Solution_>, org.optaplanner.constraint.streams.common.RetrievalSemantics) ,public TriConstraintStream<A,B,NewC> filter(TriPredicate<A,B,NewC>) ,public TriConstraintStream<A,B,ResultC_> flattenLast(Function<NewC,Iterable<ResultC_>>) ,public UniConstraintStream<Result_> groupBy(TriConstraintCollector<A,B,NewC,ResultContainer_,Result_>) ,public BiConstraintStream<ResultA_,ResultB_> groupBy(TriConstraintCollector<A,B,NewC,ResultContainerA_,ResultA_>, TriConstraintCollector<A,B,NewC,ResultContainerB_,ResultB_>) ,public TriConstraintStream<ResultA_,ResultB_,ResultC_> groupBy(TriConstraintCollector<A,B,NewC,ResultContainerA_,ResultA_>, TriConstraintCollector<A,B,NewC,ResultContainerB_,ResultB_>, TriConstraintCollector<A,B,NewC,ResultContainerC_,ResultC_>) ,public QuadConstraintStream<ResultA_,ResultB_,ResultC_,ResultD_> groupBy(TriConstraintCollector<A,B,NewC,ResultContainerA_,ResultA_>, TriConstraintCollector<A,B,NewC,ResultContainerB_,ResultB_>, TriConstraintCollector<A,B,NewC,ResultContainerC_,ResultC_>, TriConstraintCollector<A,B,NewC,ResultContainerD_,ResultD_>) ,public UniConstraintStream<GroupKey_> groupBy(TriFunction<A,B,NewC,GroupKey_>) ,public BiConstraintStream<GroupKey_,Result_> groupBy(TriFunction<A,B,NewC,GroupKey_>, TriConstraintCollector<A,B,NewC,ResultContainer_,Result_>) ,public TriConstraintStream<GroupKey_,ResultB_,ResultC_> groupBy(TriFunction<A,B,NewC,GroupKey_>, TriConstraintCollector<A,B,NewC,ResultContainerB_,ResultB_>, TriConstraintCollector<A,B,NewC,ResultContainerC_,ResultC_>) ,public QuadConstraintStream<GroupKey_,ResultB_,ResultC_,ResultD_> groupBy(TriFunction<A,B,NewC,GroupKey_>, TriConstraintCollector<A,B,NewC,ResultContainerB_,ResultB_>, TriConstraintCollector<A,B,NewC,ResultContainerC_,ResultC_>, TriConstraintCollector<A,B,NewC,ResultContainerD_,ResultD_>) ,public BiConstraintStream<GroupKeyA_,GroupKeyB_> groupBy(TriFunction<A,B,NewC,GroupKeyA_>, TriFunction<A,B,NewC,GroupKeyB_>) ,public TriConstraintStream<GroupKeyA_,GroupKeyB_,Result_> groupBy(TriFunction<A,B,NewC,GroupKeyA_>, TriFunction<A,B,NewC,GroupKeyB_>, TriConstraintCollector<A,B,NewC,ResultContainer_,Result_>) ,public QuadConstraintStream<GroupKeyA_,GroupKeyB_,ResultC_,ResultD_> groupBy(TriFunction<A,B,NewC,GroupKeyA_>, TriFunction<A,B,NewC,GroupKeyB_>, TriConstraintCollector<A,B,NewC,ResultContainerC_,ResultC_>, TriConstraintCollector<A,B,NewC,ResultContainerD_,ResultD_>) ,public TriConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_> groupBy(TriFunction<A,B,NewC,GroupKeyA_>, TriFunction<A,B,NewC,GroupKeyB_>, TriFunction<A,B,NewC,GroupKeyC_>) ,public QuadConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_,ResultD_> groupBy(TriFunction<A,B,NewC,GroupKeyA_>, TriFunction<A,B,NewC,GroupKeyB_>, TriFunction<A,B,NewC,GroupKeyC_>, TriConstraintCollector<A,B,NewC,ResultContainerD_,ResultD_>) ,public QuadConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_,GroupKeyD_> groupBy(TriFunction<A,B,NewC,GroupKeyA_>, TriFunction<A,B,NewC,GroupKeyB_>, TriFunction<A,B,NewC,GroupKeyC_>, TriFunction<A,B,NewC,GroupKeyD_>) ,public final transient TriConstraintStream<A,B,NewC> ifExists(Class<D>, QuadJoiner<A,B,NewC,D>[]) ,public final transient TriConstraintStream<A,B,NewC> ifExistsIncludingNullVars(Class<D>, QuadJoiner<A,B,NewC,D>[]) ,public final transient TriConstraintStream<A,B,NewC> ifNotExists(Class<D>, QuadJoiner<A,B,NewC,D>[]) ,public final transient TriConstraintStream<A,B,NewC> ifNotExistsIncludingNullVars(Class<D>, QuadJoiner<A,B,NewC,D>[]) ,public TriConstraintBuilder<A,B,NewC,Score_> innerImpact(Score_, ToIntTriFunction<A,B,NewC>, org.optaplanner.constraint.streams.common.ScoreImpactType) ,public TriConstraintBuilder<A,B,NewC,Score_> innerImpact(Score_, ToLongTriFunction<A,B,NewC>, org.optaplanner.constraint.streams.common.ScoreImpactType) ,public TriConstraintBuilder<A,B,NewC,Score_> innerImpact(Score_, TriFunction<A,B,NewC,java.math.BigDecimal>, org.optaplanner.constraint.streams.common.ScoreImpactType) ,public final transient QuadConstraintStream<A,B,NewC,D> join(UniConstraintStream<D>, QuadJoiner<A,B,NewC,D>[]) ,public UniConstraintStream<ResultA_> map(TriFunction<A,B,NewC,ResultA_>) <variables>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-constraint-streams-drools/src/main/java/org/optaplanner/constraint/streams/drools/tri/DroolsJoinTriConstraintStream.java
DroolsJoinTriConstraintStream
toString
class DroolsJoinTriConstraintStream<Solution_, A, B, C> extends DroolsAbstractTriConstraintStream<Solution_, A, B, C> { private final Supplier<TriLeftHandSide<A, B, C>> leftHandSide; private final boolean guaranteesDistinct; public DroolsJoinTriConstraintStream(DroolsConstraintFactory<Solution_> constraintFactory, DroolsAbstractBiConstraintStream<Solution_, A, B> parent, DroolsAbstractUniConstraintStream<Solution_, C> otherStream, TriJoiner<A, B, C> joiner) { super(constraintFactory, parent.getRetrievalSemantics()); this.leftHandSide = () -> parent.createLeftHandSide().andJoin(otherStream.createLeftHandSide(), joiner); this.guaranteesDistinct = parent.guaranteesDistinct() && otherStream.guaranteesDistinct(); } @Override public boolean guaranteesDistinct() { return guaranteesDistinct; } // ************************************************************************ // Pattern creation // ************************************************************************ @Override public TriLeftHandSide<A, B, C> createLeftHandSide() { return leftHandSide.get(); } // ************************************************************************ // Getters/setters // ************************************************************************ @Override public String toString() {<FILL_FUNCTION_BODY>} }
return "TriJoin() with " + getChildStreams().size() + " children";
361
24
385
<methods>public void <init>(DroolsConstraintFactory<Solution_>, org.optaplanner.constraint.streams.common.RetrievalSemantics) ,public TriConstraintStream<A,B,C> filter(TriPredicate<A,B,C>) ,public TriConstraintStream<A,B,ResultC_> flattenLast(Function<C,Iterable<ResultC_>>) ,public UniConstraintStream<Result_> groupBy(TriConstraintCollector<A,B,C,ResultContainer_,Result_>) ,public BiConstraintStream<ResultA_,ResultB_> groupBy(TriConstraintCollector<A,B,C,ResultContainerA_,ResultA_>, TriConstraintCollector<A,B,C,ResultContainerB_,ResultB_>) ,public TriConstraintStream<ResultA_,ResultB_,ResultC_> groupBy(TriConstraintCollector<A,B,C,ResultContainerA_,ResultA_>, TriConstraintCollector<A,B,C,ResultContainerB_,ResultB_>, TriConstraintCollector<A,B,C,ResultContainerC_,ResultC_>) ,public QuadConstraintStream<ResultA_,ResultB_,ResultC_,ResultD_> groupBy(TriConstraintCollector<A,B,C,ResultContainerA_,ResultA_>, TriConstraintCollector<A,B,C,ResultContainerB_,ResultB_>, TriConstraintCollector<A,B,C,ResultContainerC_,ResultC_>, TriConstraintCollector<A,B,C,ResultContainerD_,ResultD_>) ,public UniConstraintStream<GroupKey_> groupBy(TriFunction<A,B,C,GroupKey_>) ,public BiConstraintStream<GroupKey_,Result_> groupBy(TriFunction<A,B,C,GroupKey_>, TriConstraintCollector<A,B,C,ResultContainer_,Result_>) ,public TriConstraintStream<GroupKey_,ResultB_,ResultC_> groupBy(TriFunction<A,B,C,GroupKey_>, TriConstraintCollector<A,B,C,ResultContainerB_,ResultB_>, TriConstraintCollector<A,B,C,ResultContainerC_,ResultC_>) ,public QuadConstraintStream<GroupKey_,ResultB_,ResultC_,ResultD_> groupBy(TriFunction<A,B,C,GroupKey_>, TriConstraintCollector<A,B,C,ResultContainerB_,ResultB_>, TriConstraintCollector<A,B,C,ResultContainerC_,ResultC_>, TriConstraintCollector<A,B,C,ResultContainerD_,ResultD_>) ,public BiConstraintStream<GroupKeyA_,GroupKeyB_> groupBy(TriFunction<A,B,C,GroupKeyA_>, TriFunction<A,B,C,GroupKeyB_>) ,public TriConstraintStream<GroupKeyA_,GroupKeyB_,Result_> groupBy(TriFunction<A,B,C,GroupKeyA_>, TriFunction<A,B,C,GroupKeyB_>, TriConstraintCollector<A,B,C,ResultContainer_,Result_>) ,public QuadConstraintStream<GroupKeyA_,GroupKeyB_,ResultC_,ResultD_> groupBy(TriFunction<A,B,C,GroupKeyA_>, TriFunction<A,B,C,GroupKeyB_>, TriConstraintCollector<A,B,C,ResultContainerC_,ResultC_>, TriConstraintCollector<A,B,C,ResultContainerD_,ResultD_>) ,public TriConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_> groupBy(TriFunction<A,B,C,GroupKeyA_>, TriFunction<A,B,C,GroupKeyB_>, TriFunction<A,B,C,GroupKeyC_>) ,public QuadConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_,ResultD_> groupBy(TriFunction<A,B,C,GroupKeyA_>, TriFunction<A,B,C,GroupKeyB_>, TriFunction<A,B,C,GroupKeyC_>, TriConstraintCollector<A,B,C,ResultContainerD_,ResultD_>) ,public QuadConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_,GroupKeyD_> groupBy(TriFunction<A,B,C,GroupKeyA_>, TriFunction<A,B,C,GroupKeyB_>, TriFunction<A,B,C,GroupKeyC_>, TriFunction<A,B,C,GroupKeyD_>) ,public final transient TriConstraintStream<A,B,C> ifExists(Class<D>, QuadJoiner<A,B,C,D>[]) ,public final transient TriConstraintStream<A,B,C> ifExistsIncludingNullVars(Class<D>, QuadJoiner<A,B,C,D>[]) ,public final transient TriConstraintStream<A,B,C> ifNotExists(Class<D>, QuadJoiner<A,B,C,D>[]) ,public final transient TriConstraintStream<A,B,C> ifNotExistsIncludingNullVars(Class<D>, QuadJoiner<A,B,C,D>[]) ,public TriConstraintBuilder<A,B,C,Score_> innerImpact(Score_, ToIntTriFunction<A,B,C>, org.optaplanner.constraint.streams.common.ScoreImpactType) ,public TriConstraintBuilder<A,B,C,Score_> innerImpact(Score_, ToLongTriFunction<A,B,C>, org.optaplanner.constraint.streams.common.ScoreImpactType) ,public TriConstraintBuilder<A,B,C,Score_> innerImpact(Score_, TriFunction<A,B,C,java.math.BigDecimal>, org.optaplanner.constraint.streams.common.ScoreImpactType) ,public final transient QuadConstraintStream<A,B,C,D> join(UniConstraintStream<D>, QuadJoiner<A,B,C,D>[]) ,public UniConstraintStream<ResultA_> map(TriFunction<A,B,C,ResultA_>) <variables>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-constraint-streams-drools/src/main/java/org/optaplanner/constraint/streams/drools/uni/DroolsExistsUniConstraintStream.java
DroolsExistsUniConstraintStream
toString
class DroolsExistsUniConstraintStream<Solution_, A> extends DroolsAbstractUniConstraintStream<Solution_, A> { private final DroolsAbstractUniConstraintStream<Solution_, A> parent; private final Supplier<UniLeftHandSide<A>> leftHandSide; private final String streamName; public <B> DroolsExistsUniConstraintStream(DroolsConstraintFactory<Solution_> constraintFactory, DroolsAbstractUniConstraintStream<Solution_, A> parent, boolean shouldExist, boolean shouldIncludeNullVars, Class<B> otherClass, BiJoiner<A, B>... joiners) { super(constraintFactory, parent.getRetrievalSemantics()); this.parent = parent; Predicate<B> nullityFilter = shouldIncludeNullVars ? null : constraintFactory.getNullityFilter(otherClass); this.leftHandSide = () -> shouldExist ? parent.createLeftHandSide().andExists(otherClass, joiners, nullityFilter) : parent.createLeftHandSide().andNotExists(otherClass, joiners, nullityFilter); this.streamName = shouldExist ? "IfExists()" : "IfNotExists()"; } @Override public boolean guaranteesDistinct() { return parent.guaranteesDistinct(); } // ************************************************************************ // Pattern creation // ************************************************************************ @Override public UniLeftHandSide<A> createLeftHandSide() { return leftHandSide.get(); } @Override public String toString() {<FILL_FUNCTION_BODY>} }
return streamName + " with " + getChildStreams().size() + " children";
413
24
437
<methods>public void <init>(DroolsConstraintFactory<Solution_>, org.optaplanner.constraint.streams.common.RetrievalSemantics) ,public UniConstraintStream<A> filter(Predicate<A>) ,public UniConstraintStream<ResultA_> flattenLast(Function<A,Iterable<ResultA_>>) ,public UniConstraintStream<Result_> groupBy(UniConstraintCollector<A,ResultContainer_,Result_>) ,public BiConstraintStream<ResultA_,ResultB_> groupBy(UniConstraintCollector<A,ResultContainerA_,ResultA_>, UniConstraintCollector<A,ResultContainerB_,ResultB_>) ,public TriConstraintStream<ResultA_,ResultB_,ResultC_> groupBy(UniConstraintCollector<A,ResultContainerA_,ResultA_>, UniConstraintCollector<A,ResultContainerB_,ResultB_>, UniConstraintCollector<A,ResultContainerC_,ResultC_>) ,public QuadConstraintStream<ResultA_,ResultB_,ResultC_,ResultD_> groupBy(UniConstraintCollector<A,ResultContainerA_,ResultA_>, UniConstraintCollector<A,ResultContainerB_,ResultB_>, UniConstraintCollector<A,ResultContainerC_,ResultC_>, UniConstraintCollector<A,ResultContainerD_,ResultD_>) ,public UniConstraintStream<GroupKey_> groupBy(Function<A,GroupKey_>) ,public BiConstraintStream<GroupKey_,Result_> groupBy(Function<A,GroupKey_>, UniConstraintCollector<A,ResultContainer_,Result_>) ,public TriConstraintStream<GroupKey_,ResultB_,ResultC_> groupBy(Function<A,GroupKey_>, UniConstraintCollector<A,ResultContainerB_,ResultB_>, UniConstraintCollector<A,ResultContainerC_,ResultC_>) ,public QuadConstraintStream<GroupKey_,ResultB_,ResultC_,ResultD_> groupBy(Function<A,GroupKey_>, UniConstraintCollector<A,ResultContainerB_,ResultB_>, UniConstraintCollector<A,ResultContainerC_,ResultC_>, UniConstraintCollector<A,ResultContainerD_,ResultD_>) ,public BiConstraintStream<GroupKeyA_,GroupKeyB_> groupBy(Function<A,GroupKeyA_>, Function<A,GroupKeyB_>) ,public TriConstraintStream<GroupKeyA_,GroupKeyB_,Result_> groupBy(Function<A,GroupKeyA_>, Function<A,GroupKeyB_>, UniConstraintCollector<A,ResultContainer_,Result_>) ,public QuadConstraintStream<GroupKeyA_,GroupKeyB_,ResultC_,ResultD_> groupBy(Function<A,GroupKeyA_>, Function<A,GroupKeyB_>, UniConstraintCollector<A,ResultContainerC_,ResultC_>, UniConstraintCollector<A,ResultContainerD_,ResultD_>) ,public TriConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_> groupBy(Function<A,GroupKeyA_>, Function<A,GroupKeyB_>, Function<A,GroupKeyC_>) ,public QuadConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_,ResultD_> groupBy(Function<A,GroupKeyA_>, Function<A,GroupKeyB_>, Function<A,GroupKeyC_>, UniConstraintCollector<A,ResultContainerD_,ResultD_>) ,public QuadConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_,GroupKeyD_> groupBy(Function<A,GroupKeyA_>, Function<A,GroupKeyB_>, Function<A,GroupKeyC_>, Function<A,GroupKeyD_>) ,public final transient UniConstraintStream<A> ifExists(Class<B>, BiJoiner<A,B>[]) ,public final transient UniConstraintStream<A> ifExistsIncludingNullVars(Class<B>, BiJoiner<A,B>[]) ,public final transient UniConstraintStream<A> ifNotExists(Class<B>, BiJoiner<A,B>[]) ,public final transient UniConstraintStream<A> ifNotExistsIncludingNullVars(Class<B>, BiJoiner<A,B>[]) ,public UniConstraintBuilder<A,Score_> innerImpact(Score_, ToIntFunction<A>, org.optaplanner.constraint.streams.common.ScoreImpactType) ,public UniConstraintBuilder<A,Score_> innerImpact(Score_, ToLongFunction<A>, org.optaplanner.constraint.streams.common.ScoreImpactType) ,public UniConstraintBuilder<A,Score_> innerImpact(Score_, Function<A,java.math.BigDecimal>, org.optaplanner.constraint.streams.common.ScoreImpactType) ,public final transient BiConstraintStream<A,B> join(UniConstraintStream<B>, BiJoiner<A,B>[]) ,public final BiConstraintStream<A,B> join(UniConstraintStream<B>, BiJoinerComber<A,B>) ,public UniConstraintStream<ResultA_> map(Function<A,ResultA_>) <variables>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-constraint-streams-drools/src/main/java/org/optaplanner/constraint/streams/drools/uni/DroolsFilterUniConstraintStream.java
DroolsFilterUniConstraintStream
toString
class DroolsFilterUniConstraintStream<Solution_, A> extends DroolsAbstractUniConstraintStream<Solution_, A> { private final DroolsAbstractUniConstraintStream<Solution_, A> parent; private final Supplier<UniLeftHandSide<A>> leftHandSide; public DroolsFilterUniConstraintStream(DroolsConstraintFactory<Solution_> constraintFactory, DroolsAbstractUniConstraintStream<Solution_, A> parent, Predicate<A> predicate) { super(constraintFactory, parent.getRetrievalSemantics()); this.parent = parent; this.leftHandSide = () -> parent.createLeftHandSide().andFilter(predicate); } @Override public boolean guaranteesDistinct() { return parent.guaranteesDistinct(); } // ************************************************************************ // Pattern creation // ************************************************************************ @Override public UniLeftHandSide<A> createLeftHandSide() { return leftHandSide.get(); } @Override public String toString() {<FILL_FUNCTION_BODY>} }
return "Filter() with " + getChildStreams().size() + " children";
286
23
309
<methods>public void <init>(DroolsConstraintFactory<Solution_>, org.optaplanner.constraint.streams.common.RetrievalSemantics) ,public UniConstraintStream<A> filter(Predicate<A>) ,public UniConstraintStream<ResultA_> flattenLast(Function<A,Iterable<ResultA_>>) ,public UniConstraintStream<Result_> groupBy(UniConstraintCollector<A,ResultContainer_,Result_>) ,public BiConstraintStream<ResultA_,ResultB_> groupBy(UniConstraintCollector<A,ResultContainerA_,ResultA_>, UniConstraintCollector<A,ResultContainerB_,ResultB_>) ,public TriConstraintStream<ResultA_,ResultB_,ResultC_> groupBy(UniConstraintCollector<A,ResultContainerA_,ResultA_>, UniConstraintCollector<A,ResultContainerB_,ResultB_>, UniConstraintCollector<A,ResultContainerC_,ResultC_>) ,public QuadConstraintStream<ResultA_,ResultB_,ResultC_,ResultD_> groupBy(UniConstraintCollector<A,ResultContainerA_,ResultA_>, UniConstraintCollector<A,ResultContainerB_,ResultB_>, UniConstraintCollector<A,ResultContainerC_,ResultC_>, UniConstraintCollector<A,ResultContainerD_,ResultD_>) ,public UniConstraintStream<GroupKey_> groupBy(Function<A,GroupKey_>) ,public BiConstraintStream<GroupKey_,Result_> groupBy(Function<A,GroupKey_>, UniConstraintCollector<A,ResultContainer_,Result_>) ,public TriConstraintStream<GroupKey_,ResultB_,ResultC_> groupBy(Function<A,GroupKey_>, UniConstraintCollector<A,ResultContainerB_,ResultB_>, UniConstraintCollector<A,ResultContainerC_,ResultC_>) ,public QuadConstraintStream<GroupKey_,ResultB_,ResultC_,ResultD_> groupBy(Function<A,GroupKey_>, UniConstraintCollector<A,ResultContainerB_,ResultB_>, UniConstraintCollector<A,ResultContainerC_,ResultC_>, UniConstraintCollector<A,ResultContainerD_,ResultD_>) ,public BiConstraintStream<GroupKeyA_,GroupKeyB_> groupBy(Function<A,GroupKeyA_>, Function<A,GroupKeyB_>) ,public TriConstraintStream<GroupKeyA_,GroupKeyB_,Result_> groupBy(Function<A,GroupKeyA_>, Function<A,GroupKeyB_>, UniConstraintCollector<A,ResultContainer_,Result_>) ,public QuadConstraintStream<GroupKeyA_,GroupKeyB_,ResultC_,ResultD_> groupBy(Function<A,GroupKeyA_>, Function<A,GroupKeyB_>, UniConstraintCollector<A,ResultContainerC_,ResultC_>, UniConstraintCollector<A,ResultContainerD_,ResultD_>) ,public TriConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_> groupBy(Function<A,GroupKeyA_>, Function<A,GroupKeyB_>, Function<A,GroupKeyC_>) ,public QuadConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_,ResultD_> groupBy(Function<A,GroupKeyA_>, Function<A,GroupKeyB_>, Function<A,GroupKeyC_>, UniConstraintCollector<A,ResultContainerD_,ResultD_>) ,public QuadConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_,GroupKeyD_> groupBy(Function<A,GroupKeyA_>, Function<A,GroupKeyB_>, Function<A,GroupKeyC_>, Function<A,GroupKeyD_>) ,public final transient UniConstraintStream<A> ifExists(Class<B>, BiJoiner<A,B>[]) ,public final transient UniConstraintStream<A> ifExistsIncludingNullVars(Class<B>, BiJoiner<A,B>[]) ,public final transient UniConstraintStream<A> ifNotExists(Class<B>, BiJoiner<A,B>[]) ,public final transient UniConstraintStream<A> ifNotExistsIncludingNullVars(Class<B>, BiJoiner<A,B>[]) ,public UniConstraintBuilder<A,Score_> innerImpact(Score_, ToIntFunction<A>, org.optaplanner.constraint.streams.common.ScoreImpactType) ,public UniConstraintBuilder<A,Score_> innerImpact(Score_, ToLongFunction<A>, org.optaplanner.constraint.streams.common.ScoreImpactType) ,public UniConstraintBuilder<A,Score_> innerImpact(Score_, Function<A,java.math.BigDecimal>, org.optaplanner.constraint.streams.common.ScoreImpactType) ,public final transient BiConstraintStream<A,B> join(UniConstraintStream<B>, BiJoiner<A,B>[]) ,public final BiConstraintStream<A,B> join(UniConstraintStream<B>, BiJoinerComber<A,B>) ,public UniConstraintStream<ResultA_> map(Function<A,ResultA_>) <variables>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-constraint-streams-drools/src/main/java/org/optaplanner/constraint/streams/drools/uni/DroolsFlatteningUniConstraintStream.java
DroolsFlatteningUniConstraintStream
guaranteesDistinct
class DroolsFlatteningUniConstraintStream<Solution_, NewA> extends DroolsAbstractUniConstraintStream<Solution_, NewA> { private final Supplier<UniLeftHandSide<NewA>> leftHandSide; public <A> DroolsFlatteningUniConstraintStream(DroolsConstraintFactory<Solution_> constraintFactory, DroolsAbstractUniConstraintStream<Solution_, A> parent, Function<A, Iterable<NewA>> mapping) { super(constraintFactory, parent.getRetrievalSemantics()); this.leftHandSide = () -> parent.createLeftHandSide().andFlattenLast(mapping); } @Override public boolean guaranteesDistinct() {<FILL_FUNCTION_BODY>} // ************************************************************************ // Pattern creation // ************************************************************************ @Override public UniLeftHandSide<NewA> createLeftHandSide() { return leftHandSide.get(); } @Override public String toString() { return "Flatten() with " + getChildStreams().size() + " children"; } }
return false; // flattening can never guarantee distinct tuples, as we do not see inside the Iterable.
291
30
321
<methods>public void <init>(DroolsConstraintFactory<Solution_>, org.optaplanner.constraint.streams.common.RetrievalSemantics) ,public UniConstraintStream<NewA> filter(Predicate<NewA>) ,public UniConstraintStream<ResultA_> flattenLast(Function<NewA,Iterable<ResultA_>>) ,public UniConstraintStream<Result_> groupBy(UniConstraintCollector<NewA,ResultContainer_,Result_>) ,public BiConstraintStream<ResultA_,ResultB_> groupBy(UniConstraintCollector<NewA,ResultContainerA_,ResultA_>, UniConstraintCollector<NewA,ResultContainerB_,ResultB_>) ,public TriConstraintStream<ResultA_,ResultB_,ResultC_> groupBy(UniConstraintCollector<NewA,ResultContainerA_,ResultA_>, UniConstraintCollector<NewA,ResultContainerB_,ResultB_>, UniConstraintCollector<NewA,ResultContainerC_,ResultC_>) ,public QuadConstraintStream<ResultA_,ResultB_,ResultC_,ResultD_> groupBy(UniConstraintCollector<NewA,ResultContainerA_,ResultA_>, UniConstraintCollector<NewA,ResultContainerB_,ResultB_>, UniConstraintCollector<NewA,ResultContainerC_,ResultC_>, UniConstraintCollector<NewA,ResultContainerD_,ResultD_>) ,public UniConstraintStream<GroupKey_> groupBy(Function<NewA,GroupKey_>) ,public BiConstraintStream<GroupKey_,Result_> groupBy(Function<NewA,GroupKey_>, UniConstraintCollector<NewA,ResultContainer_,Result_>) ,public TriConstraintStream<GroupKey_,ResultB_,ResultC_> groupBy(Function<NewA,GroupKey_>, UniConstraintCollector<NewA,ResultContainerB_,ResultB_>, UniConstraintCollector<NewA,ResultContainerC_,ResultC_>) ,public QuadConstraintStream<GroupKey_,ResultB_,ResultC_,ResultD_> groupBy(Function<NewA,GroupKey_>, UniConstraintCollector<NewA,ResultContainerB_,ResultB_>, UniConstraintCollector<NewA,ResultContainerC_,ResultC_>, UniConstraintCollector<NewA,ResultContainerD_,ResultD_>) ,public BiConstraintStream<GroupKeyA_,GroupKeyB_> groupBy(Function<NewA,GroupKeyA_>, Function<NewA,GroupKeyB_>) ,public TriConstraintStream<GroupKeyA_,GroupKeyB_,Result_> groupBy(Function<NewA,GroupKeyA_>, Function<NewA,GroupKeyB_>, UniConstraintCollector<NewA,ResultContainer_,Result_>) ,public QuadConstraintStream<GroupKeyA_,GroupKeyB_,ResultC_,ResultD_> groupBy(Function<NewA,GroupKeyA_>, Function<NewA,GroupKeyB_>, UniConstraintCollector<NewA,ResultContainerC_,ResultC_>, UniConstraintCollector<NewA,ResultContainerD_,ResultD_>) ,public TriConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_> groupBy(Function<NewA,GroupKeyA_>, Function<NewA,GroupKeyB_>, Function<NewA,GroupKeyC_>) ,public QuadConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_,ResultD_> groupBy(Function<NewA,GroupKeyA_>, Function<NewA,GroupKeyB_>, Function<NewA,GroupKeyC_>, UniConstraintCollector<NewA,ResultContainerD_,ResultD_>) ,public QuadConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_,GroupKeyD_> groupBy(Function<NewA,GroupKeyA_>, Function<NewA,GroupKeyB_>, Function<NewA,GroupKeyC_>, Function<NewA,GroupKeyD_>) ,public final transient UniConstraintStream<NewA> ifExists(Class<B>, BiJoiner<NewA,B>[]) ,public final transient UniConstraintStream<NewA> ifExistsIncludingNullVars(Class<B>, BiJoiner<NewA,B>[]) ,public final transient UniConstraintStream<NewA> ifNotExists(Class<B>, BiJoiner<NewA,B>[]) ,public final transient UniConstraintStream<NewA> ifNotExistsIncludingNullVars(Class<B>, BiJoiner<NewA,B>[]) ,public UniConstraintBuilder<NewA,Score_> innerImpact(Score_, ToIntFunction<NewA>, org.optaplanner.constraint.streams.common.ScoreImpactType) ,public UniConstraintBuilder<NewA,Score_> innerImpact(Score_, ToLongFunction<NewA>, org.optaplanner.constraint.streams.common.ScoreImpactType) ,public UniConstraintBuilder<NewA,Score_> innerImpact(Score_, Function<NewA,java.math.BigDecimal>, org.optaplanner.constraint.streams.common.ScoreImpactType) ,public final transient BiConstraintStream<NewA,B> join(UniConstraintStream<B>, BiJoiner<NewA,B>[]) ,public final BiConstraintStream<NewA,B> join(UniConstraintStream<B>, BiJoinerComber<NewA,B>) ,public UniConstraintStream<ResultA_> map(Function<NewA,ResultA_>) <variables>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-constraint-streams-drools/src/main/java/org/optaplanner/constraint/streams/drools/uni/DroolsFromUniConstraintStream.java
DroolsFromUniConstraintStream
toString
class DroolsFromUniConstraintStream<Solution_, A> extends DroolsAbstractUniConstraintStream<Solution_, A> { private final Class<A> fromClass; public DroolsFromUniConstraintStream(DroolsConstraintFactory<Solution_> constraintFactory, Class<A> fromClass, RetrievalSemantics retrievalSemantics) { super(constraintFactory, retrievalSemantics); this.fromClass = fromClass; } @Override public boolean guaranteesDistinct() { return true; } // ************************************************************************ // Pattern creation // ************************************************************************ @Override public UniLeftHandSide<A> createLeftHandSide() { return new UniLeftHandSide<>(fromClass, constraintFactory.getVariableFactory()); } // ************************************************************************ // Getters/setters // ************************************************************************ @Override public String toString() {<FILL_FUNCTION_BODY>} }
return "From(" + fromClass.getSimpleName() + ") with " + getChildStreams().size() + " children";
255
33
288
<methods>public void <init>(DroolsConstraintFactory<Solution_>, org.optaplanner.constraint.streams.common.RetrievalSemantics) ,public UniConstraintStream<A> filter(Predicate<A>) ,public UniConstraintStream<ResultA_> flattenLast(Function<A,Iterable<ResultA_>>) ,public UniConstraintStream<Result_> groupBy(UniConstraintCollector<A,ResultContainer_,Result_>) ,public BiConstraintStream<ResultA_,ResultB_> groupBy(UniConstraintCollector<A,ResultContainerA_,ResultA_>, UniConstraintCollector<A,ResultContainerB_,ResultB_>) ,public TriConstraintStream<ResultA_,ResultB_,ResultC_> groupBy(UniConstraintCollector<A,ResultContainerA_,ResultA_>, UniConstraintCollector<A,ResultContainerB_,ResultB_>, UniConstraintCollector<A,ResultContainerC_,ResultC_>) ,public QuadConstraintStream<ResultA_,ResultB_,ResultC_,ResultD_> groupBy(UniConstraintCollector<A,ResultContainerA_,ResultA_>, UniConstraintCollector<A,ResultContainerB_,ResultB_>, UniConstraintCollector<A,ResultContainerC_,ResultC_>, UniConstraintCollector<A,ResultContainerD_,ResultD_>) ,public UniConstraintStream<GroupKey_> groupBy(Function<A,GroupKey_>) ,public BiConstraintStream<GroupKey_,Result_> groupBy(Function<A,GroupKey_>, UniConstraintCollector<A,ResultContainer_,Result_>) ,public TriConstraintStream<GroupKey_,ResultB_,ResultC_> groupBy(Function<A,GroupKey_>, UniConstraintCollector<A,ResultContainerB_,ResultB_>, UniConstraintCollector<A,ResultContainerC_,ResultC_>) ,public QuadConstraintStream<GroupKey_,ResultB_,ResultC_,ResultD_> groupBy(Function<A,GroupKey_>, UniConstraintCollector<A,ResultContainerB_,ResultB_>, UniConstraintCollector<A,ResultContainerC_,ResultC_>, UniConstraintCollector<A,ResultContainerD_,ResultD_>) ,public BiConstraintStream<GroupKeyA_,GroupKeyB_> groupBy(Function<A,GroupKeyA_>, Function<A,GroupKeyB_>) ,public TriConstraintStream<GroupKeyA_,GroupKeyB_,Result_> groupBy(Function<A,GroupKeyA_>, Function<A,GroupKeyB_>, UniConstraintCollector<A,ResultContainer_,Result_>) ,public QuadConstraintStream<GroupKeyA_,GroupKeyB_,ResultC_,ResultD_> groupBy(Function<A,GroupKeyA_>, Function<A,GroupKeyB_>, UniConstraintCollector<A,ResultContainerC_,ResultC_>, UniConstraintCollector<A,ResultContainerD_,ResultD_>) ,public TriConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_> groupBy(Function<A,GroupKeyA_>, Function<A,GroupKeyB_>, Function<A,GroupKeyC_>) ,public QuadConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_,ResultD_> groupBy(Function<A,GroupKeyA_>, Function<A,GroupKeyB_>, Function<A,GroupKeyC_>, UniConstraintCollector<A,ResultContainerD_,ResultD_>) ,public QuadConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_,GroupKeyD_> groupBy(Function<A,GroupKeyA_>, Function<A,GroupKeyB_>, Function<A,GroupKeyC_>, Function<A,GroupKeyD_>) ,public final transient UniConstraintStream<A> ifExists(Class<B>, BiJoiner<A,B>[]) ,public final transient UniConstraintStream<A> ifExistsIncludingNullVars(Class<B>, BiJoiner<A,B>[]) ,public final transient UniConstraintStream<A> ifNotExists(Class<B>, BiJoiner<A,B>[]) ,public final transient UniConstraintStream<A> ifNotExistsIncludingNullVars(Class<B>, BiJoiner<A,B>[]) ,public UniConstraintBuilder<A,Score_> innerImpact(Score_, ToIntFunction<A>, org.optaplanner.constraint.streams.common.ScoreImpactType) ,public UniConstraintBuilder<A,Score_> innerImpact(Score_, ToLongFunction<A>, org.optaplanner.constraint.streams.common.ScoreImpactType) ,public UniConstraintBuilder<A,Score_> innerImpact(Score_, Function<A,java.math.BigDecimal>, org.optaplanner.constraint.streams.common.ScoreImpactType) ,public final transient BiConstraintStream<A,B> join(UniConstraintStream<B>, BiJoiner<A,B>[]) ,public final BiConstraintStream<A,B> join(UniConstraintStream<B>, BiJoinerComber<A,B>) ,public UniConstraintStream<ResultA_> map(Function<A,ResultA_>) <variables>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-constraint-streams-drools/src/main/java/org/optaplanner/constraint/streams/drools/uni/DroolsMappingUniConstraintStream.java
DroolsMappingUniConstraintStream
toString
class DroolsMappingUniConstraintStream<Solution_, NewA> extends DroolsAbstractUniConstraintStream<Solution_, NewA> { private final Supplier<UniLeftHandSide<NewA>> leftHandSide; public <A> DroolsMappingUniConstraintStream(DroolsConstraintFactory<Solution_> constraintFactory, DroolsAbstractUniConstraintStream<Solution_, A> parent, Function<A, NewA> mapping) { super(constraintFactory, parent.getRetrievalSemantics()); this.leftHandSide = () -> parent.createLeftHandSide().andMap(mapping); } public <A, B> DroolsMappingUniConstraintStream(DroolsConstraintFactory<Solution_> constraintFactory, DroolsAbstractBiConstraintStream<Solution_, A, B> parent, BiFunction<A, B, NewA> mapping) { super(constraintFactory, parent.getRetrievalSemantics()); this.leftHandSide = () -> parent.createLeftHandSide().andMap(mapping); } public <A, B, C> DroolsMappingUniConstraintStream(DroolsConstraintFactory<Solution_> constraintFactory, DroolsAbstractTriConstraintStream<Solution_, A, B, C> parent, TriFunction<A, B, C, NewA> mapping) { super(constraintFactory, parent.getRetrievalSemantics()); this.leftHandSide = () -> parent.createLeftHandSide().andMap(mapping); } public <A, B, C, D> DroolsMappingUniConstraintStream(DroolsConstraintFactory<Solution_> constraintFactory, DroolsAbstractQuadConstraintStream<Solution_, A, B, C, D> parent, QuadFunction<A, B, C, D, NewA> mapping) { super(constraintFactory, parent.getRetrievalSemantics()); this.leftHandSide = () -> parent.createLeftHandSide().andMap(mapping); } @Override public boolean guaranteesDistinct() { return false; // map() can never guarantee distinct tuples, as we do not see inside of the mapping function. } // ************************************************************************ // Pattern creation // ************************************************************************ @Override public UniLeftHandSide<NewA> createLeftHandSide() { return leftHandSide.get(); } @Override public String toString() {<FILL_FUNCTION_BODY>} }
return "Map() with " + getChildStreams().size() + " children";
619
23
642
<methods>public void <init>(DroolsConstraintFactory<Solution_>, org.optaplanner.constraint.streams.common.RetrievalSemantics) ,public UniConstraintStream<NewA> filter(Predicate<NewA>) ,public UniConstraintStream<ResultA_> flattenLast(Function<NewA,Iterable<ResultA_>>) ,public UniConstraintStream<Result_> groupBy(UniConstraintCollector<NewA,ResultContainer_,Result_>) ,public BiConstraintStream<ResultA_,ResultB_> groupBy(UniConstraintCollector<NewA,ResultContainerA_,ResultA_>, UniConstraintCollector<NewA,ResultContainerB_,ResultB_>) ,public TriConstraintStream<ResultA_,ResultB_,ResultC_> groupBy(UniConstraintCollector<NewA,ResultContainerA_,ResultA_>, UniConstraintCollector<NewA,ResultContainerB_,ResultB_>, UniConstraintCollector<NewA,ResultContainerC_,ResultC_>) ,public QuadConstraintStream<ResultA_,ResultB_,ResultC_,ResultD_> groupBy(UniConstraintCollector<NewA,ResultContainerA_,ResultA_>, UniConstraintCollector<NewA,ResultContainerB_,ResultB_>, UniConstraintCollector<NewA,ResultContainerC_,ResultC_>, UniConstraintCollector<NewA,ResultContainerD_,ResultD_>) ,public UniConstraintStream<GroupKey_> groupBy(Function<NewA,GroupKey_>) ,public BiConstraintStream<GroupKey_,Result_> groupBy(Function<NewA,GroupKey_>, UniConstraintCollector<NewA,ResultContainer_,Result_>) ,public TriConstraintStream<GroupKey_,ResultB_,ResultC_> groupBy(Function<NewA,GroupKey_>, UniConstraintCollector<NewA,ResultContainerB_,ResultB_>, UniConstraintCollector<NewA,ResultContainerC_,ResultC_>) ,public QuadConstraintStream<GroupKey_,ResultB_,ResultC_,ResultD_> groupBy(Function<NewA,GroupKey_>, UniConstraintCollector<NewA,ResultContainerB_,ResultB_>, UniConstraintCollector<NewA,ResultContainerC_,ResultC_>, UniConstraintCollector<NewA,ResultContainerD_,ResultD_>) ,public BiConstraintStream<GroupKeyA_,GroupKeyB_> groupBy(Function<NewA,GroupKeyA_>, Function<NewA,GroupKeyB_>) ,public TriConstraintStream<GroupKeyA_,GroupKeyB_,Result_> groupBy(Function<NewA,GroupKeyA_>, Function<NewA,GroupKeyB_>, UniConstraintCollector<NewA,ResultContainer_,Result_>) ,public QuadConstraintStream<GroupKeyA_,GroupKeyB_,ResultC_,ResultD_> groupBy(Function<NewA,GroupKeyA_>, Function<NewA,GroupKeyB_>, UniConstraintCollector<NewA,ResultContainerC_,ResultC_>, UniConstraintCollector<NewA,ResultContainerD_,ResultD_>) ,public TriConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_> groupBy(Function<NewA,GroupKeyA_>, Function<NewA,GroupKeyB_>, Function<NewA,GroupKeyC_>) ,public QuadConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_,ResultD_> groupBy(Function<NewA,GroupKeyA_>, Function<NewA,GroupKeyB_>, Function<NewA,GroupKeyC_>, UniConstraintCollector<NewA,ResultContainerD_,ResultD_>) ,public QuadConstraintStream<GroupKeyA_,GroupKeyB_,GroupKeyC_,GroupKeyD_> groupBy(Function<NewA,GroupKeyA_>, Function<NewA,GroupKeyB_>, Function<NewA,GroupKeyC_>, Function<NewA,GroupKeyD_>) ,public final transient UniConstraintStream<NewA> ifExists(Class<B>, BiJoiner<NewA,B>[]) ,public final transient UniConstraintStream<NewA> ifExistsIncludingNullVars(Class<B>, BiJoiner<NewA,B>[]) ,public final transient UniConstraintStream<NewA> ifNotExists(Class<B>, BiJoiner<NewA,B>[]) ,public final transient UniConstraintStream<NewA> ifNotExistsIncludingNullVars(Class<B>, BiJoiner<NewA,B>[]) ,public UniConstraintBuilder<NewA,Score_> innerImpact(Score_, ToIntFunction<NewA>, org.optaplanner.constraint.streams.common.ScoreImpactType) ,public UniConstraintBuilder<NewA,Score_> innerImpact(Score_, ToLongFunction<NewA>, org.optaplanner.constraint.streams.common.ScoreImpactType) ,public UniConstraintBuilder<NewA,Score_> innerImpact(Score_, Function<NewA,java.math.BigDecimal>, org.optaplanner.constraint.streams.common.ScoreImpactType) ,public final transient BiConstraintStream<NewA,B> join(UniConstraintStream<B>, BiJoiner<NewA,B>[]) ,public final BiConstraintStream<NewA,B> join(UniConstraintStream<B>, BiJoinerComber<NewA,B>) ,public UniConstraintStream<ResultA_> map(Function<NewA,ResultA_>) <variables>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/api/score/buildin/hardsoft/HardSoftScore.java
HardSoftScore
parseScore
class HardSoftScore implements Score<HardSoftScore> { public static final HardSoftScore ZERO = new HardSoftScore(0, 0, 0); public static final HardSoftScore ONE_HARD = new HardSoftScore(0, 1, 0); public static final HardSoftScore ONE_SOFT = new HardSoftScore(0, 0, 1); public static HardSoftScore parseScore(String scoreString) {<FILL_FUNCTION_BODY>} public static HardSoftScore ofUninitialized(int initScore, int hardScore, int softScore) { return new HardSoftScore(initScore, hardScore, softScore); } public static HardSoftScore of(int hardScore, int softScore) { return new HardSoftScore(0, hardScore, softScore); } public static HardSoftScore ofHard(int hardScore) { return of(hardScore, 0); } public static HardSoftScore ofSoft(int softScore) { return of(0, softScore); } // ************************************************************************ // Fields // ************************************************************************ private final int initScore; private final int hardScore; private final int softScore; /** * Private default constructor for default marshalling/unmarshalling of unknown frameworks that use reflection. * Such integration is always inferior to the specialized integration modules, such as * optaplanner-persistence-jpa, optaplanner-persistence-jackson, optaplanner-persistence-jaxb, ... */ @SuppressWarnings("unused") private HardSoftScore() { this(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE); } private HardSoftScore(int initScore, int hardScore, int softScore) { this.initScore = initScore; this.hardScore = hardScore; this.softScore = softScore; } @Override public int initScore() { return initScore; } /** * The total of the broken negative hard constraints and fulfilled positive hard constraints. * Their weight is included in the total. * The hard score is usually a negative number because most use cases only have negative constraints. * * @return higher is better, usually negative, 0 if no hard constraints are broken/fulfilled */ public int hardScore() { return hardScore; } /** * As defined by {@link #hardScore()}. * * @deprecated Use {@link #hardScore()} instead. */ @Deprecated(forRemoval = true) public int getHardScore() { return hardScore; } /** * The total of the broken negative soft constraints and fulfilled positive soft constraints. * Their weight is included in the total. * The soft score is usually a negative number because most use cases only have negative constraints. * <p> * In a normal score comparison, the soft score is irrelevant if the 2 scores don't have the same hard score. * * @return higher is better, usually negative, 0 if no soft constraints are broken/fulfilled */ public int softScore() { return softScore; } /** * As defined by {@link #softScore()}. * * @deprecated Use {@link #softScore()} instead. */ @Deprecated(forRemoval = true) public int getSoftScore() { return softScore; } // ************************************************************************ // Worker methods // ************************************************************************ @Override public HardSoftScore withInitScore(int newInitScore) { return new HardSoftScore(newInitScore, hardScore, softScore); } @Override public boolean isFeasible() { return initScore >= 0 && hardScore >= 0; } @Override public HardSoftScore add(HardSoftScore addend) { return new HardSoftScore( initScore + addend.initScore(), hardScore + addend.hardScore(), softScore + addend.softScore()); } @Override public HardSoftScore subtract(HardSoftScore subtrahend) { return new HardSoftScore( initScore - subtrahend.initScore(), hardScore - subtrahend.hardScore(), softScore - subtrahend.softScore()); } @Override public HardSoftScore multiply(double multiplicand) { return new HardSoftScore( (int) Math.floor(initScore * multiplicand), (int) Math.floor(hardScore * multiplicand), (int) Math.floor(softScore * multiplicand)); } @Override public HardSoftScore divide(double divisor) { return new HardSoftScore( (int) Math.floor(initScore / divisor), (int) Math.floor(hardScore / divisor), (int) Math.floor(softScore / divisor)); } @Override public HardSoftScore power(double exponent) { return new HardSoftScore( (int) Math.floor(Math.pow(initScore, exponent)), (int) Math.floor(Math.pow(hardScore, exponent)), (int) Math.floor(Math.pow(softScore, exponent))); } @Override public HardSoftScore abs() { return new HardSoftScore(Math.abs(initScore), Math.abs(hardScore), Math.abs(softScore)); } @Override public HardSoftScore zero() { return HardSoftScore.ZERO; } @Override public Number[] toLevelNumbers() { return new Number[] { hardScore, softScore }; } @Override public boolean equals(Object o) { if (this == o) { return true; } else if (o instanceof HardSoftScore) { HardSoftScore other = (HardSoftScore) o; return initScore == other.initScore() && hardScore == other.hardScore() && softScore == other.softScore(); } else { return false; } } @Override public int hashCode() { return Objects.hash(initScore, hardScore, softScore); } @Override public int compareTo(HardSoftScore other) { if (initScore != other.initScore()) { return Integer.compare(initScore, other.initScore()); } else if (hardScore != other.hardScore()) { return Integer.compare(hardScore, other.hardScore()); } else { return Integer.compare(softScore, other.softScore()); } } @Override public String toShortString() { return ScoreUtil.buildShortString(this, n -> n.intValue() != 0, HARD_LABEL, SOFT_LABEL); } @Override public String toString() { return ScoreUtil.getInitPrefix(initScore) + hardScore + HARD_LABEL + "/" + softScore + SOFT_LABEL; } }
String[] scoreTokens = parseScoreTokens(HardSoftScore.class, scoreString, HARD_LABEL, SOFT_LABEL); int initScore = parseInitScore(HardSoftScore.class, scoreString, scoreTokens[0]); int hardScore = parseLevelAsInt(HardSoftScore.class, scoreString, scoreTokens[1]); int softScore = parseLevelAsInt(HardSoftScore.class, scoreString, scoreTokens[2]); return ofUninitialized(initScore, hardScore, softScore);
1,802
133
1,935
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/api/score/buildin/hardsoftlong/HardSoftLongScore.java
HardSoftLongScore
add
class HardSoftLongScore implements Score<HardSoftLongScore> { public static final HardSoftLongScore ZERO = new HardSoftLongScore(0, 0L, 0L); public static final HardSoftLongScore ONE_HARD = new HardSoftLongScore(0, 1L, 0L); public static final HardSoftLongScore ONE_SOFT = new HardSoftLongScore(0, 0L, 1L); public static HardSoftLongScore parseScore(String scoreString) { String[] scoreTokens = ScoreUtil.parseScoreTokens(HardSoftLongScore.class, scoreString, HARD_LABEL, SOFT_LABEL); int initScore = ScoreUtil.parseInitScore(HardSoftLongScore.class, scoreString, scoreTokens[0]); long hardScore = ScoreUtil.parseLevelAsLong(HardSoftLongScore.class, scoreString, scoreTokens[1]); long softScore = ScoreUtil.parseLevelAsLong(HardSoftLongScore.class, scoreString, scoreTokens[2]); return ofUninitialized(initScore, hardScore, softScore); } public static HardSoftLongScore ofUninitialized(int initScore, long hardScore, long softScore) { return new HardSoftLongScore(initScore, hardScore, softScore); } public static HardSoftLongScore of(long hardScore, long softScore) { return new HardSoftLongScore(0, hardScore, softScore); } public static HardSoftLongScore ofHard(long hardScore) { return of(hardScore, 0L); } public static HardSoftLongScore ofSoft(long softScore) { return of(0L, softScore); } // ************************************************************************ // Fields // ************************************************************************ private final int initScore; private final long hardScore; private final long softScore; /** * Private default constructor for default marshalling/unmarshalling of unknown frameworks that use reflection. * Such integration is always inferior to the specialized integration modules, such as * optaplanner-persistence-jpa, optaplanner-persistence-jackson, optaplanner-persistence-jaxb, ... */ @SuppressWarnings("unused") private HardSoftLongScore() { this(Integer.MIN_VALUE, Long.MIN_VALUE, Long.MIN_VALUE); } private HardSoftLongScore(int initScore, long hardScore, long softScore) { this.initScore = initScore; this.hardScore = hardScore; this.softScore = softScore; } @Override public int initScore() { return initScore; } /** * The total of the broken negative hard constraints and fulfilled positive hard constraints. * Their weight is included in the total. * The hard score is usually a negative number because most use cases only have negative constraints. * * @return higher is better, usually negative, 0 if no hard constraints are broken/fulfilled */ public long hardScore() { return hardScore; } /** * As defined by {@link #hardScore()}. * * @deprecated Use {@link #hardScore()} instead. */ @Deprecated(forRemoval = true) public long getHardScore() { return hardScore; } /** * The total of the broken negative soft constraints and fulfilled positive soft constraints. * Their weight is included in the total. * The soft score is usually a negative number because most use cases only have negative constraints. * <p> * In a normal score comparison, the soft score is irrelevant if the 2 scores don't have the same hard score. * * @return higher is better, usually negative, 0 if no soft constraints are broken/fulfilled */ public long softScore() { return softScore; } /** * As defined by {@link #softScore()}. * * @deprecated Use {@link #softScore()} instead. */ @Deprecated(forRemoval = true) public long getSoftScore() { return softScore; } // ************************************************************************ // Worker methods // ************************************************************************ @Override public HardSoftLongScore withInitScore(int newInitScore) { return new HardSoftLongScore(newInitScore, hardScore, softScore); } @Override public boolean isFeasible() { return initScore >= 0 && hardScore >= 0L; } @Override public HardSoftLongScore add(HardSoftLongScore addend) {<FILL_FUNCTION_BODY>} @Override public HardSoftLongScore subtract(HardSoftLongScore subtrahend) { return new HardSoftLongScore( initScore - subtrahend.initScore(), hardScore - subtrahend.hardScore(), softScore - subtrahend.softScore()); } @Override public HardSoftLongScore multiply(double multiplicand) { return new HardSoftLongScore( (int) Math.floor(initScore * multiplicand), (long) Math.floor(hardScore * multiplicand), (long) Math.floor(softScore * multiplicand)); } @Override public HardSoftLongScore divide(double divisor) { return new HardSoftLongScore( (int) Math.floor(initScore / divisor), (long) Math.floor(hardScore / divisor), (long) Math.floor(softScore / divisor)); } @Override public HardSoftLongScore power(double exponent) { return new HardSoftLongScore( (int) Math.floor(Math.pow(initScore, exponent)), (long) Math.floor(Math.pow(hardScore, exponent)), (long) Math.floor(Math.pow(softScore, exponent))); } @Override public HardSoftLongScore abs() { return new HardSoftLongScore(Math.abs(initScore), Math.abs(hardScore), Math.abs(softScore)); } @Override public HardSoftLongScore zero() { return HardSoftLongScore.ZERO; } @Override public Number[] toLevelNumbers() { return new Number[] { hardScore, softScore }; } @Override public boolean equals(Object o) { if (this == o) { return true; } else if (o instanceof HardSoftLongScore) { HardSoftLongScore other = (HardSoftLongScore) o; return initScore == other.initScore() && hardScore == other.hardScore() && softScore == other.softScore(); } else { return false; } } @Override public int hashCode() { return Objects.hash(initScore, hardScore, softScore); } @Override public int compareTo(HardSoftLongScore other) { if (initScore != other.initScore()) { return Integer.compare(initScore, other.initScore()); } else if (hardScore != other.hardScore()) { return Long.compare(hardScore, other.hardScore()); } else { return Long.compare(softScore, other.softScore()); } } @Override public String toShortString() { return ScoreUtil.buildShortString(this, n -> n.longValue() != 0L, HARD_LABEL, SOFT_LABEL); } @Override public String toString() { return ScoreUtil.getInitPrefix(initScore) + hardScore + HARD_LABEL + "/" + softScore + SOFT_LABEL; } }
return new HardSoftLongScore( initScore + addend.initScore(), hardScore + addend.hardScore(), softScore + addend.softScore());
1,959
45
2,004
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/api/score/buildin/simple/SimpleScore.java
SimpleScore
parseScore
class SimpleScore implements Score<SimpleScore> { public static final SimpleScore ZERO = new SimpleScore(0, 0); public static final SimpleScore ONE = new SimpleScore(0, 1); public static SimpleScore parseScore(String scoreString) {<FILL_FUNCTION_BODY>} public static SimpleScore ofUninitialized(int initScore, int score) { return new SimpleScore(initScore, score); } public static SimpleScore of(int score) { return new SimpleScore(0, score); } // ************************************************************************ // Fields // ************************************************************************ private final int initScore; private final int score; /** * Private default constructor for default marshalling/unmarshalling of unknown frameworks that use reflection. * Such integration is always inferior to the specialized integration modules, such as * optaplanner-persistence-jpa, optaplanner-persistence-jackson, optaplanner-persistence-jaxb, ... */ @SuppressWarnings("unused") private SimpleScore() { this(Integer.MIN_VALUE, Integer.MIN_VALUE); } private SimpleScore(int initScore, int score) { this.initScore = initScore; this.score = score; } @Override public int initScore() { return initScore; } /** * The total of the broken negative constraints and fulfilled positive constraints. * Their weight is included in the total. * The score is usually a negative number because most use cases only have negative constraints. * * @return higher is better, usually negative, 0 if no constraints are broken/fulfilled */ public int score() { return score; } /** * As defined by {@link #score()}. * * @deprecated Use {@link #score()} instead. */ @Deprecated(forRemoval = true) public int getScore() { return score; } // ************************************************************************ // Worker methods // ************************************************************************ @Override public SimpleScore withInitScore(int newInitScore) { return new SimpleScore(newInitScore, score); } @Override public SimpleScore add(SimpleScore addend) { return new SimpleScore( initScore + addend.initScore(), score + addend.score()); } @Override public SimpleScore subtract(SimpleScore subtrahend) { return new SimpleScore( initScore - subtrahend.initScore(), score - subtrahend.score()); } @Override public SimpleScore multiply(double multiplicand) { return new SimpleScore( (int) Math.floor(initScore * multiplicand), (int) Math.floor(score * multiplicand)); } @Override public SimpleScore divide(double divisor) { return new SimpleScore( (int) Math.floor(initScore / divisor), (int) Math.floor(score / divisor)); } @Override public SimpleScore power(double exponent) { return new SimpleScore( (int) Math.floor(Math.pow(initScore, exponent)), (int) Math.floor(Math.pow(score, exponent))); } @Override public SimpleScore abs() { return new SimpleScore(Math.abs(initScore), Math.abs(score)); } @Override public SimpleScore zero() { return SimpleScore.ZERO; } @Override public boolean isFeasible() { return initScore >= 0; } @Override public Number[] toLevelNumbers() { return new Number[] { score }; } @Override public boolean equals(Object o) { if (this == o) { return true; } else if (o instanceof SimpleScore) { SimpleScore other = (SimpleScore) o; return initScore == other.initScore() && score == other.score(); } else { return false; } } @Override public int hashCode() { return Objects.hash(initScore, score); } @Override public int compareTo(SimpleScore other) { if (initScore != other.initScore()) { return Integer.compare(initScore, other.initScore()); } else { return Integer.compare(score, other.score()); } } @Override public String toShortString() { return ScoreUtil.buildShortString(this, n -> n.intValue() != 0, ""); } @Override public String toString() { return ScoreUtil.getInitPrefix(initScore) + score; } }
String[] scoreTokens = ScoreUtil.parseScoreTokens(SimpleScore.class, scoreString, ""); int initScore = ScoreUtil.parseInitScore(SimpleScore.class, scoreString, scoreTokens[0]); int score = ScoreUtil.parseLevelAsInt(SimpleScore.class, scoreString, scoreTokens[1]); return ofUninitialized(initScore, score);
1,229
99
1,328
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/api/score/buildin/simplelong/SimpleLongScore.java
SimpleLongScore
compareTo
class SimpleLongScore implements Score<SimpleLongScore> { public static final SimpleLongScore ZERO = new SimpleLongScore(0, 0L); public static final SimpleLongScore ONE = new SimpleLongScore(0, 1L); public static SimpleLongScore parseScore(String scoreString) { String[] scoreTokens = ScoreUtil.parseScoreTokens(SimpleLongScore.class, scoreString, ""); int initScore = ScoreUtil.parseInitScore(SimpleLongScore.class, scoreString, scoreTokens[0]); long score = ScoreUtil.parseLevelAsLong(SimpleLongScore.class, scoreString, scoreTokens[1]); return ofUninitialized(initScore, score); } public static SimpleLongScore ofUninitialized(int initScore, long score) { return new SimpleLongScore(initScore, score); } public static SimpleLongScore of(long score) { return new SimpleLongScore(0, score); } // ************************************************************************ // Fields // ************************************************************************ private final int initScore; private final long score; /** * Private default constructor for default marshalling/unmarshalling of unknown frameworks that use reflection. * Such integration is always inferior to the specialized integration modules, such as * optaplanner-persistence-jpa, optaplanner-persistence-jackson, optaplanner-persistence-jaxb, ... */ @SuppressWarnings("unused") private SimpleLongScore() { this(Integer.MIN_VALUE, Long.MIN_VALUE); } private SimpleLongScore(int initScore, long score) { this.initScore = initScore; this.score = score; } @Override public int initScore() { return initScore; } /** * The total of the broken negative constraints and fulfilled positive constraints. * Their weight is included in the total. * The score is usually a negative number because most use cases only have negative constraints. * * @return higher is better, usually negative, 0 if no constraints are broken/fulfilled */ public long score() { return score; } /** * As defined by {@link #score()}. * * @deprecated Use {@link #score()} instead. */ @Deprecated(forRemoval = true) public long getScore() { return score; } // ************************************************************************ // Worker methods // ************************************************************************ @Override public SimpleLongScore withInitScore(int newInitScore) { return new SimpleLongScore(newInitScore, score); } @Override public SimpleLongScore add(SimpleLongScore addend) { return new SimpleLongScore( initScore + addend.initScore(), score + addend.score()); } @Override public SimpleLongScore subtract(SimpleLongScore subtrahend) { return new SimpleLongScore( initScore - subtrahend.initScore(), score - subtrahend.score()); } @Override public SimpleLongScore multiply(double multiplicand) { return new SimpleLongScore( (int) Math.floor(initScore * multiplicand), (long) Math.floor(score * multiplicand)); } @Override public SimpleLongScore divide(double divisor) { return new SimpleLongScore( (int) Math.floor(initScore / divisor), (long) Math.floor(score / divisor)); } @Override public SimpleLongScore power(double exponent) { return new SimpleLongScore( (int) Math.floor(Math.pow(initScore, exponent)), (long) Math.floor(Math.pow(score, exponent))); } @Override public SimpleLongScore abs() { return new SimpleLongScore(Math.abs(initScore), Math.abs(score)); } @Override public SimpleLongScore zero() { return SimpleLongScore.ZERO; } @Override public boolean isFeasible() { return initScore >= 0; } @Override public Number[] toLevelNumbers() { return new Number[] { score }; } @Override public boolean equals(Object o) { if (this == o) { return true; } else if (o instanceof SimpleLongScore) { SimpleLongScore other = (SimpleLongScore) o; return initScore == other.initScore() && score == other.score(); } else { return false; } } @Override public int hashCode() { return Objects.hash(initScore, score); } @Override public int compareTo(SimpleLongScore other) {<FILL_FUNCTION_BODY>} @Override public String toShortString() { return ScoreUtil.buildShortString(this, n -> n.longValue() != 0L, ""); } @Override public String toString() { return ScoreUtil.getInitPrefix(initScore) + score; } }
if (initScore != other.initScore()) { return Integer.compare(initScore, other.initScore()); } else { return Long.compare(score, other.score()); }
1,316
53
1,369
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/api/score/constraint/ConstraintMatch.java
ConstraintMatch
compareTo
class ConstraintMatch<Score_ extends Score<Score_>> implements Comparable<ConstraintMatch<Score_>> { private final String constraintPackage; private final String constraintName; private final String constraintId; private final ConstraintJustification justification; private final List<Object> indictedObjects; private final Score_ score; /** * @deprecated Prefer {@link ConstraintMatch#ConstraintMatch(String, String, ConstraintJustification, Collection, Score)}. * @param constraintPackage never null * @param constraintName never null * @param justificationList never null, sometimes empty * @param score never null */ @Deprecated(forRemoval = true) public ConstraintMatch(String constraintPackage, String constraintName, List<Object> justificationList, Score_ score) { this(constraintPackage, constraintName, DefaultConstraintJustification.of(score, justificationList), justificationList, score); } /** * @param constraintPackage never null * @param constraintName never null * @param justification never null * @param score never null */ public ConstraintMatch(String constraintPackage, String constraintName, ConstraintJustification justification, Collection<Object> indictedObjects, Score_ score) { this.constraintPackage = requireNonNull(constraintPackage); this.constraintName = requireNonNull(constraintName); this.constraintId = ConstraintMatchTotal.composeConstraintId(constraintPackage, constraintName); this.justification = requireNonNull(justification); this.indictedObjects = requireNonNull(indictedObjects) instanceof List ? (List<Object>) indictedObjects : List.copyOf(indictedObjects); this.score = requireNonNull(score); } public String getConstraintPackage() { return constraintPackage; } public String getConstraintName() { return constraintName; } /** * Return a list of justifications for the constraint. * <p> * This method has a different meaning based on which score director the constraint comes from. * <ul> * <li>For Score DRL, it returns every object that Drools considers to be part of the match. * This is largely undefined.</li> * <li>For incremental score calculation, it returns what the calculator is implemented to return.</li> * <li>For constraint streams, it returns a list of facts from the matching tuple for backwards compatibility * (eg. [A, B] for a bi stream), * unless a custom justification mapping was provided, in which case it throws an exception, * pointing users towards {@link #getJustification()}.</li> * </ul> * * @deprecated Prefer {@link #getJustification()} or {@link #getIndictedObjectList()}. * @return never null */ @Deprecated(forRemoval = true) public List<Object> getJustificationList() { if (justification instanceof DefaultConstraintJustification) { // No custom function provided. return ((DefaultConstraintJustification) justification).getFacts(); } else { throw new IllegalStateException("Cannot retrieve list of facts from a custom constraint justification (" + justification + ").\n" + "Use ConstraintMatch#getJustification() method instead."); } } /** * Return a singular justification for the constraint. * <p> * This method has a different meaning based on which score director the constraint comes from. * <ul> * <li>For Score DRL, it returns {@link DefaultConstraintJustification} of all objects * that Drools considers to be part of the match. * This is largely undefined.</li> * <li>For incremental score calculation, it returns what the calculator is implemented to return.</li> * <li>For constraint streams, it returns {@link DefaultConstraintJustification} from the matching tuple * (eg. [A, B] for a bi stream), unless a custom justification mapping was provided, * in which case it returns the return value of that function.</li> * </ul> * * @return never null */ public <Justification_ extends ConstraintJustification> Justification_ getJustification() { return (Justification_) justification; } /** * Returns a set of objects indicted for causing this constraint match. * <p> * This method has a different meaning based on which score director the constraint comes from. * <ul> * <li>For Score DRL, it returns {@link DefaultConstraintJustification} of all objects * that Drools considers to be part of the match. * This is largely undefined.</li> * <li>For incremental score calculation, it returns what the calculator is implemented to return.</li> * <li>For constraint streams, it returns the facts from the matching tuple * (eg. [A, B] for a bi stream), unless a custom indictment mapping was provided, * in which case it returns the return value of that function.</li> * </ul> * * @return never null, may be empty */ public List<Object> getIndictedObjectList() { return indictedObjects; } public Score_ getScore() { return score; } // ************************************************************************ // Worker methods // ************************************************************************ public String getConstraintId() { return ConstraintMatchTotal.composeConstraintId(constraintPackage, constraintName); } public String getIdentificationString() { return getConstraintId() + "/" + justification; } @Override public int compareTo(ConstraintMatch<Score_> other) {<FILL_FUNCTION_BODY>} @Override public String toString() { return getIdentificationString() + "=" + score; } }
if (!constraintId.equals(other.constraintId)) { return constraintId.compareTo(other.constraintId); } else if (!score.equals(other.score)) { return score.compareTo(other.score); } else if (justification instanceof Comparable) { return ((Comparable) justification).compareTo(other.justification); } return Integer.compare(System.identityHashCode(justification), System.identityHashCode(other.justification));
1,485
124
1,609
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/api/score/stream/DefaultConstraintJustification.java
DefaultConstraintJustification
getClassAndIdPlanningComparator
class DefaultConstraintJustification implements ConstraintJustification, Comparable<DefaultConstraintJustification> { public static DefaultConstraintJustification of(Score<?> impact, Object fact) { return new DefaultConstraintJustification(impact, List.of(fact)); } public static DefaultConstraintJustification of(Score<?> impact, Object factA, Object factB) { return new DefaultConstraintJustification(impact, List.of(factA, factB)); } public static DefaultConstraintJustification of(Score<?> impact, Object factA, Object factB, Object factC) { return new DefaultConstraintJustification(impact, List.of(factA, factB, factC)); } public static DefaultConstraintJustification of(Score<?> impact, Object factA, Object factB, Object factC, Object factD) { return new DefaultConstraintJustification(impact, List.of(factA, factB, factC, factD)); } public static DefaultConstraintJustification of(Score<?> impact, Object... facts) { return new DefaultConstraintJustification(impact, List.of(facts)); } public static DefaultConstraintJustification of(Score<?> impact, List<Object> facts) { return new DefaultConstraintJustification(impact, facts); } private final Score<?> impact; private final List<Object> facts; private Comparator<Object> classAndIdPlanningComparator; private DefaultConstraintJustification(Score<?> impact, List<Object> facts) { this.impact = impact; this.facts = facts; } public <Score_ extends Score<Score_>> Score_ getImpact() { return (Score_) impact; } public List<Object> getFacts() { return facts; } @Override public String toString() { return facts.toString(); } @Override public int compareTo(DefaultConstraintJustification other) { String impactClassName = impact.getClass().getCanonicalName(); String otherImpactClassName = other.impact.getClass().getCanonicalName(); int scoreClassComparison = impactClassName.compareTo(otherImpactClassName); if (scoreClassComparison != 0) { // Don't fail on two different score types. return scoreClassComparison; } int scoreComparison = ((Score) impact).compareTo(other.impact); if (scoreComparison != 0) { return scoreComparison; } List<?> justificationList = this.getFacts(); List<?> otherJustificationList = other.getFacts(); if (justificationList != otherJustificationList) { if (justificationList.size() != otherJustificationList.size()) { return Integer.compare(justificationList.size(), otherJustificationList.size()); } else { Comparator<Object> comparator = getClassAndIdPlanningComparator(other); for (int i = 0; i < justificationList.size(); i++) { Object left = justificationList.get(i); Object right = otherJustificationList.get(i); int comparison = comparator.compare(left, right); if (comparison != 0) { return comparison; } } } } return Integer.compare(System.identityHashCode(this), System.identityHashCode(other)); } private Comparator<Object> getClassAndIdPlanningComparator(DefaultConstraintJustification other) {<FILL_FUNCTION_BODY>} }
/* * The comparator performs some expensive operations, which can be cached. * For optimal performance, this cache (MemberAccessFactory) needs to be shared between comparators. * In order to prevent the comparator from being shared in a static field creating a de-facto memory leak, * we cache the comparator inside this class, and we minimize the number of instances that will be created * by creating the comparator when none of the constraint matches already carry it, * and we store it in both. */ if (classAndIdPlanningComparator != null) { return classAndIdPlanningComparator; } else if (other.classAndIdPlanningComparator != null) { return other.classAndIdPlanningComparator; } else { /* * FIXME Using reflection will break Quarkus once we don't open up classes for reflection any more. * Use cases which need to operate safely within Quarkus should use SolutionDescriptor's MemberAccessorFactory. */ classAndIdPlanningComparator = new ClassAndPlanningIdComparator(new MemberAccessorFactory(), DomainAccessType.REFLECTION, false); other.classAndIdPlanningComparator = classAndIdPlanningComparator; return classAndIdPlanningComparator; }
912
328
1,240
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/config/constructionheuristic/ConstructionHeuristicPhaseConfig.java
ConstructionHeuristicPhaseConfig
inherit
class ConstructionHeuristicPhaseConfig extends PhaseConfig<ConstructionHeuristicPhaseConfig> { public static final String XML_ELEMENT_NAME = "constructionHeuristic"; // Warning: all fields are null (and not defaulted) because they can be inherited // and also because the input config file should match the output config file protected ConstructionHeuristicType constructionHeuristicType = null; protected EntitySorterManner entitySorterManner = null; protected ValueSorterManner valueSorterManner = null; @XmlElements({ @XmlElement(name = "queuedEntityPlacer", type = QueuedEntityPlacerConfig.class), @XmlElement(name = "queuedValuePlacer", type = QueuedValuePlacerConfig.class), @XmlElement(name = "pooledEntityPlacer", type = PooledEntityPlacerConfig.class) }) protected EntityPlacerConfig entityPlacerConfig = null; /** Simpler alternative for {@link #entityPlacerConfig}. */ @XmlElements({ @XmlElement(name = CartesianProductMoveSelectorConfig.XML_ELEMENT_NAME, type = CartesianProductMoveSelectorConfig.class), @XmlElement(name = ChangeMoveSelectorConfig.XML_ELEMENT_NAME, type = ChangeMoveSelectorConfig.class), @XmlElement(name = MoveIteratorFactoryConfig.XML_ELEMENT_NAME, type = MoveIteratorFactoryConfig.class), @XmlElement(name = MoveListFactoryConfig.XML_ELEMENT_NAME, type = MoveListFactoryConfig.class), @XmlElement(name = PillarChangeMoveSelectorConfig.XML_ELEMENT_NAME, type = PillarChangeMoveSelectorConfig.class), @XmlElement(name = PillarSwapMoveSelectorConfig.XML_ELEMENT_NAME, type = PillarSwapMoveSelectorConfig.class), @XmlElement(name = SubChainChangeMoveSelectorConfig.XML_ELEMENT_NAME, type = SubChainChangeMoveSelectorConfig.class), @XmlElement(name = SubChainSwapMoveSelectorConfig.XML_ELEMENT_NAME, type = SubChainSwapMoveSelectorConfig.class), @XmlElement(name = SwapMoveSelectorConfig.XML_ELEMENT_NAME, type = SwapMoveSelectorConfig.class), @XmlElement(name = TailChainSwapMoveSelectorConfig.XML_ELEMENT_NAME, type = TailChainSwapMoveSelectorConfig.class), @XmlElement(name = UnionMoveSelectorConfig.XML_ELEMENT_NAME, type = UnionMoveSelectorConfig.class) }) protected List<MoveSelectorConfig> moveSelectorConfigList = null; @XmlElement(name = "forager") protected ConstructionHeuristicForagerConfig foragerConfig = null; // ************************************************************************ // Constructors and simple getters/setters // ************************************************************************ public ConstructionHeuristicType getConstructionHeuristicType() { return constructionHeuristicType; } public void setConstructionHeuristicType(ConstructionHeuristicType constructionHeuristicType) { this.constructionHeuristicType = constructionHeuristicType; } public EntitySorterManner getEntitySorterManner() { return entitySorterManner; } public void setEntitySorterManner(EntitySorterManner entitySorterManner) { this.entitySorterManner = entitySorterManner; } public ValueSorterManner getValueSorterManner() { return valueSorterManner; } public void setValueSorterManner(ValueSorterManner valueSorterManner) { this.valueSorterManner = valueSorterManner; } public EntityPlacerConfig getEntityPlacerConfig() { return entityPlacerConfig; } public void setEntityPlacerConfig(EntityPlacerConfig entityPlacerConfig) { this.entityPlacerConfig = entityPlacerConfig; } public List<MoveSelectorConfig> getMoveSelectorConfigList() { return moveSelectorConfigList; } public void setMoveSelectorConfigList(List<MoveSelectorConfig> moveSelectorConfigList) { this.moveSelectorConfigList = moveSelectorConfigList; } public ConstructionHeuristicForagerConfig getForagerConfig() { return foragerConfig; } public void setForagerConfig(ConstructionHeuristicForagerConfig foragerConfig) { this.foragerConfig = foragerConfig; } // ************************************************************************ // With methods // ************************************************************************ public ConstructionHeuristicPhaseConfig withConstructionHeuristicType( ConstructionHeuristicType constructionHeuristicType) { this.constructionHeuristicType = constructionHeuristicType; return this; } public ConstructionHeuristicPhaseConfig withEntitySorterManner(EntitySorterManner entitySorterManner) { this.entitySorterManner = entitySorterManner; return this; } public ConstructionHeuristicPhaseConfig withValueSorterManner(ValueSorterManner valueSorterManner) { this.valueSorterManner = valueSorterManner; return this; } public ConstructionHeuristicPhaseConfig withEntityPlacerConfig(EntityPlacerConfig<?> entityPlacerConfig) { this.entityPlacerConfig = entityPlacerConfig; return this; } public ConstructionHeuristicPhaseConfig withMoveSelectorConfigList(List<MoveSelectorConfig> moveSelectorConfigList) { this.moveSelectorConfigList = moveSelectorConfigList; return this; } public ConstructionHeuristicPhaseConfig withForagerConfig(ConstructionHeuristicForagerConfig foragerConfig) { this.foragerConfig = foragerConfig; return this; } @Override public ConstructionHeuristicPhaseConfig inherit(ConstructionHeuristicPhaseConfig inheritedConfig) {<FILL_FUNCTION_BODY>} @Override public ConstructionHeuristicPhaseConfig copyConfig() { return new ConstructionHeuristicPhaseConfig().inherit(this); } @Override public void visitReferencedClasses(Consumer<Class<?>> classVisitor) { if (getTerminationConfig() != null) { getTerminationConfig().visitReferencedClasses(classVisitor); } if (entityPlacerConfig != null) { entityPlacerConfig.visitReferencedClasses(classVisitor); } if (moveSelectorConfigList != null) { moveSelectorConfigList.forEach(ms -> ms.visitReferencedClasses(classVisitor)); } if (foragerConfig != null) { foragerConfig.visitReferencedClasses(classVisitor); } } }
super.inherit(inheritedConfig); constructionHeuristicType = ConfigUtils.inheritOverwritableProperty(constructionHeuristicType, inheritedConfig.getConstructionHeuristicType()); entitySorterManner = ConfigUtils.inheritOverwritableProperty(entitySorterManner, inheritedConfig.getEntitySorterManner()); valueSorterManner = ConfigUtils.inheritOverwritableProperty(valueSorterManner, inheritedConfig.getValueSorterManner()); setEntityPlacerConfig(ConfigUtils.inheritOverwritableProperty( getEntityPlacerConfig(), inheritedConfig.getEntityPlacerConfig())); moveSelectorConfigList = ConfigUtils.inheritMergeableListConfig( moveSelectorConfigList, inheritedConfig.getMoveSelectorConfigList()); foragerConfig = ConfigUtils.inheritConfig(foragerConfig, inheritedConfig.getForagerConfig()); return this;
1,711
215
1,926
<methods>public non-sealed void <init>() ,public org.optaplanner.core.config.solver.termination.TerminationConfig getTerminationConfig() ,public org.optaplanner.core.config.constructionheuristic.ConstructionHeuristicPhaseConfig inherit(org.optaplanner.core.config.constructionheuristic.ConstructionHeuristicPhaseConfig) ,public void setTerminationConfig(org.optaplanner.core.config.solver.termination.TerminationConfig) ,public java.lang.String toString() ,public org.optaplanner.core.config.constructionheuristic.ConstructionHeuristicPhaseConfig withTerminationConfig(org.optaplanner.core.config.solver.termination.TerminationConfig) <variables>private org.optaplanner.core.config.solver.termination.TerminationConfig terminationConfig
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/config/constructionheuristic/placer/QueuedEntityPlacerConfig.java
QueuedEntityPlacerConfig
visitReferencedClasses
class QueuedEntityPlacerConfig extends EntityPlacerConfig<QueuedEntityPlacerConfig> { @XmlElement(name = "entitySelector") protected EntitySelectorConfig entitySelectorConfig = null; @XmlElements({ @XmlElement(name = CartesianProductMoveSelectorConfig.XML_ELEMENT_NAME, type = CartesianProductMoveSelectorConfig.class), @XmlElement(name = ChangeMoveSelectorConfig.XML_ELEMENT_NAME, type = ChangeMoveSelectorConfig.class), @XmlElement(name = MoveIteratorFactoryConfig.XML_ELEMENT_NAME, type = MoveIteratorFactoryConfig.class), @XmlElement(name = MoveListFactoryConfig.XML_ELEMENT_NAME, type = MoveListFactoryConfig.class), @XmlElement(name = PillarChangeMoveSelectorConfig.XML_ELEMENT_NAME, type = PillarChangeMoveSelectorConfig.class), @XmlElement(name = PillarSwapMoveSelectorConfig.XML_ELEMENT_NAME, type = PillarSwapMoveSelectorConfig.class), @XmlElement(name = SubChainChangeMoveSelectorConfig.XML_ELEMENT_NAME, type = SubChainChangeMoveSelectorConfig.class), @XmlElement(name = SubChainSwapMoveSelectorConfig.XML_ELEMENT_NAME, type = SubChainSwapMoveSelectorConfig.class), @XmlElement(name = SwapMoveSelectorConfig.XML_ELEMENT_NAME, type = SwapMoveSelectorConfig.class), @XmlElement(name = TailChainSwapMoveSelectorConfig.XML_ELEMENT_NAME, type = TailChainSwapMoveSelectorConfig.class), @XmlElement(name = UnionMoveSelectorConfig.XML_ELEMENT_NAME, type = UnionMoveSelectorConfig.class) }) protected List<MoveSelectorConfig> moveSelectorConfigList = null; public EntitySelectorConfig getEntitySelectorConfig() { return entitySelectorConfig; } public void setEntitySelectorConfig(EntitySelectorConfig entitySelectorConfig) { this.entitySelectorConfig = entitySelectorConfig; } public List<MoveSelectorConfig> getMoveSelectorConfigList() { return moveSelectorConfigList; } public void setMoveSelectorConfigList(List<MoveSelectorConfig> moveSelectorConfigList) { this.moveSelectorConfigList = moveSelectorConfigList; } // ************************************************************************ // With methods // ************************************************************************ public QueuedEntityPlacerConfig withEntitySelectorConfig(EntitySelectorConfig entitySelectorConfig) { this.setEntitySelectorConfig(entitySelectorConfig); return this; } public QueuedEntityPlacerConfig withMoveSelectorConfigList(List<MoveSelectorConfig> moveSelectorConfigList) { this.setMoveSelectorConfigList(moveSelectorConfigList); return this; } public QueuedEntityPlacerConfig withMoveSelectorConfigs(MoveSelectorConfig... moveSelectorConfigs) { return this.withMoveSelectorConfigList(Arrays.asList(moveSelectorConfigs)); } // ************************************************************************ // Builder methods // ************************************************************************ @Override public QueuedEntityPlacerConfig inherit(QueuedEntityPlacerConfig inheritedConfig) { entitySelectorConfig = ConfigUtils.inheritConfig(entitySelectorConfig, inheritedConfig.getEntitySelectorConfig()); moveSelectorConfigList = ConfigUtils.inheritMergeableListConfig( moveSelectorConfigList, inheritedConfig.getMoveSelectorConfigList()); return this; } @Override public QueuedEntityPlacerConfig copyConfig() { return new QueuedEntityPlacerConfig().inherit(this); } @Override public void visitReferencedClasses(Consumer<Class<?>> classVisitor) {<FILL_FUNCTION_BODY>} @Override public String toString() { return getClass().getSimpleName() + "(" + entitySelectorConfig + ", " + moveSelectorConfigList + ")"; } }
if (entitySelectorConfig != null) { entitySelectorConfig.visitReferencedClasses(classVisitor); } if (moveSelectorConfigList != null) { moveSelectorConfigList.forEach(ms -> ms.visitReferencedClasses(classVisitor)); }
965
76
1,041
<methods>public non-sealed void <init>() <variables>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/config/constructionheuristic/placer/QueuedValuePlacerConfig.java
QueuedValuePlacerConfig
visitReferencedClasses
class QueuedValuePlacerConfig extends EntityPlacerConfig<QueuedValuePlacerConfig> { protected Class<?> entityClass = null; @XmlElement(name = "valueSelector") protected ValueSelectorConfig valueSelectorConfig = null; @XmlElements({ @XmlElement(name = CartesianProductMoveSelectorConfig.XML_ELEMENT_NAME, type = CartesianProductMoveSelectorConfig.class), @XmlElement(name = ChangeMoveSelectorConfig.XML_ELEMENT_NAME, type = ChangeMoveSelectorConfig.class), @XmlElement(name = MoveIteratorFactoryConfig.XML_ELEMENT_NAME, type = MoveIteratorFactoryConfig.class), @XmlElement(name = MoveListFactoryConfig.XML_ELEMENT_NAME, type = MoveListFactoryConfig.class), @XmlElement(name = PillarChangeMoveSelectorConfig.XML_ELEMENT_NAME, type = PillarChangeMoveSelectorConfig.class), @XmlElement(name = PillarSwapMoveSelectorConfig.XML_ELEMENT_NAME, type = PillarSwapMoveSelectorConfig.class), @XmlElement(name = SubChainChangeMoveSelectorConfig.XML_ELEMENT_NAME, type = SubChainChangeMoveSelectorConfig.class), @XmlElement(name = SubChainSwapMoveSelectorConfig.XML_ELEMENT_NAME, type = SubChainSwapMoveSelectorConfig.class), @XmlElement(name = SwapMoveSelectorConfig.XML_ELEMENT_NAME, type = SwapMoveSelectorConfig.class), @XmlElement(name = TailChainSwapMoveSelectorConfig.XML_ELEMENT_NAME, type = TailChainSwapMoveSelectorConfig.class), @XmlElement(name = UnionMoveSelectorConfig.XML_ELEMENT_NAME, type = UnionMoveSelectorConfig.class) }) private MoveSelectorConfig moveSelectorConfig = null; public Class<?> getEntityClass() { return entityClass; } public void setEntityClass(Class<?> entityClass) { this.entityClass = entityClass; } public ValueSelectorConfig getValueSelectorConfig() { return valueSelectorConfig; } public void setValueSelectorConfig(ValueSelectorConfig valueSelectorConfig) { this.valueSelectorConfig = valueSelectorConfig; } public MoveSelectorConfig getMoveSelectorConfig() { return moveSelectorConfig; } public void setMoveSelectorConfig(MoveSelectorConfig moveSelectorConfig) { this.moveSelectorConfig = moveSelectorConfig; } // ************************************************************************ // With methods // ************************************************************************ public QueuedValuePlacerConfig withEntityClass(Class<?> entityClass) { this.setEntityClass(entityClass); return this; } public QueuedValuePlacerConfig withValueSelectorConfig(ValueSelectorConfig valueSelectorConfig) { this.setValueSelectorConfig(valueSelectorConfig); return this; } public QueuedValuePlacerConfig withMoveSelectorConfig(MoveSelectorConfig moveSelectorConfig) { this.setMoveSelectorConfig(moveSelectorConfig); return this; } // ************************************************************************ // Builder methods // ************************************************************************ @Override public QueuedValuePlacerConfig inherit(QueuedValuePlacerConfig inheritedConfig) { entityClass = ConfigUtils.inheritOverwritableProperty(entityClass, inheritedConfig.getEntityClass()); valueSelectorConfig = ConfigUtils.inheritConfig(valueSelectorConfig, inheritedConfig.getValueSelectorConfig()); setMoveSelectorConfig( ConfigUtils.inheritOverwritableProperty(getMoveSelectorConfig(), inheritedConfig.getMoveSelectorConfig())); return this; } @Override public QueuedValuePlacerConfig copyConfig() { return new QueuedValuePlacerConfig().inherit(this); } @Override public void visitReferencedClasses(Consumer<Class<?>> classVisitor) {<FILL_FUNCTION_BODY>} @Override public String toString() { return getClass().getSimpleName() + "(" + valueSelectorConfig + ", " + moveSelectorConfig + ")"; } }
classVisitor.accept(entityClass); if (valueSelectorConfig != null) { valueSelectorConfig.visitReferencedClasses(classVisitor); } if (moveSelectorConfig != null) { moveSelectorConfig.visitReferencedClasses(classVisitor); }
1,015
78
1,093
<methods>public non-sealed void <init>() <variables>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/config/exhaustivesearch/ExhaustiveSearchPhaseConfig.java
ExhaustiveSearchPhaseConfig
inherit
class ExhaustiveSearchPhaseConfig extends PhaseConfig<ExhaustiveSearchPhaseConfig> { public static final String XML_ELEMENT_NAME = "exhaustiveSearch"; // Warning: all fields are null (and not defaulted) because they can be inherited // and also because the input config file should match the output config file protected ExhaustiveSearchType exhaustiveSearchType = null; protected NodeExplorationType nodeExplorationType = null; protected EntitySorterManner entitySorterManner = null; protected ValueSorterManner valueSorterManner = null; @XmlElement(name = "entitySelector") protected EntitySelectorConfig entitySelectorConfig = null; @XmlElements({ @XmlElement(name = CartesianProductMoveSelectorConfig.XML_ELEMENT_NAME, type = CartesianProductMoveSelectorConfig.class), @XmlElement(name = ChangeMoveSelectorConfig.XML_ELEMENT_NAME, type = ChangeMoveSelectorConfig.class), @XmlElement(name = MoveIteratorFactoryConfig.XML_ELEMENT_NAME, type = MoveIteratorFactoryConfig.class), @XmlElement(name = MoveListFactoryConfig.XML_ELEMENT_NAME, type = MoveListFactoryConfig.class), @XmlElement(name = PillarChangeMoveSelectorConfig.XML_ELEMENT_NAME, type = PillarChangeMoveSelectorConfig.class), @XmlElement(name = PillarSwapMoveSelectorConfig.XML_ELEMENT_NAME, type = PillarSwapMoveSelectorConfig.class), @XmlElement(name = SubChainChangeMoveSelectorConfig.XML_ELEMENT_NAME, type = SubChainChangeMoveSelectorConfig.class), @XmlElement(name = SubChainSwapMoveSelectorConfig.XML_ELEMENT_NAME, type = SubChainSwapMoveSelectorConfig.class), @XmlElement(name = SwapMoveSelectorConfig.XML_ELEMENT_NAME, type = SwapMoveSelectorConfig.class), @XmlElement(name = TailChainSwapMoveSelectorConfig.XML_ELEMENT_NAME, type = TailChainSwapMoveSelectorConfig.class), @XmlElement(name = UnionMoveSelectorConfig.XML_ELEMENT_NAME, type = UnionMoveSelectorConfig.class) }) protected MoveSelectorConfig moveSelectorConfig = null; public ExhaustiveSearchType getExhaustiveSearchType() { return exhaustiveSearchType; } public void setExhaustiveSearchType(ExhaustiveSearchType exhaustiveSearchType) { this.exhaustiveSearchType = exhaustiveSearchType; } public NodeExplorationType getNodeExplorationType() { return nodeExplorationType; } public void setNodeExplorationType(NodeExplorationType nodeExplorationType) { this.nodeExplorationType = nodeExplorationType; } public EntitySorterManner getEntitySorterManner() { return entitySorterManner; } public void setEntitySorterManner(EntitySorterManner entitySorterManner) { this.entitySorterManner = entitySorterManner; } public ValueSorterManner getValueSorterManner() { return valueSorterManner; } public void setValueSorterManner(ValueSorterManner valueSorterManner) { this.valueSorterManner = valueSorterManner; } public EntitySelectorConfig getEntitySelectorConfig() { return entitySelectorConfig; } public void setEntitySelectorConfig(EntitySelectorConfig entitySelectorConfig) { this.entitySelectorConfig = entitySelectorConfig; } public MoveSelectorConfig getMoveSelectorConfig() { return moveSelectorConfig; } public void setMoveSelectorConfig(MoveSelectorConfig moveSelectorConfig) { this.moveSelectorConfig = moveSelectorConfig; } // ************************************************************************ // With methods // ************************************************************************ public ExhaustiveSearchPhaseConfig withExhaustiveSearchType(ExhaustiveSearchType exhaustiveSearchType) { this.setExhaustiveSearchType(exhaustiveSearchType); return this; } public ExhaustiveSearchPhaseConfig withNodeExplorationType(NodeExplorationType nodeExplorationType) { this.setNodeExplorationType(nodeExplorationType); return this; } public ExhaustiveSearchPhaseConfig withEntitySorterManner(EntitySorterManner entitySorterManner) { this.setEntitySorterManner(entitySorterManner); return this; } public ExhaustiveSearchPhaseConfig withValueSorterManner(ValueSorterManner valueSorterManner) { this.setValueSorterManner(valueSorterManner); return this; } public ExhaustiveSearchPhaseConfig withEntitySelectorConfig(EntitySelectorConfig entitySelectorConfig) { this.setEntitySelectorConfig(entitySelectorConfig); return this; } public ExhaustiveSearchPhaseConfig withMoveSelectorConfig(MoveSelectorConfig moveSelectorConfig) { this.setMoveSelectorConfig(moveSelectorConfig); return this; } @Override public ExhaustiveSearchPhaseConfig inherit(ExhaustiveSearchPhaseConfig inheritedConfig) {<FILL_FUNCTION_BODY>} @Override public ExhaustiveSearchPhaseConfig copyConfig() { return new ExhaustiveSearchPhaseConfig().inherit(this); } @Override public void visitReferencedClasses(Consumer<Class<?>> classVisitor) { if (getTerminationConfig() != null) { getTerminationConfig().visitReferencedClasses(classVisitor); } if (entitySelectorConfig != null) { entitySelectorConfig.visitReferencedClasses(classVisitor); } if (moveSelectorConfig != null) { moveSelectorConfig.visitReferencedClasses(classVisitor); } } }
super.inherit(inheritedConfig); exhaustiveSearchType = ConfigUtils.inheritOverwritableProperty(exhaustiveSearchType, inheritedConfig.getExhaustiveSearchType()); nodeExplorationType = ConfigUtils.inheritOverwritableProperty(nodeExplorationType, inheritedConfig.getNodeExplorationType()); entitySorterManner = ConfigUtils.inheritOverwritableProperty(entitySorterManner, inheritedConfig.getEntitySorterManner()); valueSorterManner = ConfigUtils.inheritOverwritableProperty(valueSorterManner, inheritedConfig.getValueSorterManner()); entitySelectorConfig = ConfigUtils.inheritConfig(entitySelectorConfig, inheritedConfig.getEntitySelectorConfig()); moveSelectorConfig = ConfigUtils.inheritConfig(moveSelectorConfig, inheritedConfig.getMoveSelectorConfig()); return this;
1,506
203
1,709
<methods>public non-sealed void <init>() ,public org.optaplanner.core.config.solver.termination.TerminationConfig getTerminationConfig() ,public org.optaplanner.core.config.exhaustivesearch.ExhaustiveSearchPhaseConfig inherit(org.optaplanner.core.config.exhaustivesearch.ExhaustiveSearchPhaseConfig) ,public void setTerminationConfig(org.optaplanner.core.config.solver.termination.TerminationConfig) ,public java.lang.String toString() ,public org.optaplanner.core.config.exhaustivesearch.ExhaustiveSearchPhaseConfig withTerminationConfig(org.optaplanner.core.config.solver.termination.TerminationConfig) <variables>private org.optaplanner.core.config.solver.termination.TerminationConfig terminationConfig
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/config/heuristic/selector/entity/pillar/PillarSelectorConfig.java
PillarSelectorConfig
inherit
class PillarSelectorConfig extends SelectorConfig<PillarSelectorConfig> { @XmlElement(name = "entitySelector") protected EntitySelectorConfig entitySelectorConfig = null; protected Integer minimumSubPillarSize = null; protected Integer maximumSubPillarSize = null; public EntitySelectorConfig getEntitySelectorConfig() { return entitySelectorConfig; } public void setEntitySelectorConfig(EntitySelectorConfig entitySelectorConfig) { this.entitySelectorConfig = entitySelectorConfig; } public Integer getMinimumSubPillarSize() { return minimumSubPillarSize; } public void setMinimumSubPillarSize(Integer minimumSubPillarSize) { this.minimumSubPillarSize = minimumSubPillarSize; } public Integer getMaximumSubPillarSize() { return maximumSubPillarSize; } public void setMaximumSubPillarSize(Integer maximumSubPillarSize) { this.maximumSubPillarSize = maximumSubPillarSize; } // ************************************************************************ // With methods // ************************************************************************ public PillarSelectorConfig withEntitySelectorConfig(EntitySelectorConfig entitySelectorConfig) { this.setEntitySelectorConfig(entitySelectorConfig); return this; } public PillarSelectorConfig withMinimumSubPillarSize(Integer minimumSubPillarSize) { this.setMinimumSubPillarSize(minimumSubPillarSize); return this; } public PillarSelectorConfig withMaximumSubPillarSize(Integer maximumSubPillarSize) { this.setMaximumSubPillarSize(maximumSubPillarSize); return this; } @Override public PillarSelectorConfig inherit(PillarSelectorConfig inheritedConfig) {<FILL_FUNCTION_BODY>} @Override public PillarSelectorConfig copyConfig() { return new PillarSelectorConfig().inherit(this); } @Override public void visitReferencedClasses(Consumer<Class<?>> classVisitor) { if (entitySelectorConfig != null) { entitySelectorConfig.visitReferencedClasses(classVisitor); } } @Override public String toString() { return getClass().getSimpleName() + "(" + entitySelectorConfig + ")"; } }
entitySelectorConfig = ConfigUtils.inheritConfig(entitySelectorConfig, inheritedConfig.getEntitySelectorConfig()); minimumSubPillarSize = ConfigUtils.inheritOverwritableProperty(minimumSubPillarSize, inheritedConfig.getMinimumSubPillarSize()); maximumSubPillarSize = ConfigUtils.inheritOverwritableProperty(maximumSubPillarSize, inheritedConfig.getMaximumSubPillarSize()); return this;
617
111
728
<methods>public non-sealed void <init>() <variables>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/config/heuristic/selector/list/DestinationSelectorConfig.java
DestinationSelectorConfig
inherit
class DestinationSelectorConfig extends SelectorConfig<DestinationSelectorConfig> { @XmlElement(name = "entitySelector") private EntitySelectorConfig entitySelectorConfig; @XmlElement(name = "valueSelector") private ValueSelectorConfig valueSelectorConfig; @XmlElement(name = "nearbySelection") private NearbySelectionConfig nearbySelectionConfig; public DestinationSelectorConfig() { } public DestinationSelectorConfig(DestinationSelectorConfig inheritedConfig) { if (inheritedConfig != null) { inherit(inheritedConfig); } } public EntitySelectorConfig getEntitySelectorConfig() { return entitySelectorConfig; } public void setEntitySelectorConfig(EntitySelectorConfig entitySelectorConfig) { this.entitySelectorConfig = entitySelectorConfig; } public ValueSelectorConfig getValueSelectorConfig() { return valueSelectorConfig; } public void setValueSelectorConfig(ValueSelectorConfig valueSelectorConfig) { this.valueSelectorConfig = valueSelectorConfig; } public NearbySelectionConfig getNearbySelectionConfig() { return nearbySelectionConfig; } public void setNearbySelectionConfig(NearbySelectionConfig nearbySelectionConfig) { this.nearbySelectionConfig = nearbySelectionConfig; } // ************************************************************************ // With methods // ************************************************************************ public DestinationSelectorConfig withEntitySelectorConfig(EntitySelectorConfig entitySelectorConfig) { this.setEntitySelectorConfig(entitySelectorConfig); return this; } public DestinationSelectorConfig withValueSelectorConfig(ValueSelectorConfig valueSelectorConfig) { this.setValueSelectorConfig(valueSelectorConfig); return this; } public DestinationSelectorConfig withNearbySelectionConfig(NearbySelectionConfig nearbySelectionConfig) { this.setNearbySelectionConfig(nearbySelectionConfig); return this; } // ************************************************************************ // Builder methods // ************************************************************************ @Override public DestinationSelectorConfig inherit(DestinationSelectorConfig inheritedConfig) {<FILL_FUNCTION_BODY>} @Override public DestinationSelectorConfig copyConfig() { return new DestinationSelectorConfig().inherit(this); } @Override public void visitReferencedClasses(Consumer<Class<?>> classVisitor) { if (entitySelectorConfig != null) { entitySelectorConfig.visitReferencedClasses(classVisitor); } if (valueSelectorConfig != null) { valueSelectorConfig.visitReferencedClasses(classVisitor); } if (nearbySelectionConfig != null) { nearbySelectionConfig.visitReferencedClasses(classVisitor); } } @Override public String toString() { return getClass().getSimpleName() + "(" + entitySelectorConfig + ", " + valueSelectorConfig + ")"; } }
entitySelectorConfig = ConfigUtils.inheritConfig(entitySelectorConfig, inheritedConfig.getEntitySelectorConfig()); valueSelectorConfig = ConfigUtils.inheritConfig(valueSelectorConfig, inheritedConfig.getValueSelectorConfig()); nearbySelectionConfig = ConfigUtils.inheritConfig(nearbySelectionConfig, inheritedConfig.getNearbySelectionConfig()); return this;
730
82
812
<methods>public non-sealed void <init>() <variables>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/config/heuristic/selector/list/SubListSelectorConfig.java
SubListSelectorConfig
visitReferencedClasses
class SubListSelectorConfig extends SelectorConfig<SubListSelectorConfig> { @XmlAttribute private String id = null; @XmlAttribute private String mimicSelectorRef = null; @XmlElement(name = "valueSelector") private ValueSelectorConfig valueSelectorConfig = null; @XmlElement(name = "nearbySelection") private NearbySelectionConfig nearbySelectionConfig = null; private Integer minimumSubListSize = null; private Integer maximumSubListSize = null; public SubListSelectorConfig() { } public SubListSelectorConfig(SubListSelectorConfig inheritedConfig) { if (inheritedConfig != null) { inherit(inheritedConfig); } } public String getId() { return id; } public void setId(String id) { this.id = id; } public String getMimicSelectorRef() { return mimicSelectorRef; } public void setMimicSelectorRef(String mimicSelectorRef) { this.mimicSelectorRef = mimicSelectorRef; } public ValueSelectorConfig getValueSelectorConfig() { return valueSelectorConfig; } public void setValueSelectorConfig(ValueSelectorConfig valueSelectorConfig) { this.valueSelectorConfig = valueSelectorConfig; } public NearbySelectionConfig getNearbySelectionConfig() { return nearbySelectionConfig; } public void setNearbySelectionConfig(NearbySelectionConfig nearbySelectionConfig) { this.nearbySelectionConfig = nearbySelectionConfig; } public Integer getMinimumSubListSize() { return minimumSubListSize; } public void setMinimumSubListSize(Integer minimumSubListSize) { this.minimumSubListSize = minimumSubListSize; } public Integer getMaximumSubListSize() { return maximumSubListSize; } public void setMaximumSubListSize(Integer maximumSubListSize) { this.maximumSubListSize = maximumSubListSize; } // ************************************************************************ // With methods // ************************************************************************ public SubListSelectorConfig withId(String id) { this.setId(id); return this; } public SubListSelectorConfig withMimicSelectorRef(String mimicSelectorRef) { this.setMimicSelectorRef(mimicSelectorRef); return this; } public SubListSelectorConfig withValueSelectorConfig(ValueSelectorConfig valueSelectorConfig) { this.setValueSelectorConfig(valueSelectorConfig); return this; } public SubListSelectorConfig withNearbySelectionConfig(NearbySelectionConfig nearbySelectionConfig) { this.setNearbySelectionConfig(nearbySelectionConfig); return this; } public SubListSelectorConfig withMinimumSubListSize(Integer minimumSubListSize) { this.setMinimumSubListSize(minimumSubListSize); return this; } public SubListSelectorConfig withMaximumSubListSize(Integer maximumSubListSize) { this.setMaximumSubListSize(maximumSubListSize); return this; } // ************************************************************************ // Builder methods // ************************************************************************ @Override public SubListSelectorConfig inherit(SubListSelectorConfig inheritedConfig) { id = ConfigUtils.inheritOverwritableProperty(id, inheritedConfig.id); mimicSelectorRef = ConfigUtils.inheritOverwritableProperty(mimicSelectorRef, inheritedConfig.mimicSelectorRef); valueSelectorConfig = ConfigUtils.inheritConfig(valueSelectorConfig, inheritedConfig.valueSelectorConfig); nearbySelectionConfig = ConfigUtils.inheritConfig(nearbySelectionConfig, inheritedConfig.nearbySelectionConfig); minimumSubListSize = ConfigUtils.inheritOverwritableProperty(minimumSubListSize, inheritedConfig.minimumSubListSize); maximumSubListSize = ConfigUtils.inheritOverwritableProperty(maximumSubListSize, inheritedConfig.maximumSubListSize); return this; } @Override public SubListSelectorConfig copyConfig() { return new SubListSelectorConfig().inherit(this); } @Override public void visitReferencedClasses(Consumer<Class<?>> classVisitor) {<FILL_FUNCTION_BODY>} @Override public String toString() { return getClass().getSimpleName() + "(" + valueSelectorConfig + ")"; } }
if (valueSelectorConfig != null) { valueSelectorConfig.visitReferencedClasses(classVisitor); } if (nearbySelectionConfig != null) { nearbySelectionConfig.visitReferencedClasses(classVisitor); }
1,119
68
1,187
<methods>public non-sealed void <init>() <variables>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/config/heuristic/selector/move/MoveSelectorConfig.java
MoveSelectorConfig
inheritCommon
class MoveSelectorConfig<Config_ extends MoveSelectorConfig<Config_>> extends SelectorConfig<Config_> { protected SelectionCacheType cacheType = null; protected SelectionOrder selectionOrder = null; protected Class<? extends SelectionFilter> filterClass = null; protected Class<? extends Comparator> sorterComparatorClass = null; protected Class<? extends SelectionSorterWeightFactory> sorterWeightFactoryClass = null; protected SelectionSorterOrder sorterOrder = null; protected Class<? extends SelectionSorter> sorterClass = null; protected Class<? extends SelectionProbabilityWeightFactory> probabilityWeightFactoryClass = null; protected Long selectedCountLimit = null; private Double fixedProbabilityWeight = null; // ************************************************************************ // Constructors and simple getters/setters // ************************************************************************ public SelectionCacheType getCacheType() { return cacheType; } public void setCacheType(SelectionCacheType cacheType) { this.cacheType = cacheType; } public SelectionOrder getSelectionOrder() { return selectionOrder; } public void setSelectionOrder(SelectionOrder selectionOrder) { this.selectionOrder = selectionOrder; } public Class<? extends SelectionFilter> getFilterClass() { return filterClass; } public void setFilterClass(Class<? extends SelectionFilter> filterClass) { this.filterClass = filterClass; } public Class<? extends Comparator> getSorterComparatorClass() { return sorterComparatorClass; } public void setSorterComparatorClass(Class<? extends Comparator> sorterComparatorClass) { this.sorterComparatorClass = sorterComparatorClass; } public Class<? extends SelectionSorterWeightFactory> getSorterWeightFactoryClass() { return sorterWeightFactoryClass; } public void setSorterWeightFactoryClass(Class<? extends SelectionSorterWeightFactory> sorterWeightFactoryClass) { this.sorterWeightFactoryClass = sorterWeightFactoryClass; } public SelectionSorterOrder getSorterOrder() { return sorterOrder; } public void setSorterOrder(SelectionSorterOrder sorterOrder) { this.sorterOrder = sorterOrder; } public Class<? extends SelectionSorter> getSorterClass() { return sorterClass; } public void setSorterClass(Class<? extends SelectionSorter> sorterClass) { this.sorterClass = sorterClass; } public Class<? extends SelectionProbabilityWeightFactory> getProbabilityWeightFactoryClass() { return probabilityWeightFactoryClass; } public void setProbabilityWeightFactoryClass( Class<? extends SelectionProbabilityWeightFactory> probabilityWeightFactoryClass) { this.probabilityWeightFactoryClass = probabilityWeightFactoryClass; } public Long getSelectedCountLimit() { return selectedCountLimit; } public void setSelectedCountLimit(Long selectedCountLimit) { this.selectedCountLimit = selectedCountLimit; } public Double getFixedProbabilityWeight() { return fixedProbabilityWeight; } public void setFixedProbabilityWeight(Double fixedProbabilityWeight) { this.fixedProbabilityWeight = fixedProbabilityWeight; } // ************************************************************************ // With methods // ************************************************************************ public Config_ withCacheType(SelectionCacheType cacheType) { this.cacheType = cacheType; return (Config_) this; } public Config_ withSelectionOrder(SelectionOrder selectionOrder) { this.selectionOrder = selectionOrder; return (Config_) this; } public Config_ withFilterClass(Class<? extends SelectionFilter> filterClass) { this.filterClass = filterClass; return (Config_) this; } public Config_ withSorterComparatorClass(Class<? extends Comparator> sorterComparatorClass) { this.sorterComparatorClass = sorterComparatorClass; return (Config_) this; } public Config_ withSorterWeightFactoryClass( Class<? extends SelectionSorterWeightFactory> sorterWeightFactoryClass) { this.sorterWeightFactoryClass = sorterWeightFactoryClass; return (Config_) this; } public Config_ withSorterOrder(SelectionSorterOrder sorterOrder) { this.sorterOrder = sorterOrder; return (Config_) this; } public Config_ withSorterClass(Class<? extends SelectionSorter> sorterClass) { this.sorterClass = sorterClass; return (Config_) this; } public Config_ withProbabilityWeightFactoryClass( Class<? extends SelectionProbabilityWeightFactory> probabilityWeightFactoryClass) { this.probabilityWeightFactoryClass = probabilityWeightFactoryClass; return (Config_) this; } public Config_ withSelectedCountLimit(Long selectedCountLimit) { this.selectedCountLimit = selectedCountLimit; return (Config_) this; } public Config_ withFixedProbabilityWeight(Double fixedProbabilityWeight) { this.fixedProbabilityWeight = fixedProbabilityWeight; return (Config_) this; } /** * Gather a list of all descendant {@link MoveSelectorConfig}s * except for {@link UnionMoveSelectorConfig} and {@link CartesianProductMoveSelectorConfig}. * * @param leafMoveSelectorConfigList not null */ public void extractLeafMoveSelectorConfigsIntoList(List<MoveSelectorConfig> leafMoveSelectorConfigList) { leafMoveSelectorConfigList.add(this); } @Override public Config_ inherit(Config_ inheritedConfig) { inheritCommon(inheritedConfig); return (Config_) this; } /** * Does not inherit subclass properties because this class and {@code foldedConfig} can be of a different type. * * @param foldedConfig never null */ public void inheritFolded(MoveSelectorConfig<?> foldedConfig) { inheritCommon(foldedConfig); } protected void visitCommonReferencedClasses(Consumer<Class<?>> classVisitor) { classVisitor.accept(filterClass); classVisitor.accept(sorterComparatorClass); classVisitor.accept(sorterWeightFactoryClass); classVisitor.accept(sorterClass); classVisitor.accept(probabilityWeightFactoryClass); } private void inheritCommon(MoveSelectorConfig<?> inheritedConfig) {<FILL_FUNCTION_BODY>} }
cacheType = ConfigUtils.inheritOverwritableProperty(cacheType, inheritedConfig.getCacheType()); selectionOrder = ConfigUtils.inheritOverwritableProperty(selectionOrder, inheritedConfig.getSelectionOrder()); filterClass = ConfigUtils.inheritOverwritableProperty(filterClass, inheritedConfig.getFilterClass()); sorterComparatorClass = ConfigUtils.inheritOverwritableProperty( sorterComparatorClass, inheritedConfig.getSorterComparatorClass()); sorterWeightFactoryClass = ConfigUtils.inheritOverwritableProperty( sorterWeightFactoryClass, inheritedConfig.getSorterWeightFactoryClass()); sorterOrder = ConfigUtils.inheritOverwritableProperty( sorterOrder, inheritedConfig.getSorterOrder()); sorterClass = ConfigUtils.inheritOverwritableProperty( sorterClass, inheritedConfig.getSorterClass()); probabilityWeightFactoryClass = ConfigUtils.inheritOverwritableProperty( probabilityWeightFactoryClass, inheritedConfig.getProbabilityWeightFactoryClass()); selectedCountLimit = ConfigUtils.inheritOverwritableProperty( selectedCountLimit, inheritedConfig.getSelectedCountLimit()); fixedProbabilityWeight = ConfigUtils.inheritOverwritableProperty( fixedProbabilityWeight, inheritedConfig.getFixedProbabilityWeight());
1,694
301
1,995
<methods>public non-sealed void <init>() <variables>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/config/heuristic/selector/move/composite/CartesianProductMoveSelectorConfig.java
CartesianProductMoveSelectorConfig
visitReferencedClasses
class CartesianProductMoveSelectorConfig extends MoveSelectorConfig<CartesianProductMoveSelectorConfig> { public static final String XML_ELEMENT_NAME = "cartesianProductMoveSelector"; @XmlElements({ @XmlElement(name = CartesianProductMoveSelectorConfig.XML_ELEMENT_NAME, type = CartesianProductMoveSelectorConfig.class), @XmlElement(name = ChangeMoveSelectorConfig.XML_ELEMENT_NAME, type = ChangeMoveSelectorConfig.class), @XmlElement(name = KOptListMoveSelectorConfig.XML_ELEMENT_NAME, type = KOptListMoveSelectorConfig.class), @XmlElement(name = ListChangeMoveSelectorConfig.XML_ELEMENT_NAME, type = ListChangeMoveSelectorConfig.class), @XmlElement(name = ListSwapMoveSelectorConfig.XML_ELEMENT_NAME, type = ListSwapMoveSelectorConfig.class), @XmlElement(name = MoveIteratorFactoryConfig.XML_ELEMENT_NAME, type = MoveIteratorFactoryConfig.class), @XmlElement(name = MoveListFactoryConfig.XML_ELEMENT_NAME, type = MoveListFactoryConfig.class), @XmlElement(name = PillarChangeMoveSelectorConfig.XML_ELEMENT_NAME, type = PillarChangeMoveSelectorConfig.class), @XmlElement(name = PillarSwapMoveSelectorConfig.XML_ELEMENT_NAME, type = PillarSwapMoveSelectorConfig.class), @XmlElement(name = SubChainChangeMoveSelectorConfig.XML_ELEMENT_NAME, type = SubChainChangeMoveSelectorConfig.class), @XmlElement(name = SubChainSwapMoveSelectorConfig.XML_ELEMENT_NAME, type = SubChainSwapMoveSelectorConfig.class), @XmlElement(name = SubListChangeMoveSelectorConfig.XML_ELEMENT_NAME, type = SubListChangeMoveSelectorConfig.class), @XmlElement(name = SubListSwapMoveSelectorConfig.XML_ELEMENT_NAME, type = SubListSwapMoveSelectorConfig.class), @XmlElement(name = SwapMoveSelectorConfig.XML_ELEMENT_NAME, type = SwapMoveSelectorConfig.class), @XmlElement(name = TailChainSwapMoveSelectorConfig.XML_ELEMENT_NAME, type = TailChainSwapMoveSelectorConfig.class), @XmlElement(name = UnionMoveSelectorConfig.XML_ELEMENT_NAME, type = UnionMoveSelectorConfig.class) }) private List<MoveSelectorConfig> moveSelectorConfigList = null; private Boolean ignoreEmptyChildIterators = null; // ************************************************************************ // Constructors and simple getters/setters // ************************************************************************ public CartesianProductMoveSelectorConfig() { } public CartesianProductMoveSelectorConfig(List<MoveSelectorConfig> moveSelectorConfigList) { this.moveSelectorConfigList = moveSelectorConfigList; } /** * @deprecated Prefer {@link #getMoveSelectorList()}. * @return sometimes null */ @Deprecated public List<MoveSelectorConfig> getMoveSelectorConfigList() { return getMoveSelectorList(); } /** * @deprecated Prefer {@link #setMoveSelectorList(List)}. * @param moveSelectorConfigList sometimes null */ @Deprecated public void setMoveSelectorConfigList(List<MoveSelectorConfig> moveSelectorConfigList) { setMoveSelectorList(moveSelectorConfigList); } public List<MoveSelectorConfig> getMoveSelectorList() { return moveSelectorConfigList; } public void setMoveSelectorList(List<MoveSelectorConfig> moveSelectorConfigList) { this.moveSelectorConfigList = moveSelectorConfigList; } public Boolean getIgnoreEmptyChildIterators() { return ignoreEmptyChildIterators; } public void setIgnoreEmptyChildIterators(Boolean ignoreEmptyChildIterators) { this.ignoreEmptyChildIterators = ignoreEmptyChildIterators; } // ************************************************************************ // With methods // ************************************************************************ public CartesianProductMoveSelectorConfig withMoveSelectorList(List<MoveSelectorConfig> moveSelectorConfigList) { this.moveSelectorConfigList = moveSelectorConfigList; return this; } public CartesianProductMoveSelectorConfig withMoveSelectors(MoveSelectorConfig... moveSelectorConfigs) { this.moveSelectorConfigList = Arrays.asList(moveSelectorConfigs); return this; } public CartesianProductMoveSelectorConfig withIgnoreEmptyChildIterators(Boolean ignoreEmptyChildIterators) { this.ignoreEmptyChildIterators = ignoreEmptyChildIterators; return this; } // ************************************************************************ // Worker methods // ************************************************************************ @Override public void extractLeafMoveSelectorConfigsIntoList(List<MoveSelectorConfig> leafMoveSelectorConfigList) { for (MoveSelectorConfig moveSelectorConfig : moveSelectorConfigList) { moveSelectorConfig.extractLeafMoveSelectorConfigsIntoList(leafMoveSelectorConfigList); } } @Override public CartesianProductMoveSelectorConfig inherit(CartesianProductMoveSelectorConfig inheritedConfig) { super.inherit(inheritedConfig); moveSelectorConfigList = ConfigUtils.inheritMergeableListConfig(moveSelectorConfigList, inheritedConfig.getMoveSelectorList()); ignoreEmptyChildIterators = ConfigUtils.inheritOverwritableProperty( ignoreEmptyChildIterators, inheritedConfig.getIgnoreEmptyChildIterators()); return this; } @Override public CartesianProductMoveSelectorConfig copyConfig() { return new CartesianProductMoveSelectorConfig().inherit(this); } @Override public void visitReferencedClasses(Consumer<Class<?>> classVisitor) {<FILL_FUNCTION_BODY>} @Override public String toString() { return getClass().getSimpleName() + "(" + moveSelectorConfigList + ")"; } }
visitCommonReferencedClasses(classVisitor); if (moveSelectorConfigList != null) { moveSelectorConfigList.forEach(ms -> ms.visitReferencedClasses(classVisitor)); }
1,461
57
1,518
<methods>public non-sealed void <init>() ,public void extractLeafMoveSelectorConfigsIntoList(List<MoveSelectorConfig#RAW>) ,public org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType getCacheType() ,public Class<? extends SelectionFilter#RAW> getFilterClass() ,public java.lang.Double getFixedProbabilityWeight() ,public Class<? extends SelectionProbabilityWeightFactory#RAW> getProbabilityWeightFactoryClass() ,public java.lang.Long getSelectedCountLimit() ,public org.optaplanner.core.config.heuristic.selector.common.SelectionOrder getSelectionOrder() ,public Class<? extends SelectionSorter#RAW> getSorterClass() ,public Class<? extends Comparator#RAW> getSorterComparatorClass() ,public org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder getSorterOrder() ,public Class<? extends SelectionSorterWeightFactory#RAW> getSorterWeightFactoryClass() ,public org.optaplanner.core.config.heuristic.selector.move.composite.CartesianProductMoveSelectorConfig inherit(org.optaplanner.core.config.heuristic.selector.move.composite.CartesianProductMoveSelectorConfig) ,public void inheritFolded(MoveSelectorConfig<?>) ,public void setCacheType(org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType) ,public void setFilterClass(Class<? extends SelectionFilter#RAW>) ,public void setFixedProbabilityWeight(java.lang.Double) ,public void setProbabilityWeightFactoryClass(Class<? extends SelectionProbabilityWeightFactory#RAW>) ,public void setSelectedCountLimit(java.lang.Long) ,public void setSelectionOrder(org.optaplanner.core.config.heuristic.selector.common.SelectionOrder) ,public void setSorterClass(Class<? extends SelectionSorter#RAW>) ,public void setSorterComparatorClass(Class<? extends Comparator#RAW>) ,public void setSorterOrder(org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder) ,public void setSorterWeightFactoryClass(Class<? extends SelectionSorterWeightFactory#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.composite.CartesianProductMoveSelectorConfig withCacheType(org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType) ,public org.optaplanner.core.config.heuristic.selector.move.composite.CartesianProductMoveSelectorConfig withFilterClass(Class<? extends SelectionFilter#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.composite.CartesianProductMoveSelectorConfig withFixedProbabilityWeight(java.lang.Double) ,public org.optaplanner.core.config.heuristic.selector.move.composite.CartesianProductMoveSelectorConfig withProbabilityWeightFactoryClass(Class<? extends SelectionProbabilityWeightFactory#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.composite.CartesianProductMoveSelectorConfig withSelectedCountLimit(java.lang.Long) ,public org.optaplanner.core.config.heuristic.selector.move.composite.CartesianProductMoveSelectorConfig withSelectionOrder(org.optaplanner.core.config.heuristic.selector.common.SelectionOrder) ,public org.optaplanner.core.config.heuristic.selector.move.composite.CartesianProductMoveSelectorConfig withSorterClass(Class<? extends SelectionSorter#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.composite.CartesianProductMoveSelectorConfig withSorterComparatorClass(Class<? extends Comparator#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.composite.CartesianProductMoveSelectorConfig withSorterOrder(org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder) ,public org.optaplanner.core.config.heuristic.selector.move.composite.CartesianProductMoveSelectorConfig withSorterWeightFactoryClass(Class<? extends SelectionSorterWeightFactory#RAW>) <variables>protected org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType cacheType,protected Class<? extends SelectionFilter#RAW> filterClass,private java.lang.Double fixedProbabilityWeight,protected Class<? extends SelectionProbabilityWeightFactory#RAW> probabilityWeightFactoryClass,protected java.lang.Long selectedCountLimit,protected org.optaplanner.core.config.heuristic.selector.common.SelectionOrder selectionOrder,protected Class<? extends SelectionSorter#RAW> sorterClass,protected Class<? extends Comparator#RAW> sorterComparatorClass,protected org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder sorterOrder,protected Class<? extends SelectionSorterWeightFactory#RAW> sorterWeightFactoryClass
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/config/heuristic/selector/move/factory/MoveIteratorFactoryConfig.java
MoveIteratorFactoryConfig
inherit
class MoveIteratorFactoryConfig extends MoveSelectorConfig<MoveIteratorFactoryConfig> { public static final String XML_ELEMENT_NAME = "moveIteratorFactory"; protected Class<? extends MoveIteratorFactory> moveIteratorFactoryClass = null; @XmlJavaTypeAdapter(JaxbCustomPropertiesAdapter.class) protected Map<String, String> moveIteratorFactoryCustomProperties = null; public Class<? extends MoveIteratorFactory> getMoveIteratorFactoryClass() { return moveIteratorFactoryClass; } public void setMoveIteratorFactoryClass(Class<? extends MoveIteratorFactory> moveIteratorFactoryClass) { this.moveIteratorFactoryClass = moveIteratorFactoryClass; } public Map<String, String> getMoveIteratorFactoryCustomProperties() { return moveIteratorFactoryCustomProperties; } public void setMoveIteratorFactoryCustomProperties(Map<String, String> moveIteratorFactoryCustomProperties) { this.moveIteratorFactoryCustomProperties = moveIteratorFactoryCustomProperties; } // ************************************************************************ // With methods // ************************************************************************ public MoveIteratorFactoryConfig withMoveIteratorFactoryClass(Class<? extends MoveIteratorFactory> moveIteratorFactoryClass) { this.setMoveIteratorFactoryClass(moveIteratorFactoryClass); return this; } public MoveIteratorFactoryConfig withMoveIteratorFactoryCustomProperties(Map<String, String> moveIteratorFactoryCustomProperties) { this.setMoveIteratorFactoryCustomProperties(moveIteratorFactoryCustomProperties); return this; } @Override public MoveIteratorFactoryConfig inherit(MoveIteratorFactoryConfig inheritedConfig) {<FILL_FUNCTION_BODY>} @Override public MoveIteratorFactoryConfig copyConfig() { return new MoveIteratorFactoryConfig().inherit(this); } @Override public void visitReferencedClasses(Consumer<Class<?>> classVisitor) { visitCommonReferencedClasses(classVisitor); classVisitor.accept(moveIteratorFactoryClass); } @Override public String toString() { return getClass().getSimpleName() + "(" + moveIteratorFactoryClass + ")"; } }
super.inherit(inheritedConfig); moveIteratorFactoryClass = ConfigUtils.inheritOverwritableProperty( moveIteratorFactoryClass, inheritedConfig.getMoveIteratorFactoryClass()); moveIteratorFactoryCustomProperties = ConfigUtils.inheritMergeableMapProperty( moveIteratorFactoryCustomProperties, inheritedConfig.getMoveIteratorFactoryCustomProperties()); return this;
525
86
611
<methods>public non-sealed void <init>() ,public void extractLeafMoveSelectorConfigsIntoList(List<MoveSelectorConfig#RAW>) ,public org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType getCacheType() ,public Class<? extends SelectionFilter#RAW> getFilterClass() ,public java.lang.Double getFixedProbabilityWeight() ,public Class<? extends SelectionProbabilityWeightFactory#RAW> getProbabilityWeightFactoryClass() ,public java.lang.Long getSelectedCountLimit() ,public org.optaplanner.core.config.heuristic.selector.common.SelectionOrder getSelectionOrder() ,public Class<? extends SelectionSorter#RAW> getSorterClass() ,public Class<? extends Comparator#RAW> getSorterComparatorClass() ,public org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder getSorterOrder() ,public Class<? extends SelectionSorterWeightFactory#RAW> getSorterWeightFactoryClass() ,public org.optaplanner.core.config.heuristic.selector.move.factory.MoveIteratorFactoryConfig inherit(org.optaplanner.core.config.heuristic.selector.move.factory.MoveIteratorFactoryConfig) ,public void inheritFolded(MoveSelectorConfig<?>) ,public void setCacheType(org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType) ,public void setFilterClass(Class<? extends SelectionFilter#RAW>) ,public void setFixedProbabilityWeight(java.lang.Double) ,public void setProbabilityWeightFactoryClass(Class<? extends SelectionProbabilityWeightFactory#RAW>) ,public void setSelectedCountLimit(java.lang.Long) ,public void setSelectionOrder(org.optaplanner.core.config.heuristic.selector.common.SelectionOrder) ,public void setSorterClass(Class<? extends SelectionSorter#RAW>) ,public void setSorterComparatorClass(Class<? extends Comparator#RAW>) ,public void setSorterOrder(org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder) ,public void setSorterWeightFactoryClass(Class<? extends SelectionSorterWeightFactory#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.factory.MoveIteratorFactoryConfig withCacheType(org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType) ,public org.optaplanner.core.config.heuristic.selector.move.factory.MoveIteratorFactoryConfig withFilterClass(Class<? extends SelectionFilter#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.factory.MoveIteratorFactoryConfig withFixedProbabilityWeight(java.lang.Double) ,public org.optaplanner.core.config.heuristic.selector.move.factory.MoveIteratorFactoryConfig withProbabilityWeightFactoryClass(Class<? extends SelectionProbabilityWeightFactory#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.factory.MoveIteratorFactoryConfig withSelectedCountLimit(java.lang.Long) ,public org.optaplanner.core.config.heuristic.selector.move.factory.MoveIteratorFactoryConfig withSelectionOrder(org.optaplanner.core.config.heuristic.selector.common.SelectionOrder) ,public org.optaplanner.core.config.heuristic.selector.move.factory.MoveIteratorFactoryConfig withSorterClass(Class<? extends SelectionSorter#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.factory.MoveIteratorFactoryConfig withSorterComparatorClass(Class<? extends Comparator#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.factory.MoveIteratorFactoryConfig withSorterOrder(org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder) ,public org.optaplanner.core.config.heuristic.selector.move.factory.MoveIteratorFactoryConfig withSorterWeightFactoryClass(Class<? extends SelectionSorterWeightFactory#RAW>) <variables>protected org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType cacheType,protected Class<? extends SelectionFilter#RAW> filterClass,private java.lang.Double fixedProbabilityWeight,protected Class<? extends SelectionProbabilityWeightFactory#RAW> probabilityWeightFactoryClass,protected java.lang.Long selectedCountLimit,protected org.optaplanner.core.config.heuristic.selector.common.SelectionOrder selectionOrder,protected Class<? extends SelectionSorter#RAW> sorterClass,protected Class<? extends Comparator#RAW> sorterComparatorClass,protected org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder sorterOrder,protected Class<? extends SelectionSorterWeightFactory#RAW> sorterWeightFactoryClass
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/config/heuristic/selector/move/factory/MoveListFactoryConfig.java
MoveListFactoryConfig
inherit
class MoveListFactoryConfig extends MoveSelectorConfig<MoveListFactoryConfig> { public static final String XML_ELEMENT_NAME = "moveListFactory"; protected Class<? extends MoveListFactory> moveListFactoryClass = null; @XmlJavaTypeAdapter(JaxbCustomPropertiesAdapter.class) protected Map<String, String> moveListFactoryCustomProperties = null; public Class<? extends MoveListFactory> getMoveListFactoryClass() { return moveListFactoryClass; } public void setMoveListFactoryClass(Class<? extends MoveListFactory> moveListFactoryClass) { this.moveListFactoryClass = moveListFactoryClass; } public Map<String, String> getMoveListFactoryCustomProperties() { return moveListFactoryCustomProperties; } public void setMoveListFactoryCustomProperties(Map<String, String> moveListFactoryCustomProperties) { this.moveListFactoryCustomProperties = moveListFactoryCustomProperties; } // ************************************************************************ // With methods // ************************************************************************ public MoveListFactoryConfig withMoveListFactoryClass(Class<? extends MoveListFactory> moveListFactoryClass) { this.setMoveListFactoryClass(moveListFactoryClass); return this; } public MoveListFactoryConfig withMoveListFactoryCustomProperties(Map<String, String> moveListFactoryCustomProperties) { this.setMoveListFactoryCustomProperties(moveListFactoryCustomProperties); return this; } // ************************************************************************ // Builder methods // ************************************************************************ @Override public MoveListFactoryConfig inherit(MoveListFactoryConfig inheritedConfig) {<FILL_FUNCTION_BODY>} @Override public MoveListFactoryConfig copyConfig() { return new MoveListFactoryConfig().inherit(this); } @Override public void visitReferencedClasses(Consumer<Class<?>> classVisitor) { visitCommonReferencedClasses(classVisitor); classVisitor.accept(moveListFactoryClass); } @Override public String toString() { return getClass().getSimpleName() + "(" + moveListFactoryClass + ")"; } }
super.inherit(inheritedConfig); moveListFactoryClass = ConfigUtils.inheritOverwritableProperty( moveListFactoryClass, inheritedConfig.getMoveListFactoryClass()); moveListFactoryCustomProperties = ConfigUtils.inheritMergeableMapProperty( moveListFactoryCustomProperties, inheritedConfig.getMoveListFactoryCustomProperties()); return this;
541
86
627
<methods>public non-sealed void <init>() ,public void extractLeafMoveSelectorConfigsIntoList(List<MoveSelectorConfig#RAW>) ,public org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType getCacheType() ,public Class<? extends SelectionFilter#RAW> getFilterClass() ,public java.lang.Double getFixedProbabilityWeight() ,public Class<? extends SelectionProbabilityWeightFactory#RAW> getProbabilityWeightFactoryClass() ,public java.lang.Long getSelectedCountLimit() ,public org.optaplanner.core.config.heuristic.selector.common.SelectionOrder getSelectionOrder() ,public Class<? extends SelectionSorter#RAW> getSorterClass() ,public Class<? extends Comparator#RAW> getSorterComparatorClass() ,public org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder getSorterOrder() ,public Class<? extends SelectionSorterWeightFactory#RAW> getSorterWeightFactoryClass() ,public org.optaplanner.core.config.heuristic.selector.move.factory.MoveListFactoryConfig inherit(org.optaplanner.core.config.heuristic.selector.move.factory.MoveListFactoryConfig) ,public void inheritFolded(MoveSelectorConfig<?>) ,public void setCacheType(org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType) ,public void setFilterClass(Class<? extends SelectionFilter#RAW>) ,public void setFixedProbabilityWeight(java.lang.Double) ,public void setProbabilityWeightFactoryClass(Class<? extends SelectionProbabilityWeightFactory#RAW>) ,public void setSelectedCountLimit(java.lang.Long) ,public void setSelectionOrder(org.optaplanner.core.config.heuristic.selector.common.SelectionOrder) ,public void setSorterClass(Class<? extends SelectionSorter#RAW>) ,public void setSorterComparatorClass(Class<? extends Comparator#RAW>) ,public void setSorterOrder(org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder) ,public void setSorterWeightFactoryClass(Class<? extends SelectionSorterWeightFactory#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.factory.MoveListFactoryConfig withCacheType(org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType) ,public org.optaplanner.core.config.heuristic.selector.move.factory.MoveListFactoryConfig withFilterClass(Class<? extends SelectionFilter#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.factory.MoveListFactoryConfig withFixedProbabilityWeight(java.lang.Double) ,public org.optaplanner.core.config.heuristic.selector.move.factory.MoveListFactoryConfig withProbabilityWeightFactoryClass(Class<? extends SelectionProbabilityWeightFactory#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.factory.MoveListFactoryConfig withSelectedCountLimit(java.lang.Long) ,public org.optaplanner.core.config.heuristic.selector.move.factory.MoveListFactoryConfig withSelectionOrder(org.optaplanner.core.config.heuristic.selector.common.SelectionOrder) ,public org.optaplanner.core.config.heuristic.selector.move.factory.MoveListFactoryConfig withSorterClass(Class<? extends SelectionSorter#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.factory.MoveListFactoryConfig withSorterComparatorClass(Class<? extends Comparator#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.factory.MoveListFactoryConfig withSorterOrder(org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder) ,public org.optaplanner.core.config.heuristic.selector.move.factory.MoveListFactoryConfig withSorterWeightFactoryClass(Class<? extends SelectionSorterWeightFactory#RAW>) <variables>protected org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType cacheType,protected Class<? extends SelectionFilter#RAW> filterClass,private java.lang.Double fixedProbabilityWeight,protected Class<? extends SelectionProbabilityWeightFactory#RAW> probabilityWeightFactoryClass,protected java.lang.Long selectedCountLimit,protected org.optaplanner.core.config.heuristic.selector.common.SelectionOrder selectionOrder,protected Class<? extends SelectionSorter#RAW> sorterClass,protected Class<? extends Comparator#RAW> sorterComparatorClass,protected org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder sorterOrder,protected Class<? extends SelectionSorterWeightFactory#RAW> sorterWeightFactoryClass
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/config/heuristic/selector/move/generic/PillarChangeMoveSelectorConfig.java
PillarChangeMoveSelectorConfig
toString
class PillarChangeMoveSelectorConfig extends AbstractPillarMoveSelectorConfig<PillarChangeMoveSelectorConfig> { public static final String XML_ELEMENT_NAME = "pillarChangeMoveSelector"; @XmlElement(name = "valueSelector") private ValueSelectorConfig valueSelectorConfig = null; public ValueSelectorConfig getValueSelectorConfig() { return valueSelectorConfig; } public void setValueSelectorConfig(ValueSelectorConfig valueSelectorConfig) { this.valueSelectorConfig = valueSelectorConfig; } // ************************************************************************ // With methods // ************************************************************************ public PillarChangeMoveSelectorConfig withValueSelectorConfig(ValueSelectorConfig valueSelectorConfig) { this.setValueSelectorConfig(valueSelectorConfig); return this; } @Override public PillarChangeMoveSelectorConfig inherit(PillarChangeMoveSelectorConfig inheritedConfig) { super.inherit(inheritedConfig); valueSelectorConfig = ConfigUtils.inheritConfig(valueSelectorConfig, inheritedConfig.getValueSelectorConfig()); return this; } @Override public PillarChangeMoveSelectorConfig copyConfig() { return new PillarChangeMoveSelectorConfig().inherit(this); } @Override public void visitReferencedClasses(Consumer<Class<?>> classVisitor) { visitCommonReferencedClasses(classVisitor); if (valueSelectorConfig != null) { valueSelectorConfig.visitReferencedClasses(classVisitor); } } @Override public String toString() {<FILL_FUNCTION_BODY>} }
return getClass().getSimpleName() + "(" + pillarSelectorConfig + ", " + valueSelectorConfig + ")";
404
31
435
<methods>public non-sealed void <init>() ,public org.optaplanner.core.config.heuristic.selector.entity.pillar.PillarSelectorConfig getPillarSelectorConfig() ,public Class<? extends Comparator#RAW> getSubPillarSequenceComparatorClass() ,public org.optaplanner.core.config.heuristic.selector.move.generic.SubPillarType getSubPillarType() ,public org.optaplanner.core.config.heuristic.selector.move.generic.PillarChangeMoveSelectorConfig inherit(org.optaplanner.core.config.heuristic.selector.move.generic.PillarChangeMoveSelectorConfig) ,public void setPillarSelectorConfig(org.optaplanner.core.config.heuristic.selector.entity.pillar.PillarSelectorConfig) ,public void setSubPillarSequenceComparatorClass(Class<? extends Comparator#RAW>) ,public void setSubPillarType(org.optaplanner.core.config.heuristic.selector.move.generic.SubPillarType) ,public org.optaplanner.core.config.heuristic.selector.move.generic.PillarChangeMoveSelectorConfig withPillarSelectorConfig(org.optaplanner.core.config.heuristic.selector.entity.pillar.PillarSelectorConfig) ,public org.optaplanner.core.config.heuristic.selector.move.generic.PillarChangeMoveSelectorConfig withSubPillarSequenceComparatorClass(Class<? extends Comparator#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.PillarChangeMoveSelectorConfig withSubPillarType(org.optaplanner.core.config.heuristic.selector.move.generic.SubPillarType) <variables>protected org.optaplanner.core.config.heuristic.selector.entity.pillar.PillarSelectorConfig pillarSelectorConfig,protected Class<? extends Comparator#RAW> subPillarSequenceComparatorClass,protected org.optaplanner.core.config.heuristic.selector.move.generic.SubPillarType subPillarType
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/config/heuristic/selector/move/generic/PillarSwapMoveSelectorConfig.java
PillarSwapMoveSelectorConfig
toString
class PillarSwapMoveSelectorConfig extends AbstractPillarMoveSelectorConfig<PillarSwapMoveSelectorConfig> { public static final String XML_ELEMENT_NAME = "pillarSwapMoveSelector"; @XmlElement(name = "secondaryPillarSelector") private PillarSelectorConfig secondaryPillarSelectorConfig = null; @XmlElementWrapper(name = "variableNameIncludes") @XmlElement(name = "variableNameInclude") private List<String> variableNameIncludeList = null; public PillarSelectorConfig getSecondaryPillarSelectorConfig() { return secondaryPillarSelectorConfig; } public void setSecondaryPillarSelectorConfig(PillarSelectorConfig secondaryPillarSelectorConfig) { this.secondaryPillarSelectorConfig = secondaryPillarSelectorConfig; } public List<String> getVariableNameIncludeList() { return variableNameIncludeList; } public void setVariableNameIncludeList(List<String> variableNameIncludeList) { this.variableNameIncludeList = variableNameIncludeList; } // ************************************************************************ // With methods // ************************************************************************ public PillarSwapMoveSelectorConfig withSecondaryPillarSelectorConfig(PillarSelectorConfig pillarSelectorConfig) { this.setSecondaryPillarSelectorConfig(pillarSelectorConfig); return this; } public PillarSwapMoveSelectorConfig withVariableNameIncludeList(List<String> variableNameIncludeList) { this.setVariableNameIncludeList(variableNameIncludeList); return this; } public PillarSwapMoveSelectorConfig withVariableNameIncludes(String... variableNameIncludes) { this.setVariableNameIncludeList(List.of(variableNameIncludes)); return this; } @Override public PillarSwapMoveSelectorConfig inherit(PillarSwapMoveSelectorConfig inheritedConfig) { super.inherit(inheritedConfig); secondaryPillarSelectorConfig = ConfigUtils.inheritConfig(secondaryPillarSelectorConfig, inheritedConfig.getSecondaryPillarSelectorConfig()); variableNameIncludeList = ConfigUtils.inheritMergeableListProperty( variableNameIncludeList, inheritedConfig.getVariableNameIncludeList()); return this; } @Override public PillarSwapMoveSelectorConfig copyConfig() { return new PillarSwapMoveSelectorConfig().inherit(this); } @Override public void visitReferencedClasses(Consumer<Class<?>> classVisitor) { visitCommonReferencedClasses(classVisitor); if (secondaryPillarSelectorConfig != null) { secondaryPillarSelectorConfig.visitReferencedClasses(classVisitor); } } @Override public String toString() {<FILL_FUNCTION_BODY>} }
return getClass().getSimpleName() + "(" + pillarSelectorConfig + (secondaryPillarSelectorConfig == null ? "" : ", " + secondaryPillarSelectorConfig) + ")";
736
49
785
<methods>public non-sealed void <init>() ,public org.optaplanner.core.config.heuristic.selector.entity.pillar.PillarSelectorConfig getPillarSelectorConfig() ,public Class<? extends Comparator#RAW> getSubPillarSequenceComparatorClass() ,public org.optaplanner.core.config.heuristic.selector.move.generic.SubPillarType getSubPillarType() ,public org.optaplanner.core.config.heuristic.selector.move.generic.PillarSwapMoveSelectorConfig inherit(org.optaplanner.core.config.heuristic.selector.move.generic.PillarSwapMoveSelectorConfig) ,public void setPillarSelectorConfig(org.optaplanner.core.config.heuristic.selector.entity.pillar.PillarSelectorConfig) ,public void setSubPillarSequenceComparatorClass(Class<? extends Comparator#RAW>) ,public void setSubPillarType(org.optaplanner.core.config.heuristic.selector.move.generic.SubPillarType) ,public org.optaplanner.core.config.heuristic.selector.move.generic.PillarSwapMoveSelectorConfig withPillarSelectorConfig(org.optaplanner.core.config.heuristic.selector.entity.pillar.PillarSelectorConfig) ,public org.optaplanner.core.config.heuristic.selector.move.generic.PillarSwapMoveSelectorConfig withSubPillarSequenceComparatorClass(Class<? extends Comparator#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.PillarSwapMoveSelectorConfig withSubPillarType(org.optaplanner.core.config.heuristic.selector.move.generic.SubPillarType) <variables>protected org.optaplanner.core.config.heuristic.selector.entity.pillar.PillarSelectorConfig pillarSelectorConfig,protected Class<? extends Comparator#RAW> subPillarSequenceComparatorClass,protected org.optaplanner.core.config.heuristic.selector.move.generic.SubPillarType subPillarType
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/config/heuristic/selector/move/generic/chained/KOptMoveSelectorConfig.java
KOptMoveSelectorConfig
inherit
class KOptMoveSelectorConfig extends MoveSelectorConfig<KOptMoveSelectorConfig> { public static final String XML_ELEMENT_NAME = "kOptMoveSelector"; @XmlElement(name = "entitySelector") private EntitySelectorConfig entitySelectorConfig = null; /** * Like {@link TailChainSwapMoveSelectorConfig#valueSelectorConfig} but used multiple times to create 1 move. */ @XmlElement(name = "valueSelector") private ValueSelectorConfig valueSelectorConfig = null; public EntitySelectorConfig getEntitySelectorConfig() { return entitySelectorConfig; } public void setEntitySelectorConfig(EntitySelectorConfig entitySelectorConfig) { this.entitySelectorConfig = entitySelectorConfig; } public ValueSelectorConfig getValueSelectorConfig() { return valueSelectorConfig; } public void setValueSelectorConfig(ValueSelectorConfig valueSelectorConfig) { this.valueSelectorConfig = valueSelectorConfig; } // ************************************************************************ // With methods // ************************************************************************ public KOptMoveSelectorConfig withEntitySelectorConfig(EntitySelectorConfig entitySelectorConfig) { this.setEntitySelectorConfig(entitySelectorConfig); return this; } public KOptMoveSelectorConfig withValueSelectorConfig(ValueSelectorConfig valueSelectorConfig) { this.setValueSelectorConfig(valueSelectorConfig); return this; } @Override public KOptMoveSelectorConfig inherit(KOptMoveSelectorConfig inheritedConfig) {<FILL_FUNCTION_BODY>} @Override public KOptMoveSelectorConfig copyConfig() { return new KOptMoveSelectorConfig().inherit(this); } @Override public void visitReferencedClasses(Consumer<Class<?>> classVisitor) { visitCommonReferencedClasses(classVisitor); if (entitySelectorConfig != null) { entitySelectorConfig.visitReferencedClasses(classVisitor); } if (valueSelectorConfig != null) { valueSelectorConfig.visitReferencedClasses(classVisitor); } } @Override public String toString() { return getClass().getSimpleName() + "(" + entitySelectorConfig + ", " + valueSelectorConfig + ")"; } }
super.inherit(inheritedConfig); entitySelectorConfig = ConfigUtils.inheritConfig(entitySelectorConfig, inheritedConfig.getEntitySelectorConfig()); valueSelectorConfig = ConfigUtils.inheritConfig(valueSelectorConfig, inheritedConfig.getValueSelectorConfig()); return this;
565
65
630
<methods>public non-sealed void <init>() ,public void extractLeafMoveSelectorConfigsIntoList(List<MoveSelectorConfig#RAW>) ,public org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType getCacheType() ,public Class<? extends SelectionFilter#RAW> getFilterClass() ,public java.lang.Double getFixedProbabilityWeight() ,public Class<? extends SelectionProbabilityWeightFactory#RAW> getProbabilityWeightFactoryClass() ,public java.lang.Long getSelectedCountLimit() ,public org.optaplanner.core.config.heuristic.selector.common.SelectionOrder getSelectionOrder() ,public Class<? extends SelectionSorter#RAW> getSorterClass() ,public Class<? extends Comparator#RAW> getSorterComparatorClass() ,public org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder getSorterOrder() ,public Class<? extends SelectionSorterWeightFactory#RAW> getSorterWeightFactoryClass() ,public org.optaplanner.core.config.heuristic.selector.move.generic.chained.KOptMoveSelectorConfig inherit(org.optaplanner.core.config.heuristic.selector.move.generic.chained.KOptMoveSelectorConfig) ,public void inheritFolded(MoveSelectorConfig<?>) ,public void setCacheType(org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType) ,public void setFilterClass(Class<? extends SelectionFilter#RAW>) ,public void setFixedProbabilityWeight(java.lang.Double) ,public void setProbabilityWeightFactoryClass(Class<? extends SelectionProbabilityWeightFactory#RAW>) ,public void setSelectedCountLimit(java.lang.Long) ,public void setSelectionOrder(org.optaplanner.core.config.heuristic.selector.common.SelectionOrder) ,public void setSorterClass(Class<? extends SelectionSorter#RAW>) ,public void setSorterComparatorClass(Class<? extends Comparator#RAW>) ,public void setSorterOrder(org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder) ,public void setSorterWeightFactoryClass(Class<? extends SelectionSorterWeightFactory#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.chained.KOptMoveSelectorConfig withCacheType(org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType) ,public org.optaplanner.core.config.heuristic.selector.move.generic.chained.KOptMoveSelectorConfig withFilterClass(Class<? extends SelectionFilter#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.chained.KOptMoveSelectorConfig withFixedProbabilityWeight(java.lang.Double) ,public org.optaplanner.core.config.heuristic.selector.move.generic.chained.KOptMoveSelectorConfig withProbabilityWeightFactoryClass(Class<? extends SelectionProbabilityWeightFactory#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.chained.KOptMoveSelectorConfig withSelectedCountLimit(java.lang.Long) ,public org.optaplanner.core.config.heuristic.selector.move.generic.chained.KOptMoveSelectorConfig withSelectionOrder(org.optaplanner.core.config.heuristic.selector.common.SelectionOrder) ,public org.optaplanner.core.config.heuristic.selector.move.generic.chained.KOptMoveSelectorConfig withSorterClass(Class<? extends SelectionSorter#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.chained.KOptMoveSelectorConfig withSorterComparatorClass(Class<? extends Comparator#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.chained.KOptMoveSelectorConfig withSorterOrder(org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder) ,public org.optaplanner.core.config.heuristic.selector.move.generic.chained.KOptMoveSelectorConfig withSorterWeightFactoryClass(Class<? extends SelectionSorterWeightFactory#RAW>) <variables>protected org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType cacheType,protected Class<? extends SelectionFilter#RAW> filterClass,private java.lang.Double fixedProbabilityWeight,protected Class<? extends SelectionProbabilityWeightFactory#RAW> probabilityWeightFactoryClass,protected java.lang.Long selectedCountLimit,protected org.optaplanner.core.config.heuristic.selector.common.SelectionOrder selectionOrder,protected Class<? extends SelectionSorter#RAW> sorterClass,protected Class<? extends Comparator#RAW> sorterComparatorClass,protected org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder sorterOrder,protected Class<? extends SelectionSorterWeightFactory#RAW> sorterWeightFactoryClass
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/config/heuristic/selector/move/generic/chained/SubChainSwapMoveSelectorConfig.java
SubChainSwapMoveSelectorConfig
inherit
class SubChainSwapMoveSelectorConfig extends MoveSelectorConfig<SubChainSwapMoveSelectorConfig> { public static final String XML_ELEMENT_NAME = "subChainSwapMoveSelector"; private Class<?> entityClass = null; @XmlElement(name = "subChainSelector") private SubChainSelectorConfig subChainSelectorConfig = null; @XmlElement(name = "secondarySubChainSelector") private SubChainSelectorConfig secondarySubChainSelectorConfig = null; private Boolean selectReversingMoveToo = null; public Class<?> getEntityClass() { return entityClass; } public void setEntityClass(Class<?> entityClass) { this.entityClass = entityClass; } public SubChainSelectorConfig getSubChainSelectorConfig() { return subChainSelectorConfig; } public void setSubChainSelectorConfig(SubChainSelectorConfig subChainSelectorConfig) { this.subChainSelectorConfig = subChainSelectorConfig; } public SubChainSelectorConfig getSecondarySubChainSelectorConfig() { return secondarySubChainSelectorConfig; } public void setSecondarySubChainSelectorConfig(SubChainSelectorConfig secondarySubChainSelectorConfig) { this.secondarySubChainSelectorConfig = secondarySubChainSelectorConfig; } public Boolean getSelectReversingMoveToo() { return selectReversingMoveToo; } public void setSelectReversingMoveToo(Boolean selectReversingMoveToo) { this.selectReversingMoveToo = selectReversingMoveToo; } // ************************************************************************ // With methods // ************************************************************************ public SubChainSwapMoveSelectorConfig withEntityClass(Class<?> entityClass) { this.setEntityClass(entityClass); return this; } public SubChainSwapMoveSelectorConfig withSubChainSelectorConfig(SubChainSelectorConfig subChainSelectorConfig) { this.setSubChainSelectorConfig(subChainSelectorConfig); return this; } public SubChainSwapMoveSelectorConfig withSecondarySubChainSelectorConfig(SubChainSelectorConfig secondarySubChainSelectorConfig) { this.setSecondarySubChainSelectorConfig(secondarySubChainSelectorConfig); return this; } public SubChainSwapMoveSelectorConfig withSelectReversingMoveToo(Boolean selectReversingMoveToo) { this.setSelectReversingMoveToo(selectReversingMoveToo); return this; } @Override public SubChainSwapMoveSelectorConfig inherit(SubChainSwapMoveSelectorConfig inheritedConfig) {<FILL_FUNCTION_BODY>} @Override public SubChainSwapMoveSelectorConfig copyConfig() { return new SubChainSwapMoveSelectorConfig().inherit(this); } @Override public void visitReferencedClasses(Consumer<Class<?>> classVisitor) { visitCommonReferencedClasses(classVisitor); classVisitor.accept(entityClass); if (subChainSelectorConfig != null) { subChainSelectorConfig.visitReferencedClasses(classVisitor); } if (secondarySubChainSelectorConfig != null) { secondarySubChainSelectorConfig.visitReferencedClasses(classVisitor); } } @Override public String toString() { return getClass().getSimpleName() + "(" + subChainSelectorConfig + (secondarySubChainSelectorConfig == null ? "" : ", " + secondarySubChainSelectorConfig) + ")"; } }
super.inherit(inheritedConfig); entityClass = ConfigUtils.inheritOverwritableProperty(entityClass, inheritedConfig.getEntityClass()); subChainSelectorConfig = ConfigUtils.inheritConfig(subChainSelectorConfig, inheritedConfig.getSubChainSelectorConfig()); secondarySubChainSelectorConfig = ConfigUtils.inheritConfig(secondarySubChainSelectorConfig, inheritedConfig.getSecondarySubChainSelectorConfig()); selectReversingMoveToo = ConfigUtils.inheritOverwritableProperty(selectReversingMoveToo, inheritedConfig.getSelectReversingMoveToo()); return this;
886
143
1,029
<methods>public non-sealed void <init>() ,public void extractLeafMoveSelectorConfigsIntoList(List<MoveSelectorConfig#RAW>) ,public org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType getCacheType() ,public Class<? extends SelectionFilter#RAW> getFilterClass() ,public java.lang.Double getFixedProbabilityWeight() ,public Class<? extends SelectionProbabilityWeightFactory#RAW> getProbabilityWeightFactoryClass() ,public java.lang.Long getSelectedCountLimit() ,public org.optaplanner.core.config.heuristic.selector.common.SelectionOrder getSelectionOrder() ,public Class<? extends SelectionSorter#RAW> getSorterClass() ,public Class<? extends Comparator#RAW> getSorterComparatorClass() ,public org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder getSorterOrder() ,public Class<? extends SelectionSorterWeightFactory#RAW> getSorterWeightFactoryClass() ,public org.optaplanner.core.config.heuristic.selector.move.generic.chained.SubChainSwapMoveSelectorConfig inherit(org.optaplanner.core.config.heuristic.selector.move.generic.chained.SubChainSwapMoveSelectorConfig) ,public void inheritFolded(MoveSelectorConfig<?>) ,public void setCacheType(org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType) ,public void setFilterClass(Class<? extends SelectionFilter#RAW>) ,public void setFixedProbabilityWeight(java.lang.Double) ,public void setProbabilityWeightFactoryClass(Class<? extends SelectionProbabilityWeightFactory#RAW>) ,public void setSelectedCountLimit(java.lang.Long) ,public void setSelectionOrder(org.optaplanner.core.config.heuristic.selector.common.SelectionOrder) ,public void setSorterClass(Class<? extends SelectionSorter#RAW>) ,public void setSorterComparatorClass(Class<? extends Comparator#RAW>) ,public void setSorterOrder(org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder) ,public void setSorterWeightFactoryClass(Class<? extends SelectionSorterWeightFactory#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.chained.SubChainSwapMoveSelectorConfig withCacheType(org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType) ,public org.optaplanner.core.config.heuristic.selector.move.generic.chained.SubChainSwapMoveSelectorConfig withFilterClass(Class<? extends SelectionFilter#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.chained.SubChainSwapMoveSelectorConfig withFixedProbabilityWeight(java.lang.Double) ,public org.optaplanner.core.config.heuristic.selector.move.generic.chained.SubChainSwapMoveSelectorConfig withProbabilityWeightFactoryClass(Class<? extends SelectionProbabilityWeightFactory#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.chained.SubChainSwapMoveSelectorConfig withSelectedCountLimit(java.lang.Long) ,public org.optaplanner.core.config.heuristic.selector.move.generic.chained.SubChainSwapMoveSelectorConfig withSelectionOrder(org.optaplanner.core.config.heuristic.selector.common.SelectionOrder) ,public org.optaplanner.core.config.heuristic.selector.move.generic.chained.SubChainSwapMoveSelectorConfig withSorterClass(Class<? extends SelectionSorter#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.chained.SubChainSwapMoveSelectorConfig withSorterComparatorClass(Class<? extends Comparator#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.chained.SubChainSwapMoveSelectorConfig withSorterOrder(org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder) ,public org.optaplanner.core.config.heuristic.selector.move.generic.chained.SubChainSwapMoveSelectorConfig withSorterWeightFactoryClass(Class<? extends SelectionSorterWeightFactory#RAW>) <variables>protected org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType cacheType,protected Class<? extends SelectionFilter#RAW> filterClass,private java.lang.Double fixedProbabilityWeight,protected Class<? extends SelectionProbabilityWeightFactory#RAW> probabilityWeightFactoryClass,protected java.lang.Long selectedCountLimit,protected org.optaplanner.core.config.heuristic.selector.common.SelectionOrder selectionOrder,protected Class<? extends SelectionSorter#RAW> sorterClass,protected Class<? extends Comparator#RAW> sorterComparatorClass,protected org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder sorterOrder,protected Class<? extends SelectionSorterWeightFactory#RAW> sorterWeightFactoryClass
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/config/heuristic/selector/move/generic/chained/TailChainSwapMoveSelectorConfig.java
TailChainSwapMoveSelectorConfig
toString
class TailChainSwapMoveSelectorConfig extends MoveSelectorConfig<TailChainSwapMoveSelectorConfig> { public static final String XML_ELEMENT_NAME = "tailChainSwapMoveSelector"; @XmlElement(name = "entitySelector") private EntitySelectorConfig entitySelectorConfig = null; /** * Uses a valueSelector instead of a secondaryEntitySelector because * the secondary entity might not exist if the value is a buoy (= the last entity in a chain) * and also because with nearby selection, it's more important that the value is near (instead of the secondary entity). */ @XmlElement(name = "valueSelector") private ValueSelectorConfig valueSelectorConfig = null; public EntitySelectorConfig getEntitySelectorConfig() { return entitySelectorConfig; } public void setEntitySelectorConfig(EntitySelectorConfig entitySelectorConfig) { this.entitySelectorConfig = entitySelectorConfig; } public ValueSelectorConfig getValueSelectorConfig() { return valueSelectorConfig; } public void setValueSelectorConfig(ValueSelectorConfig valueSelectorConfig) { this.valueSelectorConfig = valueSelectorConfig; } // ************************************************************************ // With methods // ************************************************************************ public TailChainSwapMoveSelectorConfig withEntitySelectorConfig(EntitySelectorConfig entitySelectorConfig) { this.entitySelectorConfig = entitySelectorConfig; return this; } public TailChainSwapMoveSelectorConfig withValueSelectorConfig(ValueSelectorConfig valueSelectorConfig) { this.valueSelectorConfig = valueSelectorConfig; return this; } @Override public TailChainSwapMoveSelectorConfig inherit(TailChainSwapMoveSelectorConfig inheritedConfig) { super.inherit(inheritedConfig); entitySelectorConfig = ConfigUtils.inheritConfig(entitySelectorConfig, inheritedConfig.getEntitySelectorConfig()); valueSelectorConfig = ConfigUtils.inheritConfig(valueSelectorConfig, inheritedConfig.getValueSelectorConfig()); return this; } @Override public TailChainSwapMoveSelectorConfig copyConfig() { return new TailChainSwapMoveSelectorConfig().inherit(this); } @Override public void visitReferencedClasses(Consumer<Class<?>> classVisitor) { visitCommonReferencedClasses(classVisitor); if (entitySelectorConfig != null) { entitySelectorConfig.visitReferencedClasses(classVisitor); } if (valueSelectorConfig != null) { valueSelectorConfig.visitReferencedClasses(classVisitor); } } @Override public String toString() {<FILL_FUNCTION_BODY>} }
return getClass().getSimpleName() + "(" + entitySelectorConfig + ", " + valueSelectorConfig + ")";
662
30
692
<methods>public non-sealed void <init>() ,public void extractLeafMoveSelectorConfigsIntoList(List<MoveSelectorConfig#RAW>) ,public org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType getCacheType() ,public Class<? extends SelectionFilter#RAW> getFilterClass() ,public java.lang.Double getFixedProbabilityWeight() ,public Class<? extends SelectionProbabilityWeightFactory#RAW> getProbabilityWeightFactoryClass() ,public java.lang.Long getSelectedCountLimit() ,public org.optaplanner.core.config.heuristic.selector.common.SelectionOrder getSelectionOrder() ,public Class<? extends SelectionSorter#RAW> getSorterClass() ,public Class<? extends Comparator#RAW> getSorterComparatorClass() ,public org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder getSorterOrder() ,public Class<? extends SelectionSorterWeightFactory#RAW> getSorterWeightFactoryClass() ,public org.optaplanner.core.config.heuristic.selector.move.generic.chained.TailChainSwapMoveSelectorConfig inherit(org.optaplanner.core.config.heuristic.selector.move.generic.chained.TailChainSwapMoveSelectorConfig) ,public void inheritFolded(MoveSelectorConfig<?>) ,public void setCacheType(org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType) ,public void setFilterClass(Class<? extends SelectionFilter#RAW>) ,public void setFixedProbabilityWeight(java.lang.Double) ,public void setProbabilityWeightFactoryClass(Class<? extends SelectionProbabilityWeightFactory#RAW>) ,public void setSelectedCountLimit(java.lang.Long) ,public void setSelectionOrder(org.optaplanner.core.config.heuristic.selector.common.SelectionOrder) ,public void setSorterClass(Class<? extends SelectionSorter#RAW>) ,public void setSorterComparatorClass(Class<? extends Comparator#RAW>) ,public void setSorterOrder(org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder) ,public void setSorterWeightFactoryClass(Class<? extends SelectionSorterWeightFactory#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.chained.TailChainSwapMoveSelectorConfig withCacheType(org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType) ,public org.optaplanner.core.config.heuristic.selector.move.generic.chained.TailChainSwapMoveSelectorConfig withFilterClass(Class<? extends SelectionFilter#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.chained.TailChainSwapMoveSelectorConfig withFixedProbabilityWeight(java.lang.Double) ,public org.optaplanner.core.config.heuristic.selector.move.generic.chained.TailChainSwapMoveSelectorConfig withProbabilityWeightFactoryClass(Class<? extends SelectionProbabilityWeightFactory#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.chained.TailChainSwapMoveSelectorConfig withSelectedCountLimit(java.lang.Long) ,public org.optaplanner.core.config.heuristic.selector.move.generic.chained.TailChainSwapMoveSelectorConfig withSelectionOrder(org.optaplanner.core.config.heuristic.selector.common.SelectionOrder) ,public org.optaplanner.core.config.heuristic.selector.move.generic.chained.TailChainSwapMoveSelectorConfig withSorterClass(Class<? extends SelectionSorter#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.chained.TailChainSwapMoveSelectorConfig withSorterComparatorClass(Class<? extends Comparator#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.chained.TailChainSwapMoveSelectorConfig withSorterOrder(org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder) ,public org.optaplanner.core.config.heuristic.selector.move.generic.chained.TailChainSwapMoveSelectorConfig withSorterWeightFactoryClass(Class<? extends SelectionSorterWeightFactory#RAW>) <variables>protected org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType cacheType,protected Class<? extends SelectionFilter#RAW> filterClass,private java.lang.Double fixedProbabilityWeight,protected Class<? extends SelectionProbabilityWeightFactory#RAW> probabilityWeightFactoryClass,protected java.lang.Long selectedCountLimit,protected org.optaplanner.core.config.heuristic.selector.common.SelectionOrder selectionOrder,protected Class<? extends SelectionSorter#RAW> sorterClass,protected Class<? extends Comparator#RAW> sorterComparatorClass,protected org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder sorterOrder,protected Class<? extends SelectionSorterWeightFactory#RAW> sorterWeightFactoryClass
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/config/heuristic/selector/move/generic/list/ListChangeMoveSelectorConfig.java
ListChangeMoveSelectorConfig
inherit
class ListChangeMoveSelectorConfig extends MoveSelectorConfig<ListChangeMoveSelectorConfig> { public static final String XML_ELEMENT_NAME = "listChangeMoveSelector"; @XmlElement(name = "valueSelector") private ValueSelectorConfig valueSelectorConfig = null; @XmlElement(name = "destinationSelector") private DestinationSelectorConfig destinationSelectorConfig = null; public ValueSelectorConfig getValueSelectorConfig() { return valueSelectorConfig; } public void setValueSelectorConfig(ValueSelectorConfig valueSelectorConfig) { this.valueSelectorConfig = valueSelectorConfig; } public DestinationSelectorConfig getDestinationSelectorConfig() { return destinationSelectorConfig; } public void setDestinationSelectorConfig(DestinationSelectorConfig destinationSelectorConfig) { this.destinationSelectorConfig = destinationSelectorConfig; } // ************************************************************************ // With methods // ************************************************************************ public ListChangeMoveSelectorConfig withValueSelectorConfig(ValueSelectorConfig valueSelectorConfig) { this.setValueSelectorConfig(valueSelectorConfig); return this; } public ListChangeMoveSelectorConfig withDestinationSelectorConfig(DestinationSelectorConfig destinationSelectorConfig) { this.setDestinationSelectorConfig(destinationSelectorConfig); return this; } // ************************************************************************ // Builder methods // ************************************************************************ @Override public ListChangeMoveSelectorConfig inherit(ListChangeMoveSelectorConfig inheritedConfig) {<FILL_FUNCTION_BODY>} @Override public ListChangeMoveSelectorConfig copyConfig() { return new ListChangeMoveSelectorConfig().inherit(this); } @Override public void visitReferencedClasses(Consumer<Class<?>> classVisitor) { visitCommonReferencedClasses(classVisitor); if (valueSelectorConfig != null) { valueSelectorConfig.visitReferencedClasses(classVisitor); } if (destinationSelectorConfig != null) { destinationSelectorConfig.visitReferencedClasses(classVisitor); } } @Override public String toString() { return getClass().getSimpleName() + "(" + valueSelectorConfig + ", " + destinationSelectorConfig + ")"; } }
super.inherit(inheritedConfig); valueSelectorConfig = ConfigUtils.inheritConfig(valueSelectorConfig, inheritedConfig.getValueSelectorConfig()); destinationSelectorConfig = ConfigUtils.inheritConfig(destinationSelectorConfig, inheritedConfig.getDestinationSelectorConfig()); return this;
560
69
629
<methods>public non-sealed void <init>() ,public void extractLeafMoveSelectorConfigsIntoList(List<MoveSelectorConfig#RAW>) ,public org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType getCacheType() ,public Class<? extends SelectionFilter#RAW> getFilterClass() ,public java.lang.Double getFixedProbabilityWeight() ,public Class<? extends SelectionProbabilityWeightFactory#RAW> getProbabilityWeightFactoryClass() ,public java.lang.Long getSelectedCountLimit() ,public org.optaplanner.core.config.heuristic.selector.common.SelectionOrder getSelectionOrder() ,public Class<? extends SelectionSorter#RAW> getSorterClass() ,public Class<? extends Comparator#RAW> getSorterComparatorClass() ,public org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder getSorterOrder() ,public Class<? extends SelectionSorterWeightFactory#RAW> getSorterWeightFactoryClass() ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.ListChangeMoveSelectorConfig inherit(org.optaplanner.core.config.heuristic.selector.move.generic.list.ListChangeMoveSelectorConfig) ,public void inheritFolded(MoveSelectorConfig<?>) ,public void setCacheType(org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType) ,public void setFilterClass(Class<? extends SelectionFilter#RAW>) ,public void setFixedProbabilityWeight(java.lang.Double) ,public void setProbabilityWeightFactoryClass(Class<? extends SelectionProbabilityWeightFactory#RAW>) ,public void setSelectedCountLimit(java.lang.Long) ,public void setSelectionOrder(org.optaplanner.core.config.heuristic.selector.common.SelectionOrder) ,public void setSorterClass(Class<? extends SelectionSorter#RAW>) ,public void setSorterComparatorClass(Class<? extends Comparator#RAW>) ,public void setSorterOrder(org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder) ,public void setSorterWeightFactoryClass(Class<? extends SelectionSorterWeightFactory#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.ListChangeMoveSelectorConfig withCacheType(org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.ListChangeMoveSelectorConfig withFilterClass(Class<? extends SelectionFilter#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.ListChangeMoveSelectorConfig withFixedProbabilityWeight(java.lang.Double) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.ListChangeMoveSelectorConfig withProbabilityWeightFactoryClass(Class<? extends SelectionProbabilityWeightFactory#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.ListChangeMoveSelectorConfig withSelectedCountLimit(java.lang.Long) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.ListChangeMoveSelectorConfig withSelectionOrder(org.optaplanner.core.config.heuristic.selector.common.SelectionOrder) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.ListChangeMoveSelectorConfig withSorterClass(Class<? extends SelectionSorter#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.ListChangeMoveSelectorConfig withSorterComparatorClass(Class<? extends Comparator#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.ListChangeMoveSelectorConfig withSorterOrder(org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.ListChangeMoveSelectorConfig withSorterWeightFactoryClass(Class<? extends SelectionSorterWeightFactory#RAW>) <variables>protected org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType cacheType,protected Class<? extends SelectionFilter#RAW> filterClass,private java.lang.Double fixedProbabilityWeight,protected Class<? extends SelectionProbabilityWeightFactory#RAW> probabilityWeightFactoryClass,protected java.lang.Long selectedCountLimit,protected org.optaplanner.core.config.heuristic.selector.common.SelectionOrder selectionOrder,protected Class<? extends SelectionSorter#RAW> sorterClass,protected Class<? extends Comparator#RAW> sorterComparatorClass,protected org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder sorterOrder,protected Class<? extends SelectionSorterWeightFactory#RAW> sorterWeightFactoryClass
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/config/heuristic/selector/move/generic/list/ListSwapMoveSelectorConfig.java
ListSwapMoveSelectorConfig
visitReferencedClasses
class ListSwapMoveSelectorConfig extends MoveSelectorConfig<ListSwapMoveSelectorConfig> { public static final String XML_ELEMENT_NAME = "listSwapMoveSelector"; @XmlElement(name = "valueSelector") private ValueSelectorConfig valueSelectorConfig = null; @XmlElement(name = "secondaryValueSelector") private ValueSelectorConfig secondaryValueSelectorConfig = null; public ValueSelectorConfig getValueSelectorConfig() { return valueSelectorConfig; } public void setValueSelectorConfig(ValueSelectorConfig valueSelectorConfig) { this.valueSelectorConfig = valueSelectorConfig; } public ValueSelectorConfig getSecondaryValueSelectorConfig() { return secondaryValueSelectorConfig; } public void setSecondaryValueSelectorConfig(ValueSelectorConfig secondaryValueSelectorConfig) { this.secondaryValueSelectorConfig = secondaryValueSelectorConfig; } // ************************************************************************ // With methods // ************************************************************************ public ListSwapMoveSelectorConfig withValueSelectorConfig(ValueSelectorConfig valueSelectorConfig) { this.setValueSelectorConfig(valueSelectorConfig); return this; } public ListSwapMoveSelectorConfig withSecondaryValueSelectorConfig(ValueSelectorConfig secondaryValueSelectorConfig) { this.setSecondaryValueSelectorConfig(secondaryValueSelectorConfig); return this; } // ************************************************************************ // Builder methods // ************************************************************************ @Override public ListSwapMoveSelectorConfig inherit(ListSwapMoveSelectorConfig inheritedConfig) { super.inherit(inheritedConfig); valueSelectorConfig = ConfigUtils.inheritConfig(valueSelectorConfig, inheritedConfig.getValueSelectorConfig()); secondaryValueSelectorConfig = ConfigUtils.inheritConfig(secondaryValueSelectorConfig, inheritedConfig.getSecondaryValueSelectorConfig()); return this; } @Override public ListSwapMoveSelectorConfig copyConfig() { return new ListSwapMoveSelectorConfig().inherit(this); } @Override public void visitReferencedClasses(Consumer<Class<?>> classVisitor) {<FILL_FUNCTION_BODY>} @Override public String toString() { return getClass().getSimpleName() + "(" + valueSelectorConfig + (secondaryValueSelectorConfig == null ? "" : ", " + secondaryValueSelectorConfig) + ")"; } }
visitCommonReferencedClasses(classVisitor); if (valueSelectorConfig != null) { valueSelectorConfig.visitReferencedClasses(classVisitor); } if (secondaryValueSelectorConfig != null) { secondaryValueSelectorConfig.visitReferencedClasses(classVisitor); }
578
82
660
<methods>public non-sealed void <init>() ,public void extractLeafMoveSelectorConfigsIntoList(List<MoveSelectorConfig#RAW>) ,public org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType getCacheType() ,public Class<? extends SelectionFilter#RAW> getFilterClass() ,public java.lang.Double getFixedProbabilityWeight() ,public Class<? extends SelectionProbabilityWeightFactory#RAW> getProbabilityWeightFactoryClass() ,public java.lang.Long getSelectedCountLimit() ,public org.optaplanner.core.config.heuristic.selector.common.SelectionOrder getSelectionOrder() ,public Class<? extends SelectionSorter#RAW> getSorterClass() ,public Class<? extends Comparator#RAW> getSorterComparatorClass() ,public org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder getSorterOrder() ,public Class<? extends SelectionSorterWeightFactory#RAW> getSorterWeightFactoryClass() ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.ListSwapMoveSelectorConfig inherit(org.optaplanner.core.config.heuristic.selector.move.generic.list.ListSwapMoveSelectorConfig) ,public void inheritFolded(MoveSelectorConfig<?>) ,public void setCacheType(org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType) ,public void setFilterClass(Class<? extends SelectionFilter#RAW>) ,public void setFixedProbabilityWeight(java.lang.Double) ,public void setProbabilityWeightFactoryClass(Class<? extends SelectionProbabilityWeightFactory#RAW>) ,public void setSelectedCountLimit(java.lang.Long) ,public void setSelectionOrder(org.optaplanner.core.config.heuristic.selector.common.SelectionOrder) ,public void setSorterClass(Class<? extends SelectionSorter#RAW>) ,public void setSorterComparatorClass(Class<? extends Comparator#RAW>) ,public void setSorterOrder(org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder) ,public void setSorterWeightFactoryClass(Class<? extends SelectionSorterWeightFactory#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.ListSwapMoveSelectorConfig withCacheType(org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.ListSwapMoveSelectorConfig withFilterClass(Class<? extends SelectionFilter#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.ListSwapMoveSelectorConfig withFixedProbabilityWeight(java.lang.Double) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.ListSwapMoveSelectorConfig withProbabilityWeightFactoryClass(Class<? extends SelectionProbabilityWeightFactory#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.ListSwapMoveSelectorConfig withSelectedCountLimit(java.lang.Long) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.ListSwapMoveSelectorConfig withSelectionOrder(org.optaplanner.core.config.heuristic.selector.common.SelectionOrder) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.ListSwapMoveSelectorConfig withSorterClass(Class<? extends SelectionSorter#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.ListSwapMoveSelectorConfig withSorterComparatorClass(Class<? extends Comparator#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.ListSwapMoveSelectorConfig withSorterOrder(org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.ListSwapMoveSelectorConfig withSorterWeightFactoryClass(Class<? extends SelectionSorterWeightFactory#RAW>) <variables>protected org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType cacheType,protected Class<? extends SelectionFilter#RAW> filterClass,private java.lang.Double fixedProbabilityWeight,protected Class<? extends SelectionProbabilityWeightFactory#RAW> probabilityWeightFactoryClass,protected java.lang.Long selectedCountLimit,protected org.optaplanner.core.config.heuristic.selector.common.SelectionOrder selectionOrder,protected Class<? extends SelectionSorter#RAW> sorterClass,protected Class<? extends Comparator#RAW> sorterComparatorClass,protected org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder sorterOrder,protected Class<? extends SelectionSorterWeightFactory#RAW> sorterWeightFactoryClass
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/config/heuristic/selector/move/generic/list/SubListChangeMoveSelectorConfig.java
SubListChangeMoveSelectorConfig
toString
class SubListChangeMoveSelectorConfig extends MoveSelectorConfig<SubListChangeMoveSelectorConfig> { public static final String XML_ELEMENT_NAME = "subListChangeMoveSelector"; /** * @deprecated The minimumSubListSize on the SubListChangeMoveSelectorConfig is deprecated and will be removed in a future * major version of OptaPlanner. Use {@link SubListSelectorConfig#getMinimumSubListSize()} instead. */ @Deprecated(forRemoval = true) protected Integer minimumSubListSize = null; /** * @deprecated The maximumSubListSize on the SubListChangeMoveSelectorConfig is deprecated and will be removed in a future * major version of OptaPlanner. Use {@link SubListSelectorConfig#getMaximumSubListSize()} instead. */ @Deprecated(forRemoval = true) protected Integer maximumSubListSize = null; private Boolean selectReversingMoveToo = null; @XmlElement(name = "subListSelector") private SubListSelectorConfig subListSelectorConfig = null; @XmlElement(name = "destinationSelector") private DestinationSelectorConfig destinationSelectorConfig = null; /** * @deprecated The minimumSubListSize on the SubListChangeMoveSelectorConfig is deprecated and will be removed in a future * major version of OptaPlanner. Use {@link SubListSelectorConfig#getMinimumSubListSize()} instead. */ @Deprecated(forRemoval = true) public Integer getMinimumSubListSize() { return minimumSubListSize; } /** * @deprecated The minimumSubListSize on the SubListChangeMoveSelectorConfig is deprecated and will be removed in a future * major version of OptaPlanner. Use {@link SubListSelectorConfig#setMinimumSubListSize(Integer)} instead. */ @Deprecated(forRemoval = true) public void setMinimumSubListSize(Integer minimumSubListSize) { this.minimumSubListSize = minimumSubListSize; } /** * @deprecated The maximumSubListSize on the SubListChangeMoveSelectorConfig is deprecated and will be removed in a future * major version of OptaPlanner. Use {@link SubListSelectorConfig#getMaximumSubListSize()} instead. */ @Deprecated(forRemoval = true) public Integer getMaximumSubListSize() { return maximumSubListSize; } /** * @deprecated The maximumSubListSize on the SubListChangeMoveSelectorConfig is deprecated and will be removed in a future * major version of OptaPlanner. Use {@link SubListSelectorConfig#setMaximumSubListSize(Integer)} instead. */ @Deprecated(forRemoval = true) public void setMaximumSubListSize(Integer maximumSubListSize) { this.maximumSubListSize = maximumSubListSize; } public Boolean getSelectReversingMoveToo() { return selectReversingMoveToo; } public void setSelectReversingMoveToo(Boolean selectReversingMoveToo) { this.selectReversingMoveToo = selectReversingMoveToo; } public SubListSelectorConfig getSubListSelectorConfig() { return subListSelectorConfig; } public void setSubListSelectorConfig(SubListSelectorConfig subListSelectorConfig) { this.subListSelectorConfig = subListSelectorConfig; } public DestinationSelectorConfig getDestinationSelectorConfig() { return destinationSelectorConfig; } public void setDestinationSelectorConfig(DestinationSelectorConfig destinationSelectorConfig) { this.destinationSelectorConfig = destinationSelectorConfig; } // ************************************************************************ // With methods // ************************************************************************ public SubListChangeMoveSelectorConfig withSelectReversingMoveToo(Boolean selectReversingMoveToo) { this.setSelectReversingMoveToo(selectReversingMoveToo); return this; } public SubListChangeMoveSelectorConfig withSubListSelectorConfig(SubListSelectorConfig subListSelectorConfig) { this.setSubListSelectorConfig(subListSelectorConfig); return this; } public SubListChangeMoveSelectorConfig withDestinationSelectorConfig(DestinationSelectorConfig destinationSelectorConfig) { this.setDestinationSelectorConfig(destinationSelectorConfig); return this; } // ************************************************************************ // Builder methods // ************************************************************************ @Override public SubListChangeMoveSelectorConfig inherit(SubListChangeMoveSelectorConfig inheritedConfig) { super.inherit(inheritedConfig); this.minimumSubListSize = ConfigUtils.inheritOverwritableProperty(minimumSubListSize, inheritedConfig.minimumSubListSize); this.maximumSubListSize = ConfigUtils.inheritOverwritableProperty(maximumSubListSize, inheritedConfig.maximumSubListSize); this.selectReversingMoveToo = ConfigUtils.inheritOverwritableProperty(selectReversingMoveToo, inheritedConfig.selectReversingMoveToo); this.subListSelectorConfig = ConfigUtils.inheritOverwritableProperty(subListSelectorConfig, inheritedConfig.subListSelectorConfig); this.destinationSelectorConfig = ConfigUtils.inheritOverwritableProperty(destinationSelectorConfig, inheritedConfig.destinationSelectorConfig); return this; } @Override public SubListChangeMoveSelectorConfig copyConfig() { return new SubListChangeMoveSelectorConfig().inherit(this); } @Override public void visitReferencedClasses(Consumer<Class<?>> classVisitor) { visitCommonReferencedClasses(classVisitor); if (subListSelectorConfig != null) { subListSelectorConfig.visitReferencedClasses(classVisitor); } if (destinationSelectorConfig != null) { destinationSelectorConfig.visitReferencedClasses(classVisitor); } } @Override public String toString() {<FILL_FUNCTION_BODY>} }
return getClass().getSimpleName() + "(" + subListSelectorConfig + ", " + destinationSelectorConfig + ")";
1,500
31
1,531
<methods>public non-sealed void <init>() ,public void extractLeafMoveSelectorConfigsIntoList(List<MoveSelectorConfig#RAW>) ,public org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType getCacheType() ,public Class<? extends SelectionFilter#RAW> getFilterClass() ,public java.lang.Double getFixedProbabilityWeight() ,public Class<? extends SelectionProbabilityWeightFactory#RAW> getProbabilityWeightFactoryClass() ,public java.lang.Long getSelectedCountLimit() ,public org.optaplanner.core.config.heuristic.selector.common.SelectionOrder getSelectionOrder() ,public Class<? extends SelectionSorter#RAW> getSorterClass() ,public Class<? extends Comparator#RAW> getSorterComparatorClass() ,public org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder getSorterOrder() ,public Class<? extends SelectionSorterWeightFactory#RAW> getSorterWeightFactoryClass() ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.SubListChangeMoveSelectorConfig inherit(org.optaplanner.core.config.heuristic.selector.move.generic.list.SubListChangeMoveSelectorConfig) ,public void inheritFolded(MoveSelectorConfig<?>) ,public void setCacheType(org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType) ,public void setFilterClass(Class<? extends SelectionFilter#RAW>) ,public void setFixedProbabilityWeight(java.lang.Double) ,public void setProbabilityWeightFactoryClass(Class<? extends SelectionProbabilityWeightFactory#RAW>) ,public void setSelectedCountLimit(java.lang.Long) ,public void setSelectionOrder(org.optaplanner.core.config.heuristic.selector.common.SelectionOrder) ,public void setSorterClass(Class<? extends SelectionSorter#RAW>) ,public void setSorterComparatorClass(Class<? extends Comparator#RAW>) ,public void setSorterOrder(org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder) ,public void setSorterWeightFactoryClass(Class<? extends SelectionSorterWeightFactory#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.SubListChangeMoveSelectorConfig withCacheType(org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.SubListChangeMoveSelectorConfig withFilterClass(Class<? extends SelectionFilter#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.SubListChangeMoveSelectorConfig withFixedProbabilityWeight(java.lang.Double) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.SubListChangeMoveSelectorConfig withProbabilityWeightFactoryClass(Class<? extends SelectionProbabilityWeightFactory#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.SubListChangeMoveSelectorConfig withSelectedCountLimit(java.lang.Long) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.SubListChangeMoveSelectorConfig withSelectionOrder(org.optaplanner.core.config.heuristic.selector.common.SelectionOrder) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.SubListChangeMoveSelectorConfig withSorterClass(Class<? extends SelectionSorter#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.SubListChangeMoveSelectorConfig withSorterComparatorClass(Class<? extends Comparator#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.SubListChangeMoveSelectorConfig withSorterOrder(org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.SubListChangeMoveSelectorConfig withSorterWeightFactoryClass(Class<? extends SelectionSorterWeightFactory#RAW>) <variables>protected org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType cacheType,protected Class<? extends SelectionFilter#RAW> filterClass,private java.lang.Double fixedProbabilityWeight,protected Class<? extends SelectionProbabilityWeightFactory#RAW> probabilityWeightFactoryClass,protected java.lang.Long selectedCountLimit,protected org.optaplanner.core.config.heuristic.selector.common.SelectionOrder selectionOrder,protected Class<? extends SelectionSorter#RAW> sorterClass,protected Class<? extends Comparator#RAW> sorterComparatorClass,protected org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder sorterOrder,protected Class<? extends SelectionSorterWeightFactory#RAW> sorterWeightFactoryClass
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/config/heuristic/selector/move/generic/list/SubListSwapMoveSelectorConfig.java
SubListSwapMoveSelectorConfig
inherit
class SubListSwapMoveSelectorConfig extends MoveSelectorConfig<SubListSwapMoveSelectorConfig> { public static final String XML_ELEMENT_NAME = "subListSwapMoveSelector"; /** * @deprecated The minimumSubListSize on the SubListSwapMoveSelectorConfig is deprecated and will be removed in a future * major version of OptaPlanner. Use {@link SubListSelectorConfig#getMinimumSubListSize()} instead. */ @Deprecated(forRemoval = true) protected Integer minimumSubListSize = null; /** * @deprecated The maximumSubListSize on the SubListSwapMoveSelectorConfig is deprecated and will be removed in a future * major version of OptaPlanner. Use {@link SubListSelectorConfig#getMaximumSubListSize()} instead. */ @Deprecated(forRemoval = true) protected Integer maximumSubListSize = null; private Boolean selectReversingMoveToo = null; @XmlElement(name = "subListSelector") private SubListSelectorConfig subListSelectorConfig = null; @XmlElement(name = "secondarySubListSelector") private SubListSelectorConfig secondarySubListSelectorConfig = null; /** * @deprecated The minimumSubListSize on the SubListSwapMoveSelectorConfig is deprecated and will be removed in a future * major version of OptaPlanner. Use {@link SubListSelectorConfig#getMinimumSubListSize()} instead. */ @Deprecated(forRemoval = true) public Integer getMinimumSubListSize() { return minimumSubListSize; } /** * @deprecated The minimumSubListSize on the SubListSwapMoveSelectorConfig is deprecated and will be removed in a future * major version of OptaPlanner. Use {@link SubListSelectorConfig#setMinimumSubListSize(Integer)} instead. */ @Deprecated(forRemoval = true) public void setMinimumSubListSize(Integer minimumSubListSize) { this.minimumSubListSize = minimumSubListSize; } /** * @deprecated The maximumSubListSize on the SubListSwapMoveSelectorConfig is deprecated and will be removed in a future * major version of OptaPlanner. Use {@link SubListSelectorConfig#getMaximumSubListSize()} instead. */ @Deprecated(forRemoval = true) public Integer getMaximumSubListSize() { return maximumSubListSize; } /** * @deprecated The maximumSubListSize on the SubListSwapMoveSelectorConfig is deprecated and will be removed in a future * major version of OptaPlanner. Use {@link SubListSelectorConfig#setMaximumSubListSize(Integer)} instead. */ @Deprecated(forRemoval = true) public void setMaximumSubListSize(Integer maximumSubListSize) { this.maximumSubListSize = maximumSubListSize; } public Boolean getSelectReversingMoveToo() { return selectReversingMoveToo; } public void setSelectReversingMoveToo(Boolean selectReversingMoveToo) { this.selectReversingMoveToo = selectReversingMoveToo; } public SubListSelectorConfig getSubListSelectorConfig() { return subListSelectorConfig; } public void setSubListSelectorConfig(SubListSelectorConfig subListSelectorConfig) { this.subListSelectorConfig = subListSelectorConfig; } public SubListSelectorConfig getSecondarySubListSelectorConfig() { return secondarySubListSelectorConfig; } public void setSecondarySubListSelectorConfig(SubListSelectorConfig secondarySubListSelectorConfig) { this.secondarySubListSelectorConfig = secondarySubListSelectorConfig; } // ************************************************************************ // With methods // ************************************************************************ public SubListSwapMoveSelectorConfig withSelectReversingMoveToo(Boolean selectReversingMoveToo) { this.setSelectReversingMoveToo(selectReversingMoveToo); return this; } public SubListSwapMoveSelectorConfig withSubListSelectorConfig(SubListSelectorConfig subListSelectorConfig) { this.setSubListSelectorConfig(subListSelectorConfig); return this; } public SubListSwapMoveSelectorConfig withSecondarySubListSelectorConfig(SubListSelectorConfig secondarySubListSelectorConfig) { this.setSecondarySubListSelectorConfig(secondarySubListSelectorConfig); return this; } @Override public SubListSwapMoveSelectorConfig inherit(SubListSwapMoveSelectorConfig inheritedConfig) {<FILL_FUNCTION_BODY>} @Override public SubListSwapMoveSelectorConfig copyConfig() { return new SubListSwapMoveSelectorConfig().inherit(this); } @Override public void visitReferencedClasses(Consumer<Class<?>> classVisitor) { visitCommonReferencedClasses(classVisitor); if (subListSelectorConfig != null) { subListSelectorConfig.visitReferencedClasses(classVisitor); } if (secondarySubListSelectorConfig != null) { secondarySubListSelectorConfig.visitReferencedClasses(classVisitor); } } @Override public String toString() { return getClass().getSimpleName() + "(" + subListSelectorConfig + (secondarySubListSelectorConfig == null ? "" : ", " + secondarySubListSelectorConfig) + ")"; } }
super.inherit(inheritedConfig); this.minimumSubListSize = ConfigUtils.inheritOverwritableProperty(minimumSubListSize, inheritedConfig.minimumSubListSize); this.maximumSubListSize = ConfigUtils.inheritOverwritableProperty(maximumSubListSize, inheritedConfig.maximumSubListSize); this.selectReversingMoveToo = ConfigUtils.inheritOverwritableProperty(selectReversingMoveToo, inheritedConfig.selectReversingMoveToo); this.subListSelectorConfig = ConfigUtils.inheritOverwritableProperty(subListSelectorConfig, inheritedConfig.subListSelectorConfig); this.secondarySubListSelectorConfig = ConfigUtils.inheritOverwritableProperty(secondarySubListSelectorConfig, inheritedConfig.secondarySubListSelectorConfig); return this;
1,374
200
1,574
<methods>public non-sealed void <init>() ,public void extractLeafMoveSelectorConfigsIntoList(List<MoveSelectorConfig#RAW>) ,public org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType getCacheType() ,public Class<? extends SelectionFilter#RAW> getFilterClass() ,public java.lang.Double getFixedProbabilityWeight() ,public Class<? extends SelectionProbabilityWeightFactory#RAW> getProbabilityWeightFactoryClass() ,public java.lang.Long getSelectedCountLimit() ,public org.optaplanner.core.config.heuristic.selector.common.SelectionOrder getSelectionOrder() ,public Class<? extends SelectionSorter#RAW> getSorterClass() ,public Class<? extends Comparator#RAW> getSorterComparatorClass() ,public org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder getSorterOrder() ,public Class<? extends SelectionSorterWeightFactory#RAW> getSorterWeightFactoryClass() ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.SubListSwapMoveSelectorConfig inherit(org.optaplanner.core.config.heuristic.selector.move.generic.list.SubListSwapMoveSelectorConfig) ,public void inheritFolded(MoveSelectorConfig<?>) ,public void setCacheType(org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType) ,public void setFilterClass(Class<? extends SelectionFilter#RAW>) ,public void setFixedProbabilityWeight(java.lang.Double) ,public void setProbabilityWeightFactoryClass(Class<? extends SelectionProbabilityWeightFactory#RAW>) ,public void setSelectedCountLimit(java.lang.Long) ,public void setSelectionOrder(org.optaplanner.core.config.heuristic.selector.common.SelectionOrder) ,public void setSorterClass(Class<? extends SelectionSorter#RAW>) ,public void setSorterComparatorClass(Class<? extends Comparator#RAW>) ,public void setSorterOrder(org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder) ,public void setSorterWeightFactoryClass(Class<? extends SelectionSorterWeightFactory#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.SubListSwapMoveSelectorConfig withCacheType(org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.SubListSwapMoveSelectorConfig withFilterClass(Class<? extends SelectionFilter#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.SubListSwapMoveSelectorConfig withFixedProbabilityWeight(java.lang.Double) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.SubListSwapMoveSelectorConfig withProbabilityWeightFactoryClass(Class<? extends SelectionProbabilityWeightFactory#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.SubListSwapMoveSelectorConfig withSelectedCountLimit(java.lang.Long) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.SubListSwapMoveSelectorConfig withSelectionOrder(org.optaplanner.core.config.heuristic.selector.common.SelectionOrder) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.SubListSwapMoveSelectorConfig withSorterClass(Class<? extends SelectionSorter#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.SubListSwapMoveSelectorConfig withSorterComparatorClass(Class<? extends Comparator#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.SubListSwapMoveSelectorConfig withSorterOrder(org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.SubListSwapMoveSelectorConfig withSorterWeightFactoryClass(Class<? extends SelectionSorterWeightFactory#RAW>) <variables>protected org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType cacheType,protected Class<? extends SelectionFilter#RAW> filterClass,private java.lang.Double fixedProbabilityWeight,protected Class<? extends SelectionProbabilityWeightFactory#RAW> probabilityWeightFactoryClass,protected java.lang.Long selectedCountLimit,protected org.optaplanner.core.config.heuristic.selector.common.SelectionOrder selectionOrder,protected Class<? extends SelectionSorter#RAW> sorterClass,protected Class<? extends Comparator#RAW> sorterComparatorClass,protected org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder sorterOrder,protected Class<? extends SelectionSorterWeightFactory#RAW> sorterWeightFactoryClass
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/config/heuristic/selector/move/generic/list/kopt/KOptListMoveSelectorConfig.java
KOptListMoveSelectorConfig
inherit
class KOptListMoveSelectorConfig extends MoveSelectorConfig<KOptListMoveSelectorConfig> { public static final String XML_ELEMENT_NAME = "kOptListMoveSelector"; protected Integer minimumK = null; protected Integer maximumK = null; @XmlElement(name = "originSelector") private ValueSelectorConfig originSelectorConfig = null; @XmlElement(name = "valueSelector") private ValueSelectorConfig valueSelectorConfig = null; public Integer getMinimumK() { return minimumK; } public void setMinimumK(Integer minimumK) { this.minimumK = minimumK; } public Integer getMaximumK() { return maximumK; } public void setMaximumK(Integer maximumK) { this.maximumK = maximumK; } public ValueSelectorConfig getOriginSelectorConfig() { return originSelectorConfig; } public void setOriginSelectorConfig(ValueSelectorConfig originSelectorConfig) { this.originSelectorConfig = originSelectorConfig; } public ValueSelectorConfig getValueSelectorConfig() { return valueSelectorConfig; } public void setValueSelectorConfig(ValueSelectorConfig valueSelectorConfig) { this.valueSelectorConfig = valueSelectorConfig; } // ************************************************************************ // With methods // ************************************************************************ public KOptListMoveSelectorConfig withMinimumK(Integer minimumK) { this.minimumK = minimumK; return this; } public KOptListMoveSelectorConfig withMaximumK(Integer maximumK) { this.maximumK = maximumK; return this; } public KOptListMoveSelectorConfig withOriginSelectorConfig(ValueSelectorConfig originSelectorConfig) { this.originSelectorConfig = originSelectorConfig; return this; } public KOptListMoveSelectorConfig withValueSelectorConfig(ValueSelectorConfig valueSelectorConfig) { this.valueSelectorConfig = valueSelectorConfig; return this; } // ************************************************************************ // Builder methods // ************************************************************************ @Override public KOptListMoveSelectorConfig inherit(KOptListMoveSelectorConfig inheritedConfig) {<FILL_FUNCTION_BODY>} @Override public KOptListMoveSelectorConfig copyConfig() { return new KOptListMoveSelectorConfig().inherit(this); } @Override public void visitReferencedClasses(Consumer<Class<?>> classVisitor) { visitCommonReferencedClasses(classVisitor); if (originSelectorConfig != null) { originSelectorConfig.visitReferencedClasses(classVisitor); } if (valueSelectorConfig != null) { valueSelectorConfig.visitReferencedClasses(classVisitor); } } @Override public String toString() { return getClass().getSimpleName() + "()"; } }
super.inherit(inheritedConfig); this.minimumK = ConfigUtils.inheritOverwritableProperty(minimumK, inheritedConfig.minimumK); this.maximumK = ConfigUtils.inheritOverwritableProperty(maximumK, inheritedConfig.maximumK); this.originSelectorConfig = ConfigUtils.inheritConfig(originSelectorConfig, inheritedConfig.originSelectorConfig); this.valueSelectorConfig = ConfigUtils.inheritConfig(valueSelectorConfig, inheritedConfig.valueSelectorConfig); return this;
737
121
858
<methods>public non-sealed void <init>() ,public void extractLeafMoveSelectorConfigsIntoList(List<MoveSelectorConfig#RAW>) ,public org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType getCacheType() ,public Class<? extends SelectionFilter#RAW> getFilterClass() ,public java.lang.Double getFixedProbabilityWeight() ,public Class<? extends SelectionProbabilityWeightFactory#RAW> getProbabilityWeightFactoryClass() ,public java.lang.Long getSelectedCountLimit() ,public org.optaplanner.core.config.heuristic.selector.common.SelectionOrder getSelectionOrder() ,public Class<? extends SelectionSorter#RAW> getSorterClass() ,public Class<? extends Comparator#RAW> getSorterComparatorClass() ,public org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder getSorterOrder() ,public Class<? extends SelectionSorterWeightFactory#RAW> getSorterWeightFactoryClass() ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.kopt.KOptListMoveSelectorConfig inherit(org.optaplanner.core.config.heuristic.selector.move.generic.list.kopt.KOptListMoveSelectorConfig) ,public void inheritFolded(MoveSelectorConfig<?>) ,public void setCacheType(org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType) ,public void setFilterClass(Class<? extends SelectionFilter#RAW>) ,public void setFixedProbabilityWeight(java.lang.Double) ,public void setProbabilityWeightFactoryClass(Class<? extends SelectionProbabilityWeightFactory#RAW>) ,public void setSelectedCountLimit(java.lang.Long) ,public void setSelectionOrder(org.optaplanner.core.config.heuristic.selector.common.SelectionOrder) ,public void setSorterClass(Class<? extends SelectionSorter#RAW>) ,public void setSorterComparatorClass(Class<? extends Comparator#RAW>) ,public void setSorterOrder(org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder) ,public void setSorterWeightFactoryClass(Class<? extends SelectionSorterWeightFactory#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.kopt.KOptListMoveSelectorConfig withCacheType(org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.kopt.KOptListMoveSelectorConfig withFilterClass(Class<? extends SelectionFilter#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.kopt.KOptListMoveSelectorConfig withFixedProbabilityWeight(java.lang.Double) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.kopt.KOptListMoveSelectorConfig withProbabilityWeightFactoryClass(Class<? extends SelectionProbabilityWeightFactory#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.kopt.KOptListMoveSelectorConfig withSelectedCountLimit(java.lang.Long) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.kopt.KOptListMoveSelectorConfig withSelectionOrder(org.optaplanner.core.config.heuristic.selector.common.SelectionOrder) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.kopt.KOptListMoveSelectorConfig withSorterClass(Class<? extends SelectionSorter#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.kopt.KOptListMoveSelectorConfig withSorterComparatorClass(Class<? extends Comparator#RAW>) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.kopt.KOptListMoveSelectorConfig withSorterOrder(org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder) ,public org.optaplanner.core.config.heuristic.selector.move.generic.list.kopt.KOptListMoveSelectorConfig withSorterWeightFactoryClass(Class<? extends SelectionSorterWeightFactory#RAW>) <variables>protected org.optaplanner.core.config.heuristic.selector.common.SelectionCacheType cacheType,protected Class<? extends SelectionFilter#RAW> filterClass,private java.lang.Double fixedProbabilityWeight,protected Class<? extends SelectionProbabilityWeightFactory#RAW> probabilityWeightFactoryClass,protected java.lang.Long selectedCountLimit,protected org.optaplanner.core.config.heuristic.selector.common.SelectionOrder selectionOrder,protected Class<? extends SelectionSorter#RAW> sorterClass,protected Class<? extends Comparator#RAW> sorterComparatorClass,protected org.optaplanner.core.config.heuristic.selector.common.decorator.SelectionSorterOrder sorterOrder,protected Class<? extends SelectionSorterWeightFactory#RAW> sorterWeightFactoryClass
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/config/heuristic/selector/value/chained/SubChainSelectorConfig.java
SubChainSelectorConfig
inherit
class SubChainSelectorConfig extends SelectorConfig<SubChainSelectorConfig> { @XmlElement(name = "valueSelector") protected ValueSelectorConfig valueSelectorConfig = null; protected Integer minimumSubChainSize = null; protected Integer maximumSubChainSize = null; public ValueSelectorConfig getValueSelectorConfig() { return valueSelectorConfig; } public void setValueSelectorConfig(ValueSelectorConfig valueSelectorConfig) { this.valueSelectorConfig = valueSelectorConfig; } /** * @return sometimes null */ public Integer getMinimumSubChainSize() { return minimumSubChainSize; } public void setMinimumSubChainSize(Integer minimumSubChainSize) { this.minimumSubChainSize = minimumSubChainSize; } public Integer getMaximumSubChainSize() { return maximumSubChainSize; } public void setMaximumSubChainSize(Integer maximumSubChainSize) { this.maximumSubChainSize = maximumSubChainSize; } // ************************************************************************ // With methods // ************************************************************************ public SubChainSelectorConfig withValueSelectorConfig(ValueSelectorConfig valueSelectorConfig) { this.setValueSelectorConfig(valueSelectorConfig); return this; } public SubChainSelectorConfig withMinimumSubChainSize(Integer minimumSubChainSize) { this.setMinimumSubChainSize(minimumSubChainSize); return this; } public SubChainSelectorConfig withMaximumSubChainSize(Integer maximumSubChainSize) { this.setMaximumSubChainSize(maximumSubChainSize); return this; } @Override public SubChainSelectorConfig inherit(SubChainSelectorConfig inheritedConfig) {<FILL_FUNCTION_BODY>} @Override public SubChainSelectorConfig copyConfig() { return new SubChainSelectorConfig().inherit(this); } @Override public void visitReferencedClasses(Consumer<Class<?>> classVisitor) { if (valueSelectorConfig != null) { valueSelectorConfig.visitReferencedClasses(classVisitor); } } @Override public String toString() { return getClass().getSimpleName() + "(" + valueSelectorConfig + ")"; } }
valueSelectorConfig = ConfigUtils.inheritConfig(valueSelectorConfig, inheritedConfig.getValueSelectorConfig()); minimumSubChainSize = ConfigUtils.inheritOverwritableProperty(minimumSubChainSize, inheritedConfig.getMinimumSubChainSize()); maximumSubChainSize = ConfigUtils.inheritOverwritableProperty(maximumSubChainSize, inheritedConfig.getMaximumSubChainSize()); return this;
576
98
674
<methods>public non-sealed void <init>() <variables>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/config/localsearch/LocalSearchPhaseConfig.java
LocalSearchPhaseConfig
visitReferencedClasses
class LocalSearchPhaseConfig extends PhaseConfig<LocalSearchPhaseConfig> { public static final String XML_ELEMENT_NAME = "localSearch"; // Warning: all fields are null (and not defaulted) because they can be inherited // and also because the input config file should match the output config file protected LocalSearchType localSearchType = null; @XmlElements({ @XmlElement(name = CartesianProductMoveSelectorConfig.XML_ELEMENT_NAME, type = CartesianProductMoveSelectorConfig.class), @XmlElement(name = ChangeMoveSelectorConfig.XML_ELEMENT_NAME, type = ChangeMoveSelectorConfig.class), @XmlElement(name = ListChangeMoveSelectorConfig.XML_ELEMENT_NAME, type = ListChangeMoveSelectorConfig.class), @XmlElement(name = ListSwapMoveSelectorConfig.XML_ELEMENT_NAME, type = ListSwapMoveSelectorConfig.class), @XmlElement(name = MoveIteratorFactoryConfig.XML_ELEMENT_NAME, type = MoveIteratorFactoryConfig.class), @XmlElement(name = MoveListFactoryConfig.XML_ELEMENT_NAME, type = MoveListFactoryConfig.class), @XmlElement(name = PillarChangeMoveSelectorConfig.XML_ELEMENT_NAME, type = PillarChangeMoveSelectorConfig.class), @XmlElement(name = PillarSwapMoveSelectorConfig.XML_ELEMENT_NAME, type = PillarSwapMoveSelectorConfig.class), @XmlElement(name = SubChainChangeMoveSelectorConfig.XML_ELEMENT_NAME, type = SubChainChangeMoveSelectorConfig.class), @XmlElement(name = SubChainSwapMoveSelectorConfig.XML_ELEMENT_NAME, type = SubChainSwapMoveSelectorConfig.class), @XmlElement(name = SubListChangeMoveSelectorConfig.XML_ELEMENT_NAME, type = SubListChangeMoveSelectorConfig.class), @XmlElement(name = SubListSwapMoveSelectorConfig.XML_ELEMENT_NAME, type = SubListSwapMoveSelectorConfig.class), @XmlElement(name = SwapMoveSelectorConfig.XML_ELEMENT_NAME, type = SwapMoveSelectorConfig.class), @XmlElement(name = TailChainSwapMoveSelectorConfig.XML_ELEMENT_NAME, type = TailChainSwapMoveSelectorConfig.class), @XmlElement(name = UnionMoveSelectorConfig.XML_ELEMENT_NAME, type = UnionMoveSelectorConfig.class) }) private MoveSelectorConfig moveSelectorConfig = null; @XmlElement(name = "acceptor") private LocalSearchAcceptorConfig acceptorConfig = null; @XmlElement(name = "forager") private LocalSearchForagerConfig foragerConfig = null; // ************************************************************************ // Constructors and simple getters/setters // ************************************************************************ public LocalSearchType getLocalSearchType() { return localSearchType; } public void setLocalSearchType(LocalSearchType localSearchType) { this.localSearchType = localSearchType; } public MoveSelectorConfig getMoveSelectorConfig() { return moveSelectorConfig; } public void setMoveSelectorConfig(MoveSelectorConfig moveSelectorConfig) { this.moveSelectorConfig = moveSelectorConfig; } public LocalSearchAcceptorConfig getAcceptorConfig() { return acceptorConfig; } public void setAcceptorConfig(LocalSearchAcceptorConfig acceptorConfig) { this.acceptorConfig = acceptorConfig; } public LocalSearchForagerConfig getForagerConfig() { return foragerConfig; } public void setForagerConfig(LocalSearchForagerConfig foragerConfig) { this.foragerConfig = foragerConfig; } // ************************************************************************ // With methods // ************************************************************************ public LocalSearchPhaseConfig withLocalSearchType(LocalSearchType localSearchType) { this.localSearchType = localSearchType; return this; } public LocalSearchPhaseConfig withMoveSelectorConfig(MoveSelectorConfig moveSelectorConfig) { this.moveSelectorConfig = moveSelectorConfig; return this; } public LocalSearchPhaseConfig withAcceptorConfig(LocalSearchAcceptorConfig acceptorConfig) { this.acceptorConfig = acceptorConfig; return this; } public LocalSearchPhaseConfig withForagerConfig(LocalSearchForagerConfig foragerConfig) { this.foragerConfig = foragerConfig; return this; } @Override public LocalSearchPhaseConfig inherit(LocalSearchPhaseConfig inheritedConfig) { super.inherit(inheritedConfig); localSearchType = ConfigUtils.inheritOverwritableProperty(localSearchType, inheritedConfig.getLocalSearchType()); setMoveSelectorConfig(ConfigUtils.inheritOverwritableProperty( getMoveSelectorConfig(), inheritedConfig.getMoveSelectorConfig())); acceptorConfig = ConfigUtils.inheritConfig(acceptorConfig, inheritedConfig.getAcceptorConfig()); foragerConfig = ConfigUtils.inheritConfig(foragerConfig, inheritedConfig.getForagerConfig()); return this; } @Override public LocalSearchPhaseConfig copyConfig() { return new LocalSearchPhaseConfig().inherit(this); } @Override public void visitReferencedClasses(Consumer<Class<?>> classVisitor) {<FILL_FUNCTION_BODY>} }
if (getTerminationConfig() != null) { getTerminationConfig().visitReferencedClasses(classVisitor); } if (moveSelectorConfig != null) { moveSelectorConfig.visitReferencedClasses(classVisitor); } if (acceptorConfig != null) { acceptorConfig.visitReferencedClasses(classVisitor); } if (foragerConfig != null) { foragerConfig.visitReferencedClasses(classVisitor); }
1,337
134
1,471
<methods>public non-sealed void <init>() ,public org.optaplanner.core.config.solver.termination.TerminationConfig getTerminationConfig() ,public org.optaplanner.core.config.localsearch.LocalSearchPhaseConfig inherit(org.optaplanner.core.config.localsearch.LocalSearchPhaseConfig) ,public void setTerminationConfig(org.optaplanner.core.config.solver.termination.TerminationConfig) ,public java.lang.String toString() ,public org.optaplanner.core.config.localsearch.LocalSearchPhaseConfig withTerminationConfig(org.optaplanner.core.config.solver.termination.TerminationConfig) <variables>private org.optaplanner.core.config.solver.termination.TerminationConfig terminationConfig
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/config/localsearch/decider/forager/LocalSearchForagerConfig.java
LocalSearchForagerConfig
inherit
class LocalSearchForagerConfig extends AbstractConfig<LocalSearchForagerConfig> { protected LocalSearchPickEarlyType pickEarlyType = null; protected Integer acceptedCountLimit = null; protected FinalistPodiumType finalistPodiumType = null; protected Boolean breakTieRandomly = null; public LocalSearchPickEarlyType getPickEarlyType() { return pickEarlyType; } public void setPickEarlyType(LocalSearchPickEarlyType pickEarlyType) { this.pickEarlyType = pickEarlyType; } public Integer getAcceptedCountLimit() { return acceptedCountLimit; } public void setAcceptedCountLimit(Integer acceptedCountLimit) { this.acceptedCountLimit = acceptedCountLimit; } public FinalistPodiumType getFinalistPodiumType() { return finalistPodiumType; } public void setFinalistPodiumType(FinalistPodiumType finalistPodiumType) { this.finalistPodiumType = finalistPodiumType; } public Boolean getBreakTieRandomly() { return breakTieRandomly; } public void setBreakTieRandomly(Boolean breakTieRandomly) { this.breakTieRandomly = breakTieRandomly; } // ************************************************************************ // With methods // ************************************************************************ public LocalSearchForagerConfig withPickEarlyType(LocalSearchPickEarlyType pickEarlyType) { this.pickEarlyType = pickEarlyType; return this; } public LocalSearchForagerConfig withAcceptedCountLimit(int acceptedCountLimit) { this.acceptedCountLimit = acceptedCountLimit; return this; } public LocalSearchForagerConfig withFinalistPodiumType(FinalistPodiumType finalistPodiumType) { this.finalistPodiumType = finalistPodiumType; return this; } public LocalSearchForagerConfig withBreakTieRandomly(boolean breakTieRandomly) { this.breakTieRandomly = breakTieRandomly; return this; } @Override public LocalSearchForagerConfig inherit(LocalSearchForagerConfig inheritedConfig) {<FILL_FUNCTION_BODY>} @Override public LocalSearchForagerConfig copyConfig() { return new LocalSearchForagerConfig().inherit(this); } @Override public void visitReferencedClasses(Consumer<Class<?>> classVisitor) { // No referenced classes } }
pickEarlyType = ConfigUtils.inheritOverwritableProperty(pickEarlyType, inheritedConfig.getPickEarlyType()); acceptedCountLimit = ConfigUtils.inheritOverwritableProperty(acceptedCountLimit, inheritedConfig.getAcceptedCountLimit()); finalistPodiumType = ConfigUtils.inheritOverwritableProperty(finalistPodiumType, inheritedConfig.getFinalistPodiumType()); breakTieRandomly = ConfigUtils.inheritOverwritableProperty(breakTieRandomly, inheritedConfig.getBreakTieRandomly()); return this;
660
143
803
<methods>public non-sealed void <init>() ,public abstract org.optaplanner.core.config.localsearch.decider.forager.LocalSearchForagerConfig copyConfig() ,public abstract org.optaplanner.core.config.localsearch.decider.forager.LocalSearchForagerConfig inherit(org.optaplanner.core.config.localsearch.decider.forager.LocalSearchForagerConfig) ,public java.lang.String toString() ,public abstract void visitReferencedClasses(Consumer<Class<?>>) <variables>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/config/solver/SolverManagerConfig.java
SolverManagerConfig
resolveParallelSolverCount
class SolverManagerConfig extends AbstractConfig<SolverManagerConfig> { public static final String PARALLEL_SOLVER_COUNT_AUTO = "AUTO"; private static final Logger LOGGER = LoggerFactory.getLogger(SolverManagerConfig.class); protected String parallelSolverCount = null; protected Class<? extends ThreadFactory> threadFactoryClass = null; // Future features: // throttlingDelay // congestionStrategy // ************************************************************************ // Constructors and simple getters/setters // ************************************************************************ public SolverManagerConfig() { } public String getParallelSolverCount() { return parallelSolverCount; } public void setParallelSolverCount(String parallelSolverCount) { this.parallelSolverCount = parallelSolverCount; } public Class<? extends ThreadFactory> getThreadFactoryClass() { return threadFactoryClass; } public void setThreadFactoryClass(Class<? extends ThreadFactory> threadFactoryClass) { this.threadFactoryClass = threadFactoryClass; } // ************************************************************************ // With methods // ************************************************************************ public SolverManagerConfig withParallelSolverCount(String parallelSolverCount) { this.parallelSolverCount = parallelSolverCount; return this; } public SolverManagerConfig withThreadFactoryClass(Class<? extends ThreadFactory> threadFactoryClass) { this.threadFactoryClass = threadFactoryClass; return this; } // ************************************************************************ // Builder methods // ************************************************************************ public Integer resolveParallelSolverCount() {<FILL_FUNCTION_BODY>} protected int getAvailableProcessors() { return Runtime.getRuntime().availableProcessors(); } protected int resolveParallelSolverCountAutomatically(int availableProcessorCount) { // Tweaked based on experience if (availableProcessorCount < 2) { return 1; } else { return availableProcessorCount / 2; } } @Override public SolverManagerConfig inherit(SolverManagerConfig inheritedConfig) { parallelSolverCount = ConfigUtils.inheritOverwritableProperty(parallelSolverCount, inheritedConfig.getParallelSolverCount()); threadFactoryClass = ConfigUtils.inheritOverwritableProperty(threadFactoryClass, inheritedConfig.getThreadFactoryClass()); return this; } @Override public SolverManagerConfig copyConfig() { return new SolverManagerConfig().inherit(this); } @Override public void visitReferencedClasses(Consumer<Class<?>> classVisitor) { classVisitor.accept(threadFactoryClass); } }
int availableProcessorCount = getAvailableProcessors(); Integer resolvedParallelSolverCount; if (parallelSolverCount == null || parallelSolverCount.equals(PARALLEL_SOLVER_COUNT_AUTO)) { resolvedParallelSolverCount = resolveParallelSolverCountAutomatically(availableProcessorCount); } else { resolvedParallelSolverCount = ConfigUtils.resolvePoolSize("parallelSolverCount", parallelSolverCount, PARALLEL_SOLVER_COUNT_AUTO); } if (resolvedParallelSolverCount < 1) { throw new IllegalArgumentException("The parallelSolverCount (" + parallelSolverCount + ") resulted in a resolvedParallelSolverCount (" + resolvedParallelSolverCount + ") that is lower than 1."); } if (resolvedParallelSolverCount > availableProcessorCount) { LOGGER.warn("The resolvedParallelSolverCount ({}) is higher " + "than the availableProcessorCount ({}), which is counter-efficient.", resolvedParallelSolverCount, availableProcessorCount); // Still allow it, to reproduce issues of a high-end server machine on a low-end developer machine } return resolvedParallelSolverCount;
695
302
997
<methods>public non-sealed void <init>() ,public abstract org.optaplanner.core.config.solver.SolverManagerConfig copyConfig() ,public abstract org.optaplanner.core.config.solver.SolverManagerConfig inherit(org.optaplanner.core.config.solver.SolverManagerConfig) ,public java.lang.String toString() ,public abstract void visitReferencedClasses(Consumer<Class<?>>) <variables>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/config/solver/monitoring/MonitoringConfig.java
MonitoringConfig
visitReferencedClasses
class MonitoringConfig extends AbstractConfig<MonitoringConfig> { @XmlElement(name = "metric") protected List<SolverMetric> solverMetricList = null; // ************************************************************************ // Constructors and simple getters/setters // ************************************************************************ public List<SolverMetric> getSolverMetricList() { return solverMetricList; } public void setSolverMetricList(List<SolverMetric> solverMetricList) { this.solverMetricList = solverMetricList; } // ************************************************************************ // With methods // ************************************************************************ public MonitoringConfig withSolverMetricList(List<SolverMetric> solverMetricList) { this.solverMetricList = solverMetricList; return this; } @Override public MonitoringConfig inherit(MonitoringConfig inheritedConfig) { solverMetricList = ConfigUtils.inheritMergeableListProperty(solverMetricList, inheritedConfig.solverMetricList); return this; } @Override public MonitoringConfig copyConfig() { return new MonitoringConfig().inherit(this); } @Override public void visitReferencedClasses(Consumer<Class<?>> classVisitor) {<FILL_FUNCTION_BODY>} }
// No referenced classes currently // If we add custom metrics here, then this should // register the custom metrics
348
30
378
<methods>public non-sealed void <init>() ,public abstract org.optaplanner.core.config.solver.monitoring.MonitoringConfig copyConfig() ,public abstract org.optaplanner.core.config.solver.monitoring.MonitoringConfig inherit(org.optaplanner.core.config.solver.monitoring.MonitoringConfig) ,public java.lang.String toString() ,public abstract void visitReferencedClasses(Consumer<Class<?>>) <variables>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/AbstractFromConfigFactory.java
AbstractFromConfigFactory
getEntityDescriptorForClass
class AbstractFromConfigFactory<Solution_, Config_ extends AbstractConfig<Config_>> { protected final Config_ config; public AbstractFromConfigFactory(Config_ config) { this.config = config; } public static <Solution_> EntitySelectorConfig getDefaultEntitySelectorConfigForEntity( HeuristicConfigPolicy<Solution_> configPolicy, EntityDescriptor<Solution_> entityDescriptor) { Class<?> entityClass = entityDescriptor.getEntityClass(); EntitySelectorConfig entitySelectorConfig = new EntitySelectorConfig() .withId(entityClass.getName()) .withEntityClass(entityClass); if (EntitySelectorConfig.hasSorter(configPolicy.getEntitySorterManner(), entityDescriptor)) { entitySelectorConfig = entitySelectorConfig.withCacheType(SelectionCacheType.PHASE) .withSelectionOrder(SelectionOrder.SORTED) .withSorterManner(configPolicy.getEntitySorterManner()); } return entitySelectorConfig; } protected EntityDescriptor<Solution_> deduceEntityDescriptor(HeuristicConfigPolicy<Solution_> configPolicy, Class<?> entityClass) { SolutionDescriptor<Solution_> solutionDescriptor = configPolicy.getSolutionDescriptor(); return entityClass == null ? getTheOnlyEntityDescriptor(solutionDescriptor) : getEntityDescriptorForClass(solutionDescriptor, entityClass); } private EntityDescriptor<Solution_> getEntityDescriptorForClass(SolutionDescriptor<Solution_> solutionDescriptor, Class<?> entityClass) {<FILL_FUNCTION_BODY>} protected EntityDescriptor<Solution_> getTheOnlyEntityDescriptor(SolutionDescriptor<Solution_> solutionDescriptor) { Collection<EntityDescriptor<Solution_>> entityDescriptors = solutionDescriptor.getGenuineEntityDescriptors(); if (entityDescriptors.size() != 1) { throw new IllegalArgumentException("The config (" + config + ") has no entityClass configured and because there are multiple in the entityClassSet (" + solutionDescriptor.getEntityClassSet() + "), it cannot be deduced automatically."); } return entityDescriptors.iterator().next(); } protected GenuineVariableDescriptor<Solution_> deduceGenuineVariableDescriptor(EntityDescriptor<Solution_> entityDescriptor, String variableName) { return variableName == null ? getTheOnlyVariableDescriptor(entityDescriptor) : getVariableDescriptorForName(entityDescriptor, variableName); } protected GenuineVariableDescriptor<Solution_> getVariableDescriptorForName(EntityDescriptor<Solution_> entityDescriptor, String variableName) { GenuineVariableDescriptor<Solution_> variableDescriptor = entityDescriptor.getGenuineVariableDescriptor(variableName); if (variableDescriptor == null) { throw new IllegalArgumentException("The config (" + config + ") has a variableName (" + variableName + ") which is not a valid planning variable on entityClass (" + entityDescriptor.getEntityClass() + ").\n" + entityDescriptor.buildInvalidVariableNameExceptionMessage(variableName)); } return variableDescriptor; } protected GenuineVariableDescriptor<Solution_> getTheOnlyVariableDescriptor(EntityDescriptor<Solution_> entityDescriptor) { List<GenuineVariableDescriptor<Solution_>> variableDescriptorList = entityDescriptor.getGenuineVariableDescriptorList(); if (variableDescriptorList.size() != 1) { throw new IllegalArgumentException("The config (" + config + ") has no configured variableName for entityClass (" + entityDescriptor.getEntityClass() + ") and because there are multiple variableNames (" + entityDescriptor.getGenuineVariableNameSet() + "), it cannot be deduced automatically."); } return variableDescriptorList.iterator().next(); } protected List<GenuineVariableDescriptor<Solution_>> deduceVariableDescriptorList( EntityDescriptor<Solution_> entityDescriptor, List<String> variableNameIncludeList) { Objects.requireNonNull(entityDescriptor); List<GenuineVariableDescriptor<Solution_>> variableDescriptorList = entityDescriptor.getGenuineVariableDescriptorList(); if (variableNameIncludeList == null) { return variableDescriptorList; } return variableNameIncludeList.stream() .map(variableNameInclude -> variableDescriptorList.stream() .filter(variableDescriptor -> variableDescriptor.getVariableName().equals(variableNameInclude)) .findFirst() .orElseThrow(() -> new IllegalArgumentException("The config (" + config + ") has a variableNameInclude (" + variableNameInclude + ") which does not exist in the entity (" + entityDescriptor.getEntityClass() + ")'s variableDescriptorList (" + variableDescriptorList + ")."))) .collect(Collectors.toList()); } }
EntityDescriptor<Solution_> entityDescriptor = solutionDescriptor.getEntityDescriptorStrict(entityClass); if (entityDescriptor == null) { throw new IllegalArgumentException("The config (" + config + ") has an entityClass (" + entityClass + ") that is not a known planning entity.\n" + "Check your solver configuration. If that class (" + entityClass.getSimpleName() + ") is not in the entityClassSet (" + solutionDescriptor.getEntityClassSet() + "), check your @" + PlanningSolution.class.getSimpleName() + " implementation's annotated methods too."); } return entityDescriptor;
1,203
157
1,360
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/constructionheuristic/DefaultConstructionHeuristicPhase.java
DefaultConstructionHeuristicPhase
solve
class DefaultConstructionHeuristicPhase<Solution_> extends AbstractPhase<Solution_> implements ConstructionHeuristicPhase<Solution_> { protected final EntityPlacer<Solution_> entityPlacer; protected final ConstructionHeuristicDecider<Solution_> decider; private DefaultConstructionHeuristicPhase(Builder<Solution_> builder) { super(builder); entityPlacer = builder.entityPlacer; decider = builder.decider; } @Override public String getPhaseTypeString() { return "Construction Heuristics"; } // ************************************************************************ // Worker methods // ************************************************************************ @Override public void solve(SolverScope<Solution_> solverScope) {<FILL_FUNCTION_BODY>} private void doStep(ConstructionHeuristicStepScope<Solution_> stepScope) { Move<Solution_> step = stepScope.getStep(); step.doMoveOnly(stepScope.getScoreDirector()); predictWorkingStepScore(stepScope, step); solver.getBestSolutionRecaller().processWorkingSolutionDuringConstructionHeuristicsStep(stepScope); } @Override public void solvingStarted(SolverScope<Solution_> solverScope) { super.solvingStarted(solverScope); entityPlacer.solvingStarted(solverScope); decider.solvingStarted(solverScope); } public void phaseStarted(ConstructionHeuristicPhaseScope<Solution_> phaseScope) { super.phaseStarted(phaseScope); entityPlacer.phaseStarted(phaseScope); decider.phaseStarted(phaseScope); } public void stepStarted(ConstructionHeuristicStepScope<Solution_> stepScope) { super.stepStarted(stepScope); entityPlacer.stepStarted(stepScope); decider.stepStarted(stepScope); } public void stepEnded(ConstructionHeuristicStepScope<Solution_> stepScope) { super.stepEnded(stepScope); entityPlacer.stepEnded(stepScope); decider.stepEnded(stepScope); if (logger.isDebugEnabled()) { long timeMillisSpent = stepScope.getPhaseScope().calculateSolverTimeMillisSpentUpToNow(); logger.debug("{} CH step ({}), time spent ({}), score ({}), selected move count ({})," + " picked move ({}).", logIndentation, stepScope.getStepIndex(), timeMillisSpent, stepScope.getScore(), stepScope.getSelectedMoveCount(), stepScope.getStepString()); } } public void phaseEnded(ConstructionHeuristicPhaseScope<Solution_> phaseScope) { super.phaseEnded(phaseScope); // Only update the best solution if the CH made any change. if (!phaseScope.getStartingScore().isSolutionInitialized()) { solver.getBestSolutionRecaller().updateBestSolutionAndFire(phaseScope.getSolverScope()); } entityPlacer.phaseEnded(phaseScope); decider.phaseEnded(phaseScope); phaseScope.endingNow(); logger.info("{}Construction Heuristic phase ({}) ended: time spent ({}), best score ({})," + " score calculation speed ({}/sec), step total ({}).", logIndentation, phaseIndex, phaseScope.calculateSolverTimeMillisSpentUpToNow(), phaseScope.getBestScore(), phaseScope.getPhaseScoreCalculationSpeed(), phaseScope.getNextStepIndex()); } @Override public void solvingEnded(SolverScope<Solution_> solverScope) { super.solvingEnded(solverScope); entityPlacer.solvingEnded(solverScope); decider.solvingEnded(solverScope); } @Override public void solvingError(SolverScope<Solution_> solverScope, Exception exception) { super.solvingError(solverScope, exception); decider.solvingError(solverScope, exception); } public static class Builder<Solution_> extends AbstractPhase.Builder<Solution_> { private final EntityPlacer<Solution_> entityPlacer; private final ConstructionHeuristicDecider<Solution_> decider; public Builder(int phaseIndex, String logIndentation, Termination<Solution_> phaseTermination, EntityPlacer<Solution_> entityPlacer, ConstructionHeuristicDecider<Solution_> decider) { super(phaseIndex, logIndentation, phaseTermination); this.entityPlacer = entityPlacer; this.decider = decider; } @Override public DefaultConstructionHeuristicPhase<Solution_> build() { return new DefaultConstructionHeuristicPhase<>(this); } } }
ConstructionHeuristicPhaseScope<Solution_> phaseScope = new ConstructionHeuristicPhaseScope<>(solverScope); phaseStarted(phaseScope); for (Placement<Solution_> placement : entityPlacer) { ConstructionHeuristicStepScope<Solution_> stepScope = new ConstructionHeuristicStepScope<>(phaseScope); stepStarted(stepScope); decider.decideNextStep(stepScope, placement); if (stepScope.getStep() == null) { if (phaseTermination.isPhaseTerminated(phaseScope)) { logger.trace("{} Step index ({}), time spent ({}) terminated without picking a nextStep.", logIndentation, stepScope.getStepIndex(), stepScope.getPhaseScope().calculateSolverTimeMillisSpentUpToNow()); } else if (stepScope.getSelectedMoveCount() == 0L) { logger.warn("{} No doable selected move at step index ({}), time spent ({})." + " Terminating phase early.", logIndentation, stepScope.getStepIndex(), stepScope.getPhaseScope().calculateSolverTimeMillisSpentUpToNow()); } else { throw new IllegalStateException("The step index (" + stepScope.getStepIndex() + ") has selected move count (" + stepScope.getSelectedMoveCount() + ") but failed to pick a nextStep (" + stepScope.getStep() + ")."); } // Although stepStarted has been called, stepEnded is not called for this step break; } doStep(stepScope); stepEnded(stepScope); phaseScope.setLastCompletedStepScope(stepScope); if (phaseTermination.isPhaseTerminated(phaseScope)) { break; } } phaseEnded(phaseScope);
1,293
468
1,761
<methods>public void addPhaseLifecycleListener(PhaseLifecycleListener<Solution_>) ,public int getPhaseIndex() ,public Termination<Solution_> getPhaseTermination() ,public abstract java.lang.String getPhaseTypeString() ,public AbstractSolver<Solution_> getSolver() ,public boolean isAssertExpectedStepScore() ,public boolean isAssertShadowVariablesAreNotStaleAfterStep() ,public boolean isAssertStepScoreFromScratch() ,public void phaseEnded(AbstractPhaseScope<Solution_>) ,public void phaseStarted(AbstractPhaseScope<Solution_>) ,public void removePhaseLifecycleListener(PhaseLifecycleListener<Solution_>) ,public void setSolver(AbstractSolver<Solution_>) ,public void solvingEnded(SolverScope<Solution_>) ,public void solvingStarted(SolverScope<Solution_>) ,public void stepEnded(AbstractStepScope<Solution_>) ,public void stepStarted(AbstractStepScope<Solution_>) <variables>protected final non-sealed boolean assertExpectedStepScore,protected final non-sealed boolean assertShadowVariablesAreNotStaleAfterStep,protected final non-sealed boolean assertStepScoreFromScratch,protected final non-sealed java.lang.String logIndentation,protected final transient Logger logger,protected final non-sealed int phaseIndex,protected PhaseLifecycleSupport<Solution_> phaseLifecycleSupport,protected final non-sealed Termination<Solution_> phaseTermination,protected AbstractSolver<Solution_> solver
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/constructionheuristic/decider/forager/DefaultConstructionHeuristicForager.java
DefaultConstructionHeuristicForager
checkPickEarly
class DefaultConstructionHeuristicForager<Solution_> extends AbstractConstructionHeuristicForager<Solution_> { protected final ConstructionHeuristicPickEarlyType pickEarlyType; protected long selectedMoveCount; protected ConstructionHeuristicMoveScope<Solution_> earlyPickedMoveScope; protected ConstructionHeuristicMoveScope<Solution_> maxScoreMoveScope; public DefaultConstructionHeuristicForager(ConstructionHeuristicPickEarlyType pickEarlyType) { this.pickEarlyType = pickEarlyType; } // ************************************************************************ // Worker methods // ************************************************************************ @Override public void stepStarted(ConstructionHeuristicStepScope<Solution_> stepScope) { super.stepStarted(stepScope); selectedMoveCount = 0L; earlyPickedMoveScope = null; maxScoreMoveScope = null; } @Override public void stepEnded(ConstructionHeuristicStepScope<Solution_> stepScope) { super.stepEnded(stepScope); earlyPickedMoveScope = null; maxScoreMoveScope = null; } @Override public void addMove(ConstructionHeuristicMoveScope<Solution_> moveScope) { selectedMoveCount++; checkPickEarly(moveScope); if (maxScoreMoveScope == null || moveScope.getScore().compareTo(maxScoreMoveScope.getScore()) > 0) { maxScoreMoveScope = moveScope; } } protected void checkPickEarly(ConstructionHeuristicMoveScope<Solution_> moveScope) {<FILL_FUNCTION_BODY>} @Override public boolean isQuitEarly() { return earlyPickedMoveScope != null; } @Override public ConstructionHeuristicMoveScope<Solution_> pickMove(ConstructionHeuristicStepScope<Solution_> stepScope) { stepScope.setSelectedMoveCount(selectedMoveCount); if (earlyPickedMoveScope != null) { return earlyPickedMoveScope; } else { return maxScoreMoveScope; } } }
switch (pickEarlyType) { case NEVER: break; case FIRST_NON_DETERIORATING_SCORE: Score lastStepScore = moveScope.getStepScope().getPhaseScope() .getLastCompletedStepScope().getScore(); if (moveScope.getScore().withInitScore(0).compareTo(lastStepScore.withInitScore(0)) >= 0) { earlyPickedMoveScope = moveScope; } break; case FIRST_FEASIBLE_SCORE: if (moveScope.getScore().withInitScore(0).isFeasible()) { earlyPickedMoveScope = moveScope; } break; case FIRST_FEASIBLE_SCORE_OR_NON_DETERIORATING_HARD: Score lastStepScore2 = moveScope.getStepScope().getPhaseScope() .getLastCompletedStepScope().getScore(); Score lastStepScoreDifference = moveScope.getScore().withInitScore(0) .subtract(lastStepScore2.withInitScore(0)); if (lastStepScoreDifference.isFeasible()) { earlyPickedMoveScope = moveScope; } break; default: throw new IllegalStateException("The pickEarlyType (" + pickEarlyType + ") is not implemented."); }
559
355
914
<methods>public non-sealed void <init>() <variables>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/constructionheuristic/placer/PooledEntityPlacerFactory.java
PooledEntityPlacerFactory
unfoldNew
class PooledEntityPlacerFactory<Solution_> extends AbstractEntityPlacerFactory<Solution_, PooledEntityPlacerConfig> { public static <Solution_> PooledEntityPlacerConfig unfoldNew(HeuristicConfigPolicy<Solution_> configPolicy, MoveSelectorConfig templateMoveSelectorConfig) {<FILL_FUNCTION_BODY>} public PooledEntityPlacerFactory(PooledEntityPlacerConfig placerConfig) { super(placerConfig); } @Override public PooledEntityPlacer<Solution_> buildEntityPlacer(HeuristicConfigPolicy<Solution_> configPolicy) { MoveSelectorConfig moveSelectorConfig_ = config.getMoveSelectorConfig() == null ? buildMoveSelectorConfig(configPolicy) : config.getMoveSelectorConfig(); MoveSelector<Solution_> moveSelector = MoveSelectorFactory.<Solution_> create(moveSelectorConfig_) .buildMoveSelector(configPolicy, SelectionCacheType.JUST_IN_TIME, SelectionOrder.ORIGINAL); return new PooledEntityPlacer<>(moveSelector); } private MoveSelectorConfig buildMoveSelectorConfig(HeuristicConfigPolicy<Solution_> configPolicy) { EntityDescriptor<Solution_> entityDescriptor = getTheOnlyEntityDescriptor(configPolicy.getSolutionDescriptor()); EntitySelectorConfig entitySelectorConfig = AbstractFromConfigFactory.getDefaultEntitySelectorConfigForEntity(configPolicy, entityDescriptor); List<GenuineVariableDescriptor<Solution_>> variableDescriptors = entityDescriptor.getGenuineVariableDescriptorList(); List<MoveSelectorConfig> subMoveSelectorConfigList = new ArrayList<>(variableDescriptors.size()); for (GenuineVariableDescriptor<Solution_> variableDescriptor : variableDescriptors) { subMoveSelectorConfigList .add(buildChangeMoveSelectorConfig(configPolicy, entitySelectorConfig.getId(), variableDescriptor)); } // The first entitySelectorConfig must be the mimic recorder, not the mimic replayer ((ChangeMoveSelectorConfig) subMoveSelectorConfigList.get(0)).setEntitySelectorConfig(entitySelectorConfig); MoveSelectorConfig moveSelectorConfig_; if (subMoveSelectorConfigList.size() > 1) { // Default to cartesian product (not a union) of planning variables. moveSelectorConfig_ = new CartesianProductMoveSelectorConfig(subMoveSelectorConfigList); } else { moveSelectorConfig_ = subMoveSelectorConfigList.get(0); } return moveSelectorConfig_; } }
PooledEntityPlacerConfig config = new PooledEntityPlacerConfig(); List<MoveSelectorConfig> leafMoveSelectorConfigList = new ArrayList<>(); MoveSelectorConfig moveSelectorConfig = (MoveSelectorConfig) templateMoveSelectorConfig.copyConfig(); moveSelectorConfig.extractLeafMoveSelectorConfigsIntoList(leafMoveSelectorConfigList); config.setMoveSelectorConfig(moveSelectorConfig); EntitySelectorConfig entitySelectorConfig = null; for (MoveSelectorConfig leafMoveSelectorConfig : leafMoveSelectorConfigList) { if (!(leafMoveSelectorConfig instanceof ChangeMoveSelectorConfig)) { throw new IllegalStateException("The <constructionHeuristic> contains a moveSelector (" + leafMoveSelectorConfig + ") that isn't a <changeMoveSelector>, a <unionMoveSelector>" + " or a <cartesianProductMoveSelector>.\n" + "Maybe you're using a moveSelector in <constructionHeuristic>" + " that's only supported for <localSearch>."); } ChangeMoveSelectorConfig changeMoveSelectorConfig = (ChangeMoveSelectorConfig) leafMoveSelectorConfig; if (changeMoveSelectorConfig.getEntitySelectorConfig() != null) { throw new IllegalStateException("The <constructionHeuristic> contains a changeMoveSelector (" + changeMoveSelectorConfig + ") that contains an entitySelector (" + changeMoveSelectorConfig.getEntitySelectorConfig() + ") without explicitly configuring the <pooledEntityPlacer>."); } if (entitySelectorConfig == null) { EntityDescriptor<Solution_> entityDescriptor = new PooledEntityPlacerFactory<Solution_>(config) .getTheOnlyEntityDescriptor(configPolicy.getSolutionDescriptor()); entitySelectorConfig = AbstractFromConfigFactory.getDefaultEntitySelectorConfigForEntity(configPolicy, entityDescriptor); changeMoveSelectorConfig.setEntitySelectorConfig(entitySelectorConfig); } changeMoveSelectorConfig.setEntitySelectorConfig( EntitySelectorConfig.newMimicSelectorConfig(entitySelectorConfig.getId())); } return config;
618
504
1,122
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/constructionheuristic/placer/QueuedValuePlacer.java
QueuedValuePlacingIterator
createUpcomingSelection
class QueuedValuePlacingIterator extends UpcomingSelectionIterator<Placement<Solution_>> { private Iterator<Object> valueIterator; private QueuedValuePlacingIterator() { valueIterator = Collections.emptyIterator(); } @Override protected Placement<Solution_> createUpcomingSelection() {<FILL_FUNCTION_BODY>} }
// If all values are used, there can still be entities uninitialized if (!valueIterator.hasNext()) { valueIterator = valueSelector.iterator(); if (!valueIterator.hasNext()) { return noUpcomingSelection(); } } valueIterator.next(); Iterator<Move<Solution_>> moveIterator = moveSelector.iterator(); // Because the valueSelector is entity independent, there is always a move if there's still an entity if (!moveIterator.hasNext()) { return noUpcomingSelection(); } return new Placement<>(moveIterator);
97
148
245
<methods>public non-sealed void <init>() ,public void phaseEnded(AbstractPhaseScope<Solution_>) ,public void phaseStarted(AbstractPhaseScope<Solution_>) ,public void solvingEnded(SolverScope<Solution_>) ,public void solvingStarted(SolverScope<Solution_>) ,public void stepEnded(AbstractStepScope<Solution_>) ,public void stepStarted(AbstractStepScope<Solution_>) <variables>protected final transient Logger logger,protected PhaseLifecycleSupport<Solution_> phaseLifecycleSupport
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/constructionheuristic/placer/QueuedValuePlacerFactory.java
QueuedValuePlacerFactory
buildEntityPlacer
class QueuedValuePlacerFactory<Solution_> extends AbstractEntityPlacerFactory<Solution_, QueuedValuePlacerConfig> { public static QueuedValuePlacerConfig unfoldNew(MoveSelectorConfig templateMoveSelectorConfig) { throw new UnsupportedOperationException("The <constructionHeuristic> contains a moveSelector (" + templateMoveSelectorConfig + ") and the <queuedValuePlacer> does not support unfolding those yet."); } public QueuedValuePlacerFactory(QueuedValuePlacerConfig placerConfig) { super(placerConfig); } @Override public QueuedValuePlacer<Solution_> buildEntityPlacer(HeuristicConfigPolicy<Solution_> configPolicy) {<FILL_FUNCTION_BODY>} private ValueSelectorConfig buildValueSelectorConfig(HeuristicConfigPolicy<Solution_> configPolicy, EntityDescriptor<Solution_> entityDescriptor) { ValueSelectorConfig valueSelectorConfig_; if (config.getValueSelectorConfig() == null) { Class<?> entityClass = entityDescriptor.getEntityClass(); GenuineVariableDescriptor<Solution_> variableDescriptor = getTheOnlyVariableDescriptor(entityDescriptor); valueSelectorConfig_ = new ValueSelectorConfig() .withId(entityClass.getName() + "." + variableDescriptor.getVariableName()) .withVariableName(variableDescriptor.getVariableName()); if (ValueSelectorConfig.hasSorter(configPolicy.getValueSorterManner(), variableDescriptor)) { valueSelectorConfig_ = valueSelectorConfig_.withCacheType(SelectionCacheType.PHASE) .withSelectionOrder(SelectionOrder.SORTED) .withSorterManner(configPolicy.getValueSorterManner()); } } else { valueSelectorConfig_ = config.getValueSelectorConfig(); } if (valueSelectorConfig_.getCacheType() != null && valueSelectorConfig_.getCacheType().compareTo(SelectionCacheType.PHASE) < 0) { throw new IllegalArgumentException("The queuedValuePlacer (" + this + ") cannot have a valueSelectorConfig (" + valueSelectorConfig_ + ") with a cacheType (" + valueSelectorConfig_.getCacheType() + ") lower than " + SelectionCacheType.PHASE + "."); } return valueSelectorConfig_; } @Override protected ChangeMoveSelectorConfig buildChangeMoveSelectorConfig( HeuristicConfigPolicy<Solution_> configPolicy, String valueSelectorConfigId, GenuineVariableDescriptor<Solution_> variableDescriptor) { ChangeMoveSelectorConfig changeMoveSelectorConfig = new ChangeMoveSelectorConfig(); EntityDescriptor<Solution_> entityDescriptor = variableDescriptor.getEntityDescriptor(); EntitySelectorConfig changeEntitySelectorConfig = new EntitySelectorConfig() .withEntityClass(entityDescriptor.getEntityClass()); if (EntitySelectorConfig.hasSorter(configPolicy.getEntitySorterManner(), entityDescriptor)) { changeEntitySelectorConfig = changeEntitySelectorConfig.withCacheType(SelectionCacheType.PHASE) .withSelectionOrder(SelectionOrder.SORTED) .withSorterManner(configPolicy.getEntitySorterManner()); } ValueSelectorConfig changeValueSelectorConfig = new ValueSelectorConfig() .withMimicSelectorRef(valueSelectorConfigId); return changeMoveSelectorConfig.withEntitySelectorConfig(changeEntitySelectorConfig) .withValueSelectorConfig(changeValueSelectorConfig); } }
EntityDescriptor<Solution_> entityDescriptor = deduceEntityDescriptor(configPolicy, config.getEntityClass()); ValueSelectorConfig valueSelectorConfig_ = buildValueSelectorConfig(configPolicy, entityDescriptor); // TODO improve the ValueSelectorFactory API (avoid the boolean flags). ValueSelector<Solution_> valueSelector = ValueSelectorFactory.<Solution_> create(valueSelectorConfig_) .buildValueSelector(configPolicy, entityDescriptor, SelectionCacheType.PHASE, SelectionOrder.ORIGINAL, false, // override applyReinitializeVariableFiltering ValueSelectorFactory.ListValueFilteringType.ACCEPT_UNASSIGNED); MoveSelectorConfig<?> moveSelectorConfig_ = config.getMoveSelectorConfig() == null ? buildChangeMoveSelectorConfig(configPolicy, valueSelectorConfig_.getId(), valueSelector.getVariableDescriptor()) : config.getMoveSelectorConfig(); MoveSelector<Solution_> moveSelector = MoveSelectorFactory.<Solution_> create(moveSelectorConfig_) .buildMoveSelector(configPolicy, SelectionCacheType.JUST_IN_TIME, SelectionOrder.ORIGINAL); if (!(valueSelector instanceof EntityIndependentValueSelector)) { throw new IllegalArgumentException("The queuedValuePlacer (" + this + ") needs to be based on an " + EntityIndependentValueSelector.class.getSimpleName() + " (" + valueSelector + ")." + " Check your @" + ValueRangeProvider.class.getSimpleName() + " annotations."); } return new QueuedValuePlacer<>((EntityIndependentValueSelector<Solution_>) valueSelector, moveSelector);
839
400
1,239
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/common/AlphabeticMemberComparator.java
AlphabeticMemberComparator
compare
class AlphabeticMemberComparator implements Comparator<Member> { @Override public int compare(Member a, Member b) {<FILL_FUNCTION_BODY>} protected int compareParameterTypes(Class<?>[] aParameterTypes, Class<?>[] bParameterTypes) { if (aParameterTypes.length != bParameterTypes.length) { return aParameterTypes.length > bParameterTypes.length ? 1 : -1; } for (int i = 0; i < aParameterTypes.length; i++) { int parameterNameCompareTo = aParameterTypes[i].getName().compareTo(bParameterTypes[i].getName()); if (parameterNameCompareTo != 0) { return parameterNameCompareTo; } } return 0; } }
int compareTo = a.getName().compareTo(b.getName()); if (compareTo != 0) { return compareTo; } if (a instanceof Method) { if (!(b instanceof Method)) { return 1; } int parameterNameCompareTo = compareParameterTypes( ((Method) a).getParameterTypes(), ((Method) b).getParameterTypes()); if (parameterNameCompareTo != 0) { return parameterNameCompareTo; } } else if (b instanceof Method) { return -1; } if (a instanceof Constructor) { if (!(b instanceof Constructor)) { return 1; } int parameterNameCompareTo = compareParameterTypes( ((Constructor) a).getParameterTypes(), ((Constructor) b).getParameterTypes()); if (parameterNameCompareTo != 0) { return parameterNameCompareTo; } } else if (b instanceof Constructor) { return -1; } return 0;
205
261
466
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/common/accessor/LambdaBeanPropertyMemberAccessor.java
LambdaBeanPropertyMemberAccessor
createGetterFunction
class LambdaBeanPropertyMemberAccessor implements MemberAccessor { private final Class<?> propertyType; private final String propertyName; private final Method getterMethod; private final Function getterFunction; private final Method setterMethod; private final BiConsumer setterFunction; public LambdaBeanPropertyMemberAccessor(Method getterMethod) { this(getterMethod, false); } public LambdaBeanPropertyMemberAccessor(Method getterMethod, boolean getterOnly) { this.getterMethod = getterMethod; Class<?> declaringClass = getterMethod.getDeclaringClass(); if (!ReflectionHelper.isGetterMethod(getterMethod)) { throw new IllegalArgumentException("The getterMethod (" + getterMethod + ") is not a valid getter."); } propertyType = getterMethod.getReturnType(); propertyName = ReflectionHelper.getGetterPropertyName(getterMethod); // TODO In JDK 9 switch to (and remove workaround from MemberAccessorFactory) // MethodHandles.Lookup lookup = MethodHandles.privateLookupIn(declaringClass, MethodHandles.lookup()) MethodHandles.Lookup lookup = MethodHandles.lookup(); getterFunction = createGetterFunction(lookup); if (getterOnly) { setterMethod = null; setterFunction = null; } else { setterMethod = ReflectionHelper.getSetterMethod(declaringClass, getterMethod.getReturnType(), propertyName); setterFunction = createSetterFunction(lookup); } } private Function createGetterFunction(MethodHandles.Lookup lookup) {<FILL_FUNCTION_BODY>} private BiConsumer createSetterFunction(MethodHandles.Lookup lookup) { if (setterMethod == null) { return null; } Class<?> declaringClass = setterMethod.getDeclaringClass(); CallSite setterSite; try { setterSite = LambdaMetafactory.metafactory(lookup, "accept", MethodType.methodType(BiConsumer.class), MethodType.methodType(void.class, Object.class, Object.class), lookup.findVirtual(declaringClass, setterMethod.getName(), MethodType.methodType(void.class, propertyType)), MethodType.methodType(void.class, declaringClass, propertyType)); } catch (LambdaConversionException | NoSuchMethodException | IllegalAccessException e) { throw new IllegalArgumentException("Lambda creation failed for setterMethod (" + setterMethod + ").", e); } try { return (BiConsumer) setterSite.getTarget().invokeExact(); } catch (Throwable e) { throw new IllegalArgumentException("Lambda creation failed for setterMethod (" + setterMethod + ").", e); } } @Override public Class<?> getDeclaringClass() { return getterMethod.getDeclaringClass(); } @Override public String getName() { return propertyName; } @Override public Class<?> getType() { return propertyType; } @Override public Type getGenericType() { return getterMethod.getGenericReturnType(); } @Override public Object executeGetter(Object bean) { return getterFunction.apply(bean); } @Override public <Fact_, Result_> Function<Fact_, Result_> getGetterFunction() { return getterFunction; } @Override public boolean supportSetter() { return setterMethod != null; } @Override public void executeSetter(Object bean, Object value) { setterFunction.accept(bean, value); } @Override public String getSpeedNote() { return "pretty fast access with LambdaMetafactory"; } @Override public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { return getterMethod.getAnnotation(annotationClass); } @Override public <T extends Annotation> T[] getDeclaredAnnotationsByType(Class<T> annotationClass) { return getterMethod.getDeclaredAnnotationsByType(annotationClass); } @Override public String toString() { return "bean property " + propertyName + " on " + getterMethod.getDeclaringClass(); } }
Class<?> declaringClass = getterMethod.getDeclaringClass(); CallSite getterSite; try { getterSite = LambdaMetafactory.metafactory(lookup, "apply", MethodType.methodType(Function.class), MethodType.methodType(Object.class, Object.class), lookup.findVirtual(declaringClass, getterMethod.getName(), MethodType.methodType(propertyType)), MethodType.methodType(propertyType, declaringClass)); } catch (IllegalAccessException e) { throw new IllegalStateException("Lambda creation failed for getterMethod (" + getterMethod + ").\n" + MemberAccessorFactory.CLASSLOADER_NUDGE_MESSAGE, e); } catch (LambdaConversionException | NoSuchMethodException e) { throw new IllegalArgumentException("Lambda creation failed for getterMethod (" + getterMethod + ").", e); } try { return (Function) getterSite.getTarget().invokeExact(); } catch (Throwable e) { throw new IllegalArgumentException("Lambda creation failed for getterMethod (" + getterMethod + ").", e); }
1,120
289
1,409
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/common/accessor/MemberAccessorFactory.java
MemberAccessorFactory
buildReflectiveMemberAccessor
class MemberAccessorFactory { // exists only so that the various member accessors can share the same text in their exception messages static final String CLASSLOADER_NUDGE_MESSAGE = "Maybe add getClass().getClassLoader() as a parameter to the " + SolverFactory.class.getSimpleName() + ".create...() method call."; /** * Creates a new member accessor based on the given parameters. * * @param member never null, method or field to access * @param memberAccessorType * @param annotationClass the annotation the member was annotated with (used for error reporting) * @param domainAccessType * @param classLoader null or {@link GizmoClassLoader} if domainAccessType is {@link DomainAccessType#GIZMO}. * @return never null, new instance of the member accessor */ public static MemberAccessor buildMemberAccessor(Member member, MemberAccessorType memberAccessorType, Class<? extends Annotation> annotationClass, DomainAccessType domainAccessType, ClassLoader classLoader) { switch (domainAccessType) { case GIZMO: return GizmoMemberAccessorFactory.buildGizmoMemberAccessor(member, annotationClass, (GizmoClassLoader) Objects.requireNonNull(classLoader)); case REFLECTION: return buildReflectiveMemberAccessor(member, memberAccessorType, annotationClass); default: throw new IllegalStateException("The domainAccessType (" + domainAccessType + ") is not implemented."); } } private static MemberAccessor buildReflectiveMemberAccessor(Member member, MemberAccessorType memberAccessorType, Class<? extends Annotation> annotationClass) {<FILL_FUNCTION_BODY>} private final Map<String, MemberAccessor> memberAccessorCache; private final GizmoClassLoader gizmoClassLoader = new GizmoClassLoader(); public MemberAccessorFactory() { this(null); } /** * Prefills the member accessor cache. * * @param memberAccessorMap key is the fully qualified member name */ public MemberAccessorFactory(Map<String, MemberAccessor> memberAccessorMap) { // The MemberAccessorFactory may be accessed, and this cache both read and updated, by multiple threads. this.memberAccessorCache = memberAccessorMap == null ? new ConcurrentHashMap<>() : new ConcurrentHashMap<>(memberAccessorMap); } /** * Creates a new member accessor based on the given parameters. Caches the result. * * @param member never null, method or field to access * @param memberAccessorType * @param annotationClass the annotation the member was annotated with (used for error reporting) * @param domainAccessType * @return never null, new {@link MemberAccessor} instance unless already found in memberAccessorMap */ public MemberAccessor buildAndCacheMemberAccessor(Member member, MemberAccessorType memberAccessorType, Class<? extends Annotation> annotationClass, DomainAccessType domainAccessType) { String generatedClassName = GizmoMemberAccessorFactory.getGeneratedClassName(member); return memberAccessorCache.computeIfAbsent(generatedClassName, k -> MemberAccessorFactory.buildMemberAccessor(member, memberAccessorType, annotationClass, domainAccessType, gizmoClassLoader)); } public GizmoClassLoader getGizmoClassLoader() { return gizmoClassLoader; } public enum MemberAccessorType { FIELD_OR_READ_METHOD, FIELD_OR_GETTER_METHOD, FIELD_OR_GETTER_METHOD_WITH_SETTER } }
if (member instanceof Field) { Field field = (Field) member; return new ReflectionFieldMemberAccessor(field); } else if (member instanceof Method) { Method method = (Method) member; MemberAccessor memberAccessor; switch (memberAccessorType) { case FIELD_OR_READ_METHOD: if (!ReflectionHelper.isGetterMethod(method)) { ReflectionHelper.assertReadMethod(method, annotationClass); memberAccessor = new ReflectionMethodMemberAccessor(method); break; } // Intentionally fall through (no break) case FIELD_OR_GETTER_METHOD: case FIELD_OR_GETTER_METHOD_WITH_SETTER: boolean getterOnly = memberAccessorType != MemberAccessorType.FIELD_OR_GETTER_METHOD_WITH_SETTER; ReflectionHelper.assertGetterMethod(method, annotationClass); if (Modifier.isPublic(method.getModifiers()) // HACK The lambda approach doesn't support classes from another classloader (such as loaded by KieContainer) in JDK 8 // TODO In JDK 9 use MethodHandles.privateLookupIn(Class, MethodHandles.lookup()) && method.getDeclaringClass().getClassLoader().equals(MemberAccessor.class.getClassLoader())) { memberAccessor = new LambdaBeanPropertyMemberAccessor(method, getterOnly); } else { memberAccessor = new ReflectionBeanPropertyMemberAccessor(method, getterOnly); } break; default: throw new IllegalStateException("The memberAccessorType (" + memberAccessorType + ") is not implemented."); } if (memberAccessorType == MemberAccessorType.FIELD_OR_GETTER_METHOD_WITH_SETTER && !memberAccessor.supportSetter()) { throw new IllegalStateException("The class (" + method.getDeclaringClass() + ") has a @" + annotationClass.getSimpleName() + " annotated getter method (" + method + "), but lacks a setter for that property (" + memberAccessor.getName() + ")."); } return memberAccessor; } else { throw new IllegalStateException("Impossible state: the member (" + member + ")'s type is not a " + Field.class.getSimpleName() + " or a " + Method.class.getSimpleName() + "."); }
932
607
1,539
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/common/accessor/ReflectionBeanPropertyMemberAccessor.java
ReflectionBeanPropertyMemberAccessor
executeGetter
class ReflectionBeanPropertyMemberAccessor extends AbstractMemberAccessor { private final Class<?> propertyType; private final String propertyName; private final Method getterMethod; private final Method setterMethod; public ReflectionBeanPropertyMemberAccessor(Method getterMethod) { this(getterMethod, false); } public ReflectionBeanPropertyMemberAccessor(Method getterMethod, boolean getterOnly) { this.getterMethod = getterMethod; getterMethod.setAccessible(true); // Performance hack by avoiding security checks Class<?> declaringClass = getterMethod.getDeclaringClass(); if (!ReflectionHelper.isGetterMethod(getterMethod)) { throw new IllegalArgumentException("The getterMethod (" + getterMethod + ") is not a valid getter."); } propertyType = getterMethod.getReturnType(); propertyName = ReflectionHelper.getGetterPropertyName(getterMethod); if (getterOnly) { setterMethod = null; } else { setterMethod = ReflectionHelper.getSetterMethod(declaringClass, getterMethod.getReturnType(), propertyName); if (setterMethod != null) { setterMethod.setAccessible(true); // Performance hack by avoiding security checks } } } @Override public Class<?> getDeclaringClass() { return getterMethod.getDeclaringClass(); } @Override public String getName() { return propertyName; } @Override public Class<?> getType() { return propertyType; } @Override public Type getGenericType() { return getterMethod.getGenericReturnType(); } @Override public Object executeGetter(Object bean) {<FILL_FUNCTION_BODY>} @Override public boolean supportSetter() { return setterMethod != null; } @Override public void executeSetter(Object bean, Object value) { try { setterMethod.invoke(bean, value); } catch (IllegalAccessException e) { throw new IllegalStateException("Cannot call property (" + propertyName + ") setterMethod (" + setterMethod + ") on bean of class (" + bean.getClass() + ") for value (" + value + ").", e); } catch (InvocationTargetException e) { throw new IllegalStateException("The property (" + propertyName + ") setterMethod (" + setterMethod + ") on bean of class (" + bean.getClass() + ") throws an exception for value (" + value + ").", e.getCause()); } } @Override public String getSpeedNote() { return "slow access with reflection"; } @Override public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { return getterMethod.getAnnotation(annotationClass); } @Override public <T extends Annotation> T[] getDeclaredAnnotationsByType(Class<T> annotationClass) { return getterMethod.getDeclaredAnnotationsByType(annotationClass); } @Override public String toString() { return "bean property " + propertyName + " on " + getterMethod.getDeclaringClass(); } }
try { return getterMethod.invoke(bean); } catch (IllegalAccessException e) { throw new IllegalStateException("Cannot call property (" + propertyName + ") getterMethod (" + getterMethod + ") on bean of class (" + bean.getClass() + ").\n" + MemberAccessorFactory.CLASSLOADER_NUDGE_MESSAGE, e); } catch (InvocationTargetException e) { throw new IllegalStateException("The property (" + propertyName + ") getterMethod (" + getterMethod + ") on bean of class (" + bean.getClass() + ") throws an exception.", e.getCause()); }
840
168
1,008
<methods>public non-sealed void <init>() ,public final Function<Fact_,Result_> getGetterFunction() <variables>private final Function#RAW getterFunction
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/common/accessor/ReflectionMethodMemberAccessor.java
ReflectionMethodMemberAccessor
toString
class ReflectionMethodMemberAccessor extends AbstractMemberAccessor { private final Class<?> returnType; private final String methodName; private final Method readMethod; public ReflectionMethodMemberAccessor(Method readMethod) { this.readMethod = readMethod; readMethod.setAccessible(true); // Performance hack by avoiding security checks returnType = readMethod.getReturnType(); methodName = readMethod.getName(); if (readMethod.getParameterTypes().length != 0) { throw new IllegalArgumentException("The readMethod (" + readMethod + ") must not have any parameters (" + Arrays.toString(readMethod.getParameterTypes()) + ")."); } if (readMethod.getReturnType() == void.class) { throw new IllegalArgumentException("The readMethod (" + readMethod + ") must have a return type (" + readMethod.getReturnType() + ")."); } } @Override public Class<?> getDeclaringClass() { return readMethod.getDeclaringClass(); } @Override public String getName() { return methodName; } @Override public Class<?> getType() { return returnType; } @Override public Type getGenericType() { return readMethod.getGenericReturnType(); } @Override public Object executeGetter(Object bean) { try { return readMethod.invoke(bean); } catch (IllegalAccessException e) { throw new IllegalStateException("Cannot call property (" + methodName + ") getterMethod (" + readMethod + ") on bean of class (" + bean.getClass() + ").\n" + MemberAccessorFactory.CLASSLOADER_NUDGE_MESSAGE, e); } catch (InvocationTargetException e) { throw new IllegalStateException("The property (" + methodName + ") getterMethod (" + readMethod + ") on bean of class (" + bean.getClass() + ") throws an exception.", e.getCause()); } } @Override public String getSpeedNote() { return "slow access with reflection"; } @Override public boolean supportSetter() { return false; } @Override public void executeSetter(Object bean, Object value) { throw new UnsupportedOperationException(); } @Override public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { return readMethod.getAnnotation(annotationClass); } @Override public <T extends Annotation> T[] getDeclaredAnnotationsByType(Class<T> annotationClass) { return readMethod.getDeclaredAnnotationsByType(annotationClass); } @Override public String toString() {<FILL_FUNCTION_BODY>} }
return "method " + methodName + " on " + readMethod.getDeclaringClass();
718
25
743
<methods>public non-sealed void <init>() ,public final Function<Fact_,Result_> getGetterFunction() <variables>private final Function#RAW getterFunction
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/common/accessor/gizmo/GizmoClassLoader.java
GizmoClassLoader
findClass
class GizmoClassLoader extends ClassLoader { private final Map<String, byte[]> classNameToBytecodeMap = new HashMap<>(); public GizmoClassLoader() { /* * As parent, Gizmo needs to use the same ClassLoader that loaded its own class. * Otherwise, issues will arise in Quarkus with MemberAccessors which were first loaded by Quarkus * and then loaded again by Gizmo, which uses the default parent ClassLoader. */ super(GizmoClassLoader.class.getClassLoader()); } @Override public String getName() { return "OptaPlanner Solver Gizmo ClassLoader"; } @Override public Class<?> findClass(String name) throws ClassNotFoundException {<FILL_FUNCTION_BODY>} public synchronized byte[] getBytecodeFor(String className) { return classNameToBytecodeMap.get(className); } public boolean hasBytecodeFor(String className) { return getBytecodeFor(className) != null; } public synchronized void storeBytecode(String className, byte[] bytecode) { classNameToBytecodeMap.put(className, bytecode); } }
byte[] byteCode = getBytecodeFor(name); if (byteCode == null) { // Not a Gizmo generated class; load from context class loader. return Thread.currentThread().getContextClassLoader().loadClass(name); } else { // Gizmo generated class. return defineClass(name, byteCode, 0, byteCode.length); }
308
94
402
<methods>public void clearAssertionStatus() ,public final java.lang.Package getDefinedPackage(java.lang.String) ,public final java.lang.Package[] getDefinedPackages() ,public java.lang.String getName() ,public final java.lang.ClassLoader getParent() ,public static java.lang.ClassLoader getPlatformClassLoader() ,public java.net.URL getResource(java.lang.String) ,public java.io.InputStream getResourceAsStream(java.lang.String) ,public Enumeration<java.net.URL> getResources(java.lang.String) throws java.io.IOException,public static java.lang.ClassLoader getSystemClassLoader() ,public static java.net.URL getSystemResource(java.lang.String) ,public static java.io.InputStream getSystemResourceAsStream(java.lang.String) ,public static Enumeration<java.net.URL> getSystemResources(java.lang.String) throws java.io.IOException,public final java.lang.Module getUnnamedModule() ,public final boolean isRegisteredAsParallelCapable() ,public Class<?> loadClass(java.lang.String) throws java.lang.ClassNotFoundException,public Stream<java.net.URL> resources(java.lang.String) ,public void setClassAssertionStatus(java.lang.String, boolean) ,public void setDefaultAssertionStatus(boolean) ,public void setPackageAssertionStatus(java.lang.String, boolean) <variables>static final boolean $assertionsDisabled,final java.lang.Object assertionLock,Map<java.lang.String,java.lang.Boolean> classAssertionStatus,private volatile ConcurrentHashMap<?,?> classLoaderValueMap,private final ArrayList<Class<?>> classes,private boolean defaultAssertionStatus,private final java.security.ProtectionDomain defaultDomain,private final jdk.internal.loader.NativeLibraries libraries,private final java.lang.String name,private final java.lang.String nameAndId,private static final java.security.cert.Certificate[] nocerts,private final ConcurrentHashMap<java.lang.String,java.security.cert.Certificate[]> package2certs,private Map<java.lang.String,java.lang.Boolean> packageAssertionStatus,private final ConcurrentHashMap<java.lang.String,java.lang.NamedPackage> packages,private final ConcurrentHashMap<java.lang.String,java.lang.Object> parallelLockMap,private final java.lang.ClassLoader parent,private static volatile java.lang.ClassLoader scl,private final java.lang.Module unnamedModule
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/common/accessor/gizmo/GizmoMemberAccessorFactory.java
GizmoMemberAccessorFactory
buildGizmoMemberAccessor
class GizmoMemberAccessorFactory { /** * Returns the generated class name for a given member. * (Here as accessing any method of GizmoMemberAccessorImplementor * will try to load Gizmo code) * * @param member The member to get the generated class name for * @return The generated class name for member */ public static String getGeneratedClassName(Member member) { String memberName = Objects.requireNonNullElse(ReflectionHelper.getGetterPropertyName(member), member.getName()); String memberType = (member instanceof Field) ? "Field" : "Method"; return member.getDeclaringClass().getName() + "$OptaPlanner$MemberAccessor$" + memberType + "$" + memberName; } public static MemberAccessor buildGizmoMemberAccessor(Member member, Class<? extends Annotation> annotationClass, GizmoClassLoader gizmoClassLoader) {<FILL_FUNCTION_BODY>} private GizmoMemberAccessorFactory() { } }
try { // Check if Gizmo on the classpath by verifying we can access one of its classes Class.forName("io.quarkus.gizmo.ClassCreator", false, Thread.currentThread().getContextClassLoader()); } catch (ClassNotFoundException e) { throw new IllegalStateException("When using the domainAccessType (" + DomainAccessType.GIZMO + ") the classpath or modulepath must contain io.quarkus.gizmo:gizmo.\n" + "Maybe add a dependency to io.quarkus.gizmo:gizmo."); } return GizmoMemberAccessorImplementor.createAccessorFor(member, annotationClass, gizmoClassLoader);
266
184
450
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/common/accessor/gizmo/GizmoMemberDescriptor.java
GizmoMemberDescriptor
lookupSetter
class GizmoMemberDescriptor { /** * The name of a member. * For a field, it is the field name. * For a method, * if it is a getter, the method name without "get"/"is" and the first letter lowercase; * otherwise, the method name. */ private final String name; private final GizmoMemberHandler memberHandler; /** * Should only be used for metadata (i.e. Generic Type and Annotated Element). */ private final GizmoMemberHandler metadataHandler; /** * The MethodDescriptor of the corresponding setter. Empty if not present. */ private final MethodDescriptor setter; public GizmoMemberDescriptor(Member member) { Class<?> declaringClass = member.getDeclaringClass(); if (!Modifier.isPublic(member.getModifiers())) { throw new IllegalStateException("Member (" + member.getName() + ") of class (" + member.getDeclaringClass().getName() + ") is not public and domainAccessType is GIZMO.\n" + ((member instanceof Field) ? "Maybe put the annotations onto the public getter of the field.\n" : "") + "Maybe use domainAccessType REFLECTION instead of GIZMO."); } if (member instanceof Field) { FieldDescriptor fieldDescriptor = FieldDescriptor.of((Field) member); this.name = member.getName(); this.memberHandler = GizmoMemberHandler.of(declaringClass, name, fieldDescriptor, false); this.setter = null; } else if (member instanceof Method) { MethodDescriptor methodDescriptor = MethodDescriptor.ofMethod((Method) member); this.name = ReflectionHelper.isGetterMethod((Method) member) ? ReflectionHelper.getGetterPropertyName(member) : member.getName(); this.memberHandler = GizmoMemberHandler.of(declaringClass, methodDescriptor); this.setter = lookupSetter(methodDescriptor, declaringClass, name).orElse(null); } else { throw new IllegalArgumentException(member + " is not a Method or a Field."); } this.metadataHandler = this.memberHandler; } public GizmoMemberDescriptor(String name, FieldDescriptor fieldDescriptor, Class<?> declaringClass) { this.name = name; this.memberHandler = GizmoMemberHandler.of(declaringClass, name, fieldDescriptor, true); this.metadataHandler = this.memberHandler; this.setter = null; } public GizmoMemberDescriptor(String name, MethodDescriptor memberDescriptor, MethodDescriptor metadataDescriptor, Class<?> declaringClass, MethodDescriptor setterDescriptor) { this.name = name; this.memberHandler = GizmoMemberHandler.of(declaringClass, memberDescriptor); this.metadataHandler = memberDescriptor == metadataDescriptor ? this.memberHandler : GizmoMemberHandler.of(declaringClass, metadataDescriptor); this.setter = setterDescriptor; } public GizmoMemberDescriptor(String name, MethodDescriptor memberDescriptor, Class<?> declaringClass, MethodDescriptor setterDescriptor) { this.name = name; this.memberHandler = GizmoMemberHandler.of(declaringClass, memberDescriptor); this.metadataHandler = this.memberHandler; this.setter = setterDescriptor; } public GizmoMemberDescriptor(String name, MethodDescriptor memberDescriptor, FieldDescriptor metadataDescriptor, Class<?> declaringClass, MethodDescriptor setterDescriptor) { this.name = name; this.memberHandler = GizmoMemberHandler.of(declaringClass, memberDescriptor); this.metadataHandler = GizmoMemberHandler.of(declaringClass, name, metadataDescriptor, true); this.setter = setterDescriptor; } /** * If the member accessor is a field, pass the member's field descriptor to the * provided consumer. Otherwise, do nothing. Returns self for chaining. * * @param fieldDescriptorConsumer What to do if the member a field. * @return this */ public GizmoMemberDescriptor whenIsField(Consumer<FieldDescriptor> fieldDescriptorConsumer) { memberHandler.whenIsField(fieldDescriptorConsumer); return this; } /** * If the member accessor is a method, pass the member's method descriptor to the * provided consumer. Otherwise, do nothing. Returns self for chaining. * * @param methodDescriptorConsumer What to do if the member a method. * @return this */ public GizmoMemberDescriptor whenIsMethod(Consumer<MethodDescriptor> methodDescriptorConsumer) { memberHandler.whenIsMethod(methodDescriptorConsumer); return this; } public ResultHandle readMemberValue(BytecodeCreator bytecodeCreator, ResultHandle thisObj) { return memberHandler.readMemberValue(bytecodeCreator, thisObj); } /** * Write the bytecode for writing to this member. If there is no setter, * it write the bytecode for throwing the exception. Return true if * it was able to write the member value. * * @param bytecodeCreator the bytecode creator to use * @param thisObj the bean to write the new value to * @param newValue to new value of the member * @return True if it was able to write the member value, false otherwise */ public boolean writeMemberValue(BytecodeCreator bytecodeCreator, ResultHandle thisObj, ResultHandle newValue) { return memberHandler.writeMemberValue(setter, bytecodeCreator, thisObj, newValue); } /** * If the member metadata is on a field, pass the member's field descriptor to the * provided consumer. Otherwise, do nothing. Returns self for chaining. * * @param fieldDescriptorConsumer What to do if the member a field. * @return this */ public GizmoMemberDescriptor whenMetadataIsOnField(Consumer<FieldDescriptor> fieldDescriptorConsumer) { metadataHandler.whenIsField(fieldDescriptorConsumer); return this; } /** * If the member metadata is on a method, pass the member's method descriptor to the * provided consumer. Otherwise, do nothing. Returns self for chaining. * * @param methodDescriptorConsumer What to do if the member a method. * @return this */ public GizmoMemberDescriptor whenMetadataIsOnMethod(Consumer<MethodDescriptor> methodDescriptorConsumer) { metadataHandler.whenIsMethod(methodDescriptorConsumer); return this; } /** * Returns the declaring class name of the member in descriptor format. * For instance, the declaring class name of Object.toString() is "java/lang/Object". * * @return Returns the declaring class name of the member in descriptor format */ public String getDeclaringClassName() { return memberHandler.getDeclaringClassName(); } public Optional<MethodDescriptor> getSetter() { return Optional.ofNullable(setter); } private static Optional<MethodDescriptor> lookupSetter(Object memberDescriptor, Class<?> declaringClass, String name) {<FILL_FUNCTION_BODY>} public String getName() { return name; } /** * Returns the member type (for fields) / return type (for methods) name. * The name does not include generic information. */ public String getTypeName() { String typeName = metadataHandler.getTypeName(); return org.objectweb.asm.Type.getType(typeName).getClassName(); } public Type getType() { return metadataHandler.getType(); } @Override public String toString() { return memberHandler.toString(); } }
if (memberDescriptor instanceof MethodDescriptor) { return Optional.ofNullable(ReflectionHelper.getSetterMethod(declaringClass, name)) .map(MethodDescriptor::ofMethod); } else { return Optional.empty(); }
1,947
63
2,010
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/common/accessor/gizmo/GizmoMethodHandler.java
GizmoMethodHandler
getType
class GizmoMethodHandler implements GizmoMemberHandler { private final Class<?> declaringClass; private final MethodDescriptor methodDescriptor; GizmoMethodHandler(Class<?> declaringClass, MethodDescriptor methodDescriptor) { this.declaringClass = declaringClass; this.methodDescriptor = methodDescriptor; } @Override public void whenIsField(Consumer<FieldDescriptor> fieldDescriptorConsumer) { // Do nothing, } @Override public void whenIsMethod(Consumer<MethodDescriptor> methodDescriptorConsumer) { methodDescriptorConsumer.accept(methodDescriptor); } @Override public ResultHandle readMemberValue(BytecodeCreator bytecodeCreator, ResultHandle thisObj) { return invokeMemberMethod(declaringClass, bytecodeCreator, methodDescriptor, thisObj); } @Override public boolean writeMemberValue(MethodDescriptor setter, BytecodeCreator bytecodeCreator, ResultHandle thisObj, ResultHandle newValue) { if (setter == null) { return false; } else { invokeMemberMethod(declaringClass, bytecodeCreator, setter, thisObj, newValue); return true; } } private ResultHandle invokeMemberMethod(Class<?> declaringClass, BytecodeCreator creator, MethodDescriptor method, ResultHandle bean, ResultHandle... parameters) { if (declaringClass.isInterface()) { return creator.invokeInterfaceMethod(method, bean, parameters); } else { return creator.invokeVirtualMethod(method, bean, parameters); } } @Override public String getDeclaringClassName() { return methodDescriptor.getDeclaringClass(); } @Override public String getTypeName() { return methodDescriptor.getReturnType(); } @Override public Type getType() {<FILL_FUNCTION_BODY>} @Override public String toString() { return methodDescriptor.toString(); } }
try { return declaringClass.getDeclaredMethod(methodDescriptor.getName()).getGenericReturnType(); } catch (NoSuchMethodException e) { throw new IllegalStateException( "Cannot find method (" + methodDescriptor.getName() + ") on class (" + declaringClass + ").", e); }
507
82
589
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/constraintweight/descriptor/ConstraintConfigurationDescriptor.java
ConstraintConfigurationDescriptor
processAnnotations
class ConstraintConfigurationDescriptor<Solution_> { private final SolutionDescriptor<Solution_> solutionDescriptor; private final Class<?> constraintConfigurationClass; private String constraintPackage; private final Map<String, ConstraintWeightDescriptor<Solution_>> constraintWeightDescriptorMap; // ************************************************************************ // Constructors and simple getters/setters // ************************************************************************ public ConstraintConfigurationDescriptor(SolutionDescriptor<Solution_> solutionDescriptor, Class<?> constraintConfigurationClass) { this.solutionDescriptor = solutionDescriptor; this.constraintConfigurationClass = constraintConfigurationClass; constraintWeightDescriptorMap = new LinkedHashMap<>(); } public String getConstraintPackage() { return constraintPackage; } public Collection<ConstraintWeightDescriptor<Solution_>> getConstraintWeightDescriptors() { return constraintWeightDescriptorMap.values(); } public ConstraintWeightDescriptor<Solution_> getConstraintWeightDescriptor(String propertyName) { return constraintWeightDescriptorMap.get(propertyName); } // ************************************************************************ // Lifecycle methods // ************************************************************************ public void processAnnotations(DescriptorPolicy descriptorPolicy, ScoreDefinition scoreDefinition) {<FILL_FUNCTION_BODY>} private void processPackAnnotation(DescriptorPolicy descriptorPolicy) { ConstraintConfiguration packAnnotation = constraintConfigurationClass.getAnnotation(ConstraintConfiguration.class); if (packAnnotation == null) { throw new IllegalStateException("The constraintConfigurationClass (" + constraintConfigurationClass + ") has been specified as a @" + ConstraintConfigurationProvider.class.getSimpleName() + " in the solution class (" + solutionDescriptor.getSolutionClass() + ")," + " but does not have a @" + ConstraintConfiguration.class.getSimpleName() + " annotation."); } // If a @ConstraintConfiguration extends a @ConstraintConfiguration, their constraintPackage might differ. // So the ConstraintWeightDescriptors parse packAnnotation.constraintPackage() themselves. constraintPackage = packAnnotation.constraintPackage(); if (constraintPackage.isEmpty()) { Package pack = constraintConfigurationClass.getPackage(); constraintPackage = (pack == null) ? "" : pack.getName(); } } private void processParameterAnnotation(DescriptorPolicy descriptorPolicy, Member member, ScoreDefinition scoreDefinition) { if (((AnnotatedElement) member).isAnnotationPresent(ConstraintWeight.class)) { MemberAccessor memberAccessor = descriptorPolicy.getMemberAccessorFactory().buildAndCacheMemberAccessor(member, FIELD_OR_READ_METHOD, ConstraintWeight.class, descriptorPolicy.getDomainAccessType()); if (constraintWeightDescriptorMap.containsKey(memberAccessor.getName())) { MemberAccessor duplicate = constraintWeightDescriptorMap.get(memberAccessor.getName()).getMemberAccessor(); throw new IllegalStateException("The constraintConfigurationClass (" + constraintConfigurationClass + ") has a @" + ConstraintWeight.class.getSimpleName() + " annotated member (" + memberAccessor + ") that is duplicated by a member (" + duplicate + ").\n" + "Maybe the annotation is defined on both the field and its getter."); } if (!scoreDefinition.getScoreClass().isAssignableFrom(memberAccessor.getType())) { throw new IllegalStateException("The constraintConfigurationClass (" + constraintConfigurationClass + ") has a @" + ConstraintWeight.class.getSimpleName() + " annotated member (" + memberAccessor + ") with a return type (" + memberAccessor.getType() + ") that is not assignable to the score class (" + scoreDefinition.getScoreClass() + ").\n" + "Maybe make that member (" + memberAccessor.getName() + ") return the score class (" + scoreDefinition.getScoreClass().getSimpleName() + ") instead."); } ConstraintWeightDescriptor<Solution_> constraintWeightDescriptor = new ConstraintWeightDescriptor<>(this, memberAccessor); constraintWeightDescriptorMap.put(memberAccessor.getName(), constraintWeightDescriptor); } } // ************************************************************************ // Worker methods // ************************************************************************ public SolutionDescriptor<Solution_> getSolutionDescriptor() { return solutionDescriptor; } public Class<?> getConstraintConfigurationClass() { return constraintConfigurationClass; } public ConstraintWeightDescriptor<Solution_> findConstraintWeightDescriptor(String constraintPackage, String constraintName) { return constraintWeightDescriptorMap.values().stream().filter( constraintWeightDescriptor -> constraintWeightDescriptor.getConstraintPackage().equals(constraintPackage) && constraintWeightDescriptor.getConstraintName().equals(constraintName)) .findFirst().orElse(null); } @Override public String toString() { return getClass().getSimpleName() + "(" + constraintConfigurationClass.getName() + ")"; } }
processPackAnnotation(descriptorPolicy); ArrayList<Method> potentiallyOverwritingMethodList = new ArrayList<>(); // Iterate inherited members too (unlike for EntityDescriptor where each one is declared) // to make sure each one is registered for (Class<?> lineageClass : ConfigUtils.getAllAnnotatedLineageClasses(constraintConfigurationClass, ConstraintConfiguration.class)) { List<Member> memberList = ConfigUtils.getDeclaredMembers(lineageClass); for (Member member : memberList) { if (member instanceof Method && potentiallyOverwritingMethodList.stream().anyMatch( m -> member.getName().equals(m.getName()) // Shortcut to discard negatives faster && ReflectionHelper.isMethodOverwritten((Method) member, m.getDeclaringClass()))) { // Ignore member because it is an overwritten method continue; } processParameterAnnotation(descriptorPolicy, member, scoreDefinition); } potentiallyOverwritingMethodList.ensureCapacity(potentiallyOverwritingMethodList.size() + memberList.size()); memberList.stream().filter(member -> member instanceof Method) .forEach(member -> potentiallyOverwritingMethodList.add((Method) member)); } if (constraintWeightDescriptorMap.isEmpty()) { throw new IllegalStateException("The constraintConfigurationClass (" + constraintConfigurationClass + ") must have at least 1 member with a " + ConstraintWeight.class.getSimpleName() + " annotation."); }
1,204
364
1,568
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/constraintweight/descriptor/ConstraintWeightDescriptor.java
ConstraintWeightDescriptor
createExtractor
class ConstraintWeightDescriptor<Solution_> { private final ConstraintConfigurationDescriptor<Solution_> constraintConfigurationDescriptor; private final String constraintPackage; private final String constraintName; private final MemberAccessor memberAccessor; // ************************************************************************ // Constructors and simple getters/setters // ************************************************************************ public ConstraintWeightDescriptor(ConstraintConfigurationDescriptor<Solution_> constraintConfigurationDescriptor, MemberAccessor memberAccessor) { this.constraintConfigurationDescriptor = constraintConfigurationDescriptor; ConstraintWeight constraintWeightAnnotation = memberAccessor.getAnnotation(ConstraintWeight.class); String constraintPackage = constraintWeightAnnotation.constraintPackage(); if (constraintPackage.isEmpty()) { // If a @ConstraintConfiguration extends a @ConstraintConfiguration, their constraintPackage might differ. ConstraintConfiguration constraintConfigurationAnnotation = memberAccessor.getDeclaringClass() .getAnnotation(ConstraintConfiguration.class); if (constraintConfigurationAnnotation == null) { throw new IllegalStateException("Impossible state: " + ConstraintConfigurationDescriptor.class.getSimpleName() + " only reflects over members with a @" + ConstraintConfiguration.class.getSimpleName() + " annotation."); } constraintPackage = constraintConfigurationAnnotation.constraintPackage(); if (constraintPackage.isEmpty()) { Package pack = memberAccessor.getDeclaringClass().getPackage(); constraintPackage = (pack == null) ? "" : pack.getName(); } } this.constraintPackage = constraintPackage; this.constraintName = constraintWeightAnnotation.value(); this.memberAccessor = memberAccessor; } public String getConstraintPackage() { return constraintPackage; } public String getConstraintName() { return constraintName; } public MemberAccessor getMemberAccessor() { return memberAccessor; } public Function<Solution_, Score<?>> createExtractor() {<FILL_FUNCTION_BODY>} @Override public String toString() { return constraintPackage + ":" + constraintName; } }
SolutionDescriptor<Solution_> solutionDescriptor = constraintConfigurationDescriptor.getSolutionDescriptor(); MemberAccessor constraintConfigurationMemberAccessor = solutionDescriptor.getConstraintConfigurationMemberAccessor(); return (Solution_ solution) -> { Object constraintConfiguration = Objects.requireNonNull( constraintConfigurationMemberAccessor.executeGetter(solution), "Constraint configuration provider (" + constraintConfigurationMemberAccessor + ") returns null."); return (Score<?>) memberAccessor.executeGetter(constraintConfiguration); };
511
129
640
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/lookup/ClassAndPlanningIdComparator.java
ClassAndPlanningIdComparator
compare
class ClassAndPlanningIdComparator implements Comparator<Object> { private final MemberAccessorFactory memberAccessorFactory; private final DomainAccessType domainAccessType; private final boolean failFastIfNoPlanningId; private final Map<Class, MemberAccessor> decisionCache = new HashMap<>(); public ClassAndPlanningIdComparator(MemberAccessorFactory memberAccessorFactory, DomainAccessType domainAccessType, boolean failFastIfNoPlanningId) { this.memberAccessorFactory = memberAccessorFactory; this.domainAccessType = domainAccessType; this.failFastIfNoPlanningId = failFastIfNoPlanningId; } @Override public int compare(Object a, Object b) {<FILL_FUNCTION_BODY>} private MemberAccessor findMemberAccessor(Class<?> clazz) { return ConfigUtils.findPlanningIdMemberAccessor(clazz, memberAccessorFactory, domainAccessType); } }
if (a == null) { return b == null ? 0 : -1; } else if (b == null) { return 1; } Class<?> aClass = a.getClass(); Class<?> bClass = b.getClass(); if (aClass != bClass) { return aClass.getName().compareTo(bClass.getName()); } MemberAccessor aMemberAccessor = decisionCache.computeIfAbsent(aClass, this::findMemberAccessor); MemberAccessor bMemberAccessor = decisionCache.computeIfAbsent(bClass, this::findMemberAccessor); if (failFastIfNoPlanningId) { if (aMemberAccessor == null) { throw new IllegalArgumentException("The class (" + aClass + ") does not have a @" + PlanningId.class.getSimpleName() + " annotation.\n" + "Maybe add the @" + PlanningId.class.getSimpleName() + " annotation."); } if (bMemberAccessor == null) { throw new IllegalArgumentException("The class (" + bClass + ") does not have a @" + PlanningId.class.getSimpleName() + " annotation.\n" + "Maybe add the @" + PlanningId.class.getSimpleName() + " annotation."); } } else { if (aMemberAccessor == null) { if (bMemberAccessor == null) { if (a instanceof Comparable) { return ((Comparable) a).compareTo(b); } else { // Return 0 to keep original order. return 0; } } else { return -1; } } else if (bMemberAccessor == null) { return 1; } } Comparable aPlanningId = (Comparable) aMemberAccessor.executeGetter(a); Comparable bPlanningId = (Comparable) bMemberAccessor.executeGetter(b); if (aPlanningId == null) { throw new IllegalArgumentException("The planningId (" + aPlanningId + ") of the member (" + aMemberAccessor + ") of the class (" + aClass + ") on object (" + a + ") must not be null.\n" + "Maybe initialize the planningId of the original object before solving.."); } if (bPlanningId == null) { throw new IllegalArgumentException("The planningId (" + bPlanningId + ") of the member (" + bMemberAccessor + ") of the class (" + bClass + ") on object (" + a + ") must not be null.\n" + "Maybe initialize the planningId of the original object before solving.."); } // If a and b are different classes, this method would have already returned. return aPlanningId.compareTo(bPlanningId);
249
703
952
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/lookup/EqualsLookUpStrategy.java
EqualsLookUpStrategy
removeWorkingObject
class EqualsLookUpStrategy implements LookUpStrategy { @Override public void addWorkingObject(Map<Object, Object> idToWorkingObjectMap, Object workingObject) { Object oldAddedObject = idToWorkingObjectMap.put(workingObject, workingObject); if (oldAddedObject != null) { throw new IllegalStateException("The workingObjects (" + oldAddedObject + ", " + workingObject + ") are equal (as in Object.equals()). Working objects must be unique."); } } @Override public void removeWorkingObject(Map<Object, Object> idToWorkingObjectMap, Object workingObject) {<FILL_FUNCTION_BODY>} @Override public <E> E lookUpWorkingObject(Map<Object, Object> idToWorkingObjectMap, E externalObject) { E workingObject = (E) idToWorkingObjectMap.get(externalObject); if (workingObject == null) { throw new IllegalStateException("The externalObject (" + externalObject + ") has no known workingObject (" + workingObject + ").\n" + "Maybe the workingObject was never added because the planning solution doesn't have a @" + ProblemFactCollectionProperty.class.getSimpleName() + " annotation on a member with instances of the externalObject's class (" + externalObject.getClass() + ")."); } return workingObject; } @Override public <E> E lookUpWorkingObjectIfExists(Map<Object, Object> idToWorkingObjectMap, E externalObject) { return (E) idToWorkingObjectMap.get(externalObject); } }
Object removedObject = idToWorkingObjectMap.remove(workingObject); if (workingObject != removedObject) { throw new IllegalStateException("The workingObject (" + workingObject + ") differs from the removedObject (" + removedObject + ")."); }
410
68
478
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/lookup/ImmutableLookUpStrategy.java
ImmutableLookUpStrategy
lookUpWorkingObjectIfExists
class ImmutableLookUpStrategy implements LookUpStrategy { @Override public void addWorkingObject(Map<Object, Object> idToWorkingObjectMap, Object workingObject) { // Do nothing } @Override public void removeWorkingObject(Map<Object, Object> idToWorkingObjectMap, Object workingObject) { // Do nothing } @Override public <E> E lookUpWorkingObject(Map<Object, Object> idToWorkingObjectMap, E externalObject) { // Because it is immutable, we can use the same one. return externalObject; } @Override public <E> E lookUpWorkingObjectIfExists(Map<Object, Object> idToWorkingObjectMap, E externalObject) {<FILL_FUNCTION_BODY>} }
// Because it is immutable, we can use the same one. return externalObject;
206
25
231
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/lookup/LookUpManager.java
LookUpManager
lookUpWorkingObject
class LookUpManager { private final LookUpStrategyResolver lookUpStrategyResolver; private Map<Object, Object> idToWorkingObjectMap; public LookUpManager(LookUpStrategyResolver lookUpStrategyResolver) { this.lookUpStrategyResolver = lookUpStrategyResolver; reset(); } public void reset() { idToWorkingObjectMap = new HashMap<>(); } public void addWorkingObject(Object workingObject) { LookUpStrategy lookUpStrategy = lookUpStrategyResolver.determineLookUpStrategy(workingObject); lookUpStrategy.addWorkingObject(idToWorkingObjectMap, workingObject); } public void removeWorkingObject(Object workingObject) { LookUpStrategy lookUpStrategy = lookUpStrategyResolver.determineLookUpStrategy(workingObject); lookUpStrategy.removeWorkingObject(idToWorkingObjectMap, workingObject); } /** * As defined by {@link ScoreDirector#lookUpWorkingObject(Object)}. * * @param externalObject sometimes null * @return null if externalObject is null * @throws IllegalArgumentException if there is no workingObject for externalObject, if it cannot be looked up * or if the externalObject's class is not supported * @throws IllegalStateException if it cannot be looked up * @param <E> the object type */ public <E> E lookUpWorkingObject(E externalObject) {<FILL_FUNCTION_BODY>} /** * As defined by {@link ScoreDirector#lookUpWorkingObjectOrReturnNull(Object)}. * * @param externalObject sometimes null * @return null if externalObject is null or if there is no workingObject for externalObject * @throws IllegalArgumentException if it cannot be looked up or if the externalObject's class is not supported * @throws IllegalStateException if it cannot be looked up * @param <E> the object type */ public <E> E lookUpWorkingObjectOrReturnNull(E externalObject) { if (externalObject == null) { return null; } LookUpStrategy lookUpStrategy = lookUpStrategyResolver.determineLookUpStrategy(externalObject); return lookUpStrategy.lookUpWorkingObjectIfExists(idToWorkingObjectMap, externalObject); } }
if (externalObject == null) { return null; } LookUpStrategy lookUpStrategy = lookUpStrategyResolver.determineLookUpStrategy(externalObject); return lookUpStrategy.lookUpWorkingObject(idToWorkingObjectMap, externalObject);
575
67
642
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/lookup/LookUpStrategyResolver.java
LookUpStrategyResolver
determineLookUpStrategy
class LookUpStrategyResolver { private final LookUpStrategyType lookUpStrategyType; private final DomainAccessType domainAccessType; private final MemberAccessorFactory memberAccessorFactory; private final ConcurrentMap<Class<?>, LookUpStrategy> decisionCache = new ConcurrentHashMap<>(); public LookUpStrategyResolver(DescriptorPolicy descriptorPolicy, LookUpStrategyType lookUpStrategyType) { this.lookUpStrategyType = lookUpStrategyType; this.domainAccessType = descriptorPolicy.getDomainAccessType(); this.memberAccessorFactory = descriptorPolicy.getMemberAccessorFactory(); decisionCache.put(Boolean.class, new ImmutableLookUpStrategy()); decisionCache.put(Byte.class, new ImmutableLookUpStrategy()); decisionCache.put(Short.class, new ImmutableLookUpStrategy()); decisionCache.put(Integer.class, new ImmutableLookUpStrategy()); decisionCache.put(Long.class, new ImmutableLookUpStrategy()); decisionCache.put(Float.class, new ImmutableLookUpStrategy()); decisionCache.put(Double.class, new ImmutableLookUpStrategy()); decisionCache.put(BigInteger.class, new ImmutableLookUpStrategy()); decisionCache.put(BigDecimal.class, new ImmutableLookUpStrategy()); decisionCache.put(Character.class, new ImmutableLookUpStrategy()); decisionCache.put(String.class, new ImmutableLookUpStrategy()); decisionCache.put(UUID.class, new ImmutableLookUpStrategy()); decisionCache.put(Instant.class, new ImmutableLookUpStrategy()); decisionCache.put(LocalDateTime.class, new ImmutableLookUpStrategy()); decisionCache.put(LocalTime.class, new ImmutableLookUpStrategy()); decisionCache.put(LocalDate.class, new ImmutableLookUpStrategy()); decisionCache.put(MonthDay.class, new ImmutableLookUpStrategy()); decisionCache.put(YearMonth.class, new ImmutableLookUpStrategy()); decisionCache.put(Year.class, new ImmutableLookUpStrategy()); decisionCache.put(OffsetDateTime.class, new ImmutableLookUpStrategy()); decisionCache.put(OffsetTime.class, new ImmutableLookUpStrategy()); decisionCache.put(ZonedDateTime.class, new ImmutableLookUpStrategy()); decisionCache.put(ZoneOffset.class, new ImmutableLookUpStrategy()); decisionCache.put(Duration.class, new ImmutableLookUpStrategy()); decisionCache.put(Period.class, new ImmutableLookUpStrategy()); } /** * This method is thread-safe. * * @param object never null * @return never null */ public LookUpStrategy determineLookUpStrategy(Object object) {<FILL_FUNCTION_BODY>} }
return decisionCache.computeIfAbsent(object.getClass(), objectClass -> { if (objectClass.isEnum()) { return new ImmutableLookUpStrategy(); } switch (lookUpStrategyType) { case PLANNING_ID_OR_NONE: MemberAccessor memberAccessor1 = ConfigUtils.findPlanningIdMemberAccessor(objectClass, memberAccessorFactory, domainAccessType); if (memberAccessor1 == null) { return new NoneLookUpStrategy(); } return new PlanningIdLookUpStrategy(memberAccessor1); case PLANNING_ID_OR_FAIL_FAST: MemberAccessor memberAccessor2 = ConfigUtils.findPlanningIdMemberAccessor(objectClass, memberAccessorFactory, domainAccessType); if (memberAccessor2 == null) { throw new IllegalArgumentException("The class (" + objectClass + ") does not have a @" + PlanningId.class.getSimpleName() + " annotation," + " but the lookUpStrategyType (" + lookUpStrategyType + ") requires it.\n" + "Maybe add the @" + PlanningId.class.getSimpleName() + " annotation" + " or change the @" + PlanningSolution.class.getSimpleName() + " annotation's " + LookUpStrategyType.class.getSimpleName() + "."); } return new PlanningIdLookUpStrategy(memberAccessor2); case EQUALITY: Method equalsMethod; Method hashCodeMethod; try { equalsMethod = objectClass.getMethod("equals", Object.class); hashCodeMethod = objectClass.getMethod("hashCode"); } catch (NoSuchMethodException e) { throw new IllegalStateException( "Impossible state because equals() and hashCode() always exist.", e); } if (equalsMethod.getDeclaringClass().equals(Object.class)) { throw new IllegalArgumentException("The class (" + objectClass.getSimpleName() + ") doesn't override the equals() method, neither does any superclass."); } if (hashCodeMethod.getDeclaringClass().equals(Object.class)) { throw new IllegalArgumentException("The class (" + objectClass.getSimpleName() + ") overrides equals() but neither it nor any superclass" + " overrides the hashCode() method."); } return new EqualsLookUpStrategy(); case NONE: return new NoneLookUpStrategy(); default: throw new IllegalStateException("The lookUpStrategyType (" + lookUpStrategyType + ") is not implemented."); } });
680
641
1,321
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/lookup/PlanningIdLookUpStrategy.java
PlanningIdLookUpStrategy
removeWorkingObject
class PlanningIdLookUpStrategy implements LookUpStrategy { private final MemberAccessor planningIdMemberAccessor; public PlanningIdLookUpStrategy(MemberAccessor planningIdMemberAccessor) { this.planningIdMemberAccessor = planningIdMemberAccessor; } @Override public void addWorkingObject(Map<Object, Object> idToWorkingObjectMap, Object workingObject) { Object planningId = extractPlanningId(workingObject); if (planningId == null) { throw new IllegalStateException("The workingObject (" + workingObject + ") returns a null value for its @" + PlanningId.class.getSimpleName() + " member (" + planningIdMemberAccessor + ")."); } Object oldAddedObject = idToWorkingObjectMap.put(planningId, workingObject); if (oldAddedObject != null) { throw new IllegalStateException("The workingObjects (" + oldAddedObject + ", " + workingObject + ") have the same planningId (" + planningId + "). Working objects must be unique."); } } @Override public void removeWorkingObject(Map<Object, Object> idToWorkingObjectMap, Object workingObject) {<FILL_FUNCTION_BODY>} @Override public <E> E lookUpWorkingObject(Map<Object, Object> idToWorkingObjectMap, E externalObject) { Object planningId = extractPlanningId(externalObject); E workingObject = (E) idToWorkingObjectMap.get(planningId); if (workingObject == null) { throw new IllegalStateException("The externalObject (" + externalObject + ") with planningId (" + planningId + ") has no known workingObject (" + workingObject + ").\n" + "Maybe the workingObject was never added because the planning solution doesn't have a @" + ProblemFactCollectionProperty.class.getSimpleName() + " annotation on a member with instances of the externalObject's class (" + externalObject.getClass() + ")."); } return workingObject; } @Override public <E> E lookUpWorkingObjectIfExists(Map<Object, Object> idToWorkingObjectMap, E externalObject) { Object planningId = extractPlanningId(externalObject); return (E) idToWorkingObjectMap.get(planningId); } protected Object extractPlanningId(Object externalObject) { Object planningId = planningIdMemberAccessor.executeGetter(externalObject); if (planningId == null) { throw new IllegalArgumentException("The planningId (" + planningId + ") of the member (" + planningIdMemberAccessor + ") of the class (" + externalObject.getClass() + ") on externalObject (" + externalObject + ") must not be null.\n" + "Maybe initialize the planningId of the class (" + externalObject.getClass().getSimpleName() + ") instance (" + externalObject + ") before solving.\n" + "Maybe remove the @" + PlanningId.class.getSimpleName() + " annotation" + " or change the @" + PlanningSolution.class.getSimpleName() + " annotation's " + LookUpStrategyType.class.getSimpleName() + "."); } return Pair.of(externalObject.getClass(), planningId); } }
Object planningId = extractPlanningId(workingObject); if (planningId == null) { throw new IllegalStateException("The workingObject (" + workingObject + ") returns a null value for its @" + PlanningId.class.getSimpleName() + " member (" + planningIdMemberAccessor + ")."); } Object removedObject = idToWorkingObjectMap.remove(planningId); if (workingObject != removedObject) { throw new IllegalStateException("The workingObject (" + workingObject + ") differs from the removedObject (" + removedObject + ") for planningId (" + planningId + ")."); }
822
158
980
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/policy/DescriptorPolicy.java
DescriptorPolicy
getValueRangeProviderIds
class DescriptorPolicy { private Map<String, SolutionCloner> generatedSolutionClonerMap = new LinkedHashMap<>(); private final Map<String, MemberAccessor> fromSolutionValueRangeProviderMap = new LinkedHashMap<>(); private final Set<MemberAccessor> anonymousFromSolutionValueRangeProviderSet = new LinkedHashSet<>(); private final Map<String, MemberAccessor> fromEntityValueRangeProviderMap = new LinkedHashMap<>(); private final Set<MemberAccessor> anonymousFromEntityValueRangeProviderSet = new LinkedHashSet<>(); private DomainAccessType domainAccessType = DomainAccessType.REFLECTION; private MemberAccessorFactory memberAccessorFactory; public void addFromSolutionValueRangeProvider(MemberAccessor memberAccessor) { String id = extractValueRangeProviderId(memberAccessor); if (id == null) { anonymousFromSolutionValueRangeProviderSet.add(memberAccessor); } else { fromSolutionValueRangeProviderMap.put(id, memberAccessor); } } public boolean isFromSolutionValueRangeProvider(MemberAccessor memberAccessor) { return fromSolutionValueRangeProviderMap.containsValue(memberAccessor) || anonymousFromSolutionValueRangeProviderSet.contains(memberAccessor); } public boolean hasFromSolutionValueRangeProvider(String id) { return fromSolutionValueRangeProviderMap.containsKey(id); } public MemberAccessor getFromSolutionValueRangeProvider(String id) { return fromSolutionValueRangeProviderMap.get(id); } public Set<MemberAccessor> getAnonymousFromSolutionValueRangeProviderSet() { return anonymousFromSolutionValueRangeProviderSet; } public void addFromEntityValueRangeProvider(MemberAccessor memberAccessor) { String id = extractValueRangeProviderId(memberAccessor); if (id == null) { anonymousFromEntityValueRangeProviderSet.add(memberAccessor); } else { fromEntityValueRangeProviderMap.put(id, memberAccessor); } } public boolean isFromEntityValueRangeProvider(MemberAccessor memberAccessor) { return fromEntityValueRangeProviderMap.containsValue(memberAccessor) || anonymousFromEntityValueRangeProviderSet.contains(memberAccessor); } public boolean hasFromEntityValueRangeProvider(String id) { return fromEntityValueRangeProviderMap.containsKey(id); } public Set<MemberAccessor> getAnonymousFromEntityValueRangeProviderSet() { return anonymousFromEntityValueRangeProviderSet; } /** * @return never null */ public DomainAccessType getDomainAccessType() { return domainAccessType; } public void setDomainAccessType(DomainAccessType domainAccessType) { this.domainAccessType = domainAccessType; } /** * @return never null */ public Map<String, SolutionCloner> getGeneratedSolutionClonerMap() { return generatedSolutionClonerMap; } public void setGeneratedSolutionClonerMap(Map<String, SolutionCloner> generatedSolutionClonerMap) { this.generatedSolutionClonerMap = generatedSolutionClonerMap; } public MemberAccessorFactory getMemberAccessorFactory() { return memberAccessorFactory; } public void setMemberAccessorFactory(MemberAccessorFactory memberAccessorFactory) { this.memberAccessorFactory = memberAccessorFactory; } public MemberAccessor getFromEntityValueRangeProvider(String id) { return fromEntityValueRangeProviderMap.get(id); } private String extractValueRangeProviderId(MemberAccessor memberAccessor) { ValueRangeProvider annotation = memberAccessor.getAnnotation(ValueRangeProvider.class); String id = annotation.id(); if (id == null || id.isEmpty()) { return null; } validateUniqueValueRangeProviderId(id, memberAccessor); return id; } private void validateUniqueValueRangeProviderId(String id, MemberAccessor memberAccessor) { MemberAccessor duplicate = fromSolutionValueRangeProviderMap.get(id); if (duplicate != null) { throw new IllegalStateException("2 members (" + duplicate + ", " + memberAccessor + ") with a @" + ValueRangeProvider.class.getSimpleName() + " annotation must not have the same id (" + id + ")."); } duplicate = fromEntityValueRangeProviderMap.get(id); if (duplicate != null) { throw new IllegalStateException("2 members (" + duplicate + ", " + memberAccessor + ") with a @" + ValueRangeProvider.class.getSimpleName() + " annotation must not have the same id (" + id + ")."); } } public Collection<String> getValueRangeProviderIds() {<FILL_FUNCTION_BODY>} }
List<String> valueRangeProviderIds = new ArrayList<>( fromSolutionValueRangeProviderMap.size() + fromEntityValueRangeProviderMap.size()); valueRangeProviderIds.addAll(fromSolutionValueRangeProviderMap.keySet()); valueRangeProviderIds.addAll(fromEntityValueRangeProviderMap.keySet()); return valueRangeProviderIds;
1,230
89
1,319
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/solution/cloner/ConcurrentMemoization.java
ConcurrentMemoization
computeIfAbsent
class ConcurrentMemoization<K, V> extends ConcurrentHashMap<K, V> { /** * An overridden implementation that heavily favors read access over write access speed. * This is thread-safe. * * {@inheritDoc} */ @Override public V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) {<FILL_FUNCTION_BODY>} }
V value = get(key); if (value != null) { return value; } return super.computeIfAbsent(key, mappingFunction);
113
45
158
<methods>public void <init>() ,public void <init>(int) ,public void <init>(Map<? extends K,? extends V>) ,public void <init>(int, float) ,public void <init>(int, float, int) ,public void clear() ,public V compute(K, BiFunction<? super K,? super V,? extends V>) ,public V computeIfAbsent(K, Function<? super K,? extends V>) ,public V computeIfPresent(K, BiFunction<? super K,? super V,? extends V>) ,public boolean contains(java.lang.Object) ,public boolean containsKey(java.lang.Object) ,public boolean containsValue(java.lang.Object) ,public Enumeration<V> elements() ,public Set<Entry<K,V>> entrySet() ,public boolean equals(java.lang.Object) ,public void forEach(BiConsumer<? super K,? super V>) ,public void forEach(long, BiConsumer<? super K,? super V>) ,public void forEach(long, BiFunction<? super K,? super V,? extends U>, Consumer<? super U>) ,public void forEachEntry(long, Consumer<? super Entry<K,V>>) ,public void forEachEntry(long, Function<Entry<K,V>,? extends U>, Consumer<? super U>) ,public void forEachKey(long, Consumer<? super K>) ,public void forEachKey(long, Function<? super K,? extends U>, Consumer<? super U>) ,public void forEachValue(long, Consumer<? super V>) ,public void forEachValue(long, Function<? super V,? extends U>, Consumer<? super U>) ,public V get(java.lang.Object) ,public V getOrDefault(java.lang.Object, V) ,public int hashCode() ,public boolean isEmpty() ,public KeySetView<K,V> keySet() ,public KeySetView<K,V> keySet(V) ,public Enumeration<K> keys() ,public long mappingCount() ,public V merge(K, V, BiFunction<? super V,? super V,? extends V>) ,public static KeySetView<K,java.lang.Boolean> newKeySet() ,public static KeySetView<K,java.lang.Boolean> newKeySet(int) ,public V put(K, V) ,public void putAll(Map<? extends K,? extends V>) ,public V putIfAbsent(K, V) ,public U reduce(long, BiFunction<? super K,? super V,? extends U>, BiFunction<? super U,? super U,? extends U>) ,public Entry<K,V> reduceEntries(long, BiFunction<Entry<K,V>,Entry<K,V>,? extends Entry<K,V>>) ,public U reduceEntries(long, Function<Entry<K,V>,? extends U>, BiFunction<? super U,? super U,? extends U>) ,public double reduceEntriesToDouble(long, ToDoubleFunction<Entry<K,V>>, double, java.util.function.DoubleBinaryOperator) ,public int reduceEntriesToInt(long, ToIntFunction<Entry<K,V>>, int, java.util.function.IntBinaryOperator) ,public long reduceEntriesToLong(long, ToLongFunction<Entry<K,V>>, long, java.util.function.LongBinaryOperator) ,public K reduceKeys(long, BiFunction<? super K,? super K,? extends K>) ,public U reduceKeys(long, Function<? super K,? extends U>, BiFunction<? super U,? super U,? extends U>) ,public double reduceKeysToDouble(long, ToDoubleFunction<? super K>, double, java.util.function.DoubleBinaryOperator) ,public int reduceKeysToInt(long, ToIntFunction<? super K>, int, java.util.function.IntBinaryOperator) ,public long reduceKeysToLong(long, ToLongFunction<? super K>, long, java.util.function.LongBinaryOperator) ,public double reduceToDouble(long, ToDoubleBiFunction<? super K,? super V>, double, java.util.function.DoubleBinaryOperator) ,public int reduceToInt(long, ToIntBiFunction<? super K,? super V>, int, java.util.function.IntBinaryOperator) ,public long reduceToLong(long, ToLongBiFunction<? super K,? super V>, long, java.util.function.LongBinaryOperator) ,public V reduceValues(long, BiFunction<? super V,? super V,? extends V>) ,public U reduceValues(long, Function<? super V,? extends U>, BiFunction<? super U,? super U,? extends U>) ,public double reduceValuesToDouble(long, ToDoubleFunction<? super V>, double, java.util.function.DoubleBinaryOperator) ,public int reduceValuesToInt(long, ToIntFunction<? super V>, int, java.util.function.IntBinaryOperator) ,public long reduceValuesToLong(long, ToLongFunction<? super V>, long, java.util.function.LongBinaryOperator) ,public V remove(java.lang.Object) ,public boolean remove(java.lang.Object, java.lang.Object) ,public V replace(K, V) ,public boolean replace(K, V, V) ,public void replaceAll(BiFunction<? super K,? super V,? extends V>) ,public U search(long, BiFunction<? super K,? super V,? extends U>) ,public U searchEntries(long, Function<Entry<K,V>,? extends U>) ,public U searchKeys(long, Function<? super K,? extends U>) ,public U searchValues(long, Function<? super V,? extends U>) ,public int size() ,public java.lang.String toString() ,public Collection<V> values() <variables>private static final int ABASE,private static final int ASHIFT,private static final long BASECOUNT,private static final long CELLSBUSY,private static final long CELLVALUE,private static final int DEFAULT_CAPACITY,private static final int DEFAULT_CONCURRENCY_LEVEL,static final int HASH_BITS,private static final float LOAD_FACTOR,private static final int MAXIMUM_CAPACITY,static final int MAX_ARRAY_SIZE,private static final int MAX_RESIZERS,private static final int MIN_TRANSFER_STRIDE,static final int MIN_TREEIFY_CAPACITY,static final int MOVED,static final int NCPU,static final int RESERVED,private static final int RESIZE_STAMP_BITS,private static final int RESIZE_STAMP_SHIFT,private static final long SIZECTL,private static final long TRANSFERINDEX,static final int TREEBIN,static final int TREEIFY_THRESHOLD,private static final jdk.internal.misc.Unsafe U,static final int UNTREEIFY_THRESHOLD,private volatile transient long baseCount,private volatile transient int cellsBusy,private volatile transient java.util.concurrent.ConcurrentHashMap.CounterCell[] counterCells,private transient EntrySetView<K,V> entrySet,private transient KeySetView<K,V> keySet,private volatile transient Node<K,V>[] nextTable,private static final java.io.ObjectStreamField[] serialPersistentFields,private static final long serialVersionUID,private volatile transient int sizeCtl,volatile transient Node<K,V>[] table,private volatile transient int transferIndex,private transient ValuesView<K,V> values
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/solution/cloner/DeepCloningUtils.java
DeepCloningUtils
isFieldADeepCloneProperty
class DeepCloningUtils { // Instances of these JDK classes will never be deep-cloned. private static final Set<Class<?>> IMMUTABLE_CLASSES = Set.of( // Numbers Byte.class, Short.class, Integer.class, Long.class, Float.class, Double.class, BigInteger.class, BigDecimal.class, // Optional Optional.class, OptionalInt.class, OptionalLong.class, OptionalDouble.class, // Date and time Duration.class, Instant.class, LocalDate.class, LocalDateTime.class, LocalTime.class, MonthDay.class, OffsetDateTime.class, OffsetTime.class, Period.class, Year.class, YearMonth.class, ZonedDateTime.class, ZoneId.class, ZoneOffset.class, // Others Boolean.class, Character.class, String.class, UUID.class); /** * Gets the deep cloning decision for a particular value assigned to a field, * memoizing the result. * * @param field the field to get the deep cloning decision of * @param owningClass the class that owns the field; can be different * from the field's declaring class (ex: subclass) * @param actualValueClass the class of the value that is currently assigned * to the field; can be different from the field type * (ex: for the field "List myList", the actual value * class might be ArrayList). * @return true iff the field should be deep cloned with a particular value. */ public static boolean isDeepCloned(SolutionDescriptor<?> solutionDescriptor, Field field, Class<?> owningClass, Class<?> actualValueClass) { return isClassDeepCloned(solutionDescriptor, actualValueClass) || isFieldDeepCloned(solutionDescriptor, field, owningClass); } /** * Gets the deep cloning decision for a field. * * @param field The field to get the deep cloning decision of * @param owningClass The class that owns the field; can be different * from the field's declaring class (ex: subclass). * @return True iff the field should always be deep cloned (regardless of value). */ public static boolean isFieldDeepCloned(SolutionDescriptor<?> solutionDescriptor, Field field, Class<?> owningClass) { Class<?> fieldType = field.getType(); if (isImmutable(fieldType)) { return false; } return isFieldAnEntityPropertyOnSolution(solutionDescriptor, field, owningClass) || isFieldAnEntityOrSolution(solutionDescriptor, field) || isFieldAPlanningListVariable(field, owningClass) || isFieldADeepCloneProperty(field, owningClass); } static boolean isImmutable(Class<?> clz) { if (clz.isPrimitive() || clz.isEnum() || Score.class.isAssignableFrom(clz)) { return true; } return IMMUTABLE_CLASSES.contains(clz); } /** * Return true only if a field represent an entity property on the solution class. * An entity property is one who type is a PlanningEntity or a collection * of PlanningEntity. * * @param field The field to get the deep cloning decision of * @param owningClass The class that owns the field; can be different * from the field's declaring class (ex: subclass). * @return True only if the field is an entity property on the solution class. * May return false if the field getter/setter is complex. */ static boolean isFieldAnEntityPropertyOnSolution(SolutionDescriptor<?> solutionDescriptor, Field field, Class<?> owningClass) { if (!solutionDescriptor.getSolutionClass().isAssignableFrom(owningClass)) { return false; } // field.getDeclaringClass() is a superclass of or equal to the owningClass String fieldName = field.getName(); // This assumes we're dealing with a simple getter/setter. // If that assumption is false, validateCloneSolution(...) fails-fast. if (solutionDescriptor.getEntityMemberAccessorMap().get(fieldName) != null) { return true; } // This assumes we're dealing with a simple getter/setter. // If that assumption is false, validateCloneSolution(...) fails-fast. return solutionDescriptor.getEntityCollectionMemberAccessorMap().get(fieldName) != null; } /** * Returns true iff a field represent an Entity/Solution or a collection * of Entity/Solution. * * @param field The field to get the deep cloning decision of * @return True only if the field represents or contains a PlanningEntity or PlanningSolution */ private static boolean isFieldAnEntityOrSolution(SolutionDescriptor<?> solutionDescriptor, Field field) { Class<?> type = field.getType(); if (isClassDeepCloned(solutionDescriptor, type)) { return true; } if (Collection.class.isAssignableFrom(type) || Map.class.isAssignableFrom(type)) { return isTypeArgumentDeepCloned(solutionDescriptor, field.getGenericType()); } else if (type.isArray()) { return isClassDeepCloned(solutionDescriptor, type.getComponentType()); } return false; } public static boolean isClassDeepCloned(SolutionDescriptor<?> solutionDescriptor, Class<?> type) { if (isImmutable(type)) { return false; } return solutionDescriptor.hasEntityDescriptor(type) || solutionDescriptor.getSolutionClass().isAssignableFrom(type) || type.isAnnotationPresent(DeepPlanningClone.class); } private static boolean isTypeArgumentDeepCloned(SolutionDescriptor<?> solutionDescriptor, Type genericType) { // Check the generic type arguments of the field. // It is possible for fields and methods, but not instances. if (genericType instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) genericType; for (Type actualTypeArgument : parameterizedType.getActualTypeArguments()) { if (actualTypeArgument instanceof Class && isClassDeepCloned(solutionDescriptor, (Class<?>) actualTypeArgument)) { return true; } if (isTypeArgumentDeepCloned(solutionDescriptor, actualTypeArgument)) { return true; } } } return false; } private static boolean isFieldADeepCloneProperty(Field field, Class<?> owningClass) {<FILL_FUNCTION_BODY>} private static boolean isFieldAPlanningListVariable(Field field, Class<?> owningClass) { if (!field.isAnnotationPresent(PlanningListVariable.class)) { Method getterMethod = ReflectionHelper.getGetterMethod(owningClass, field.getName()); return getterMethod != null && getterMethod.isAnnotationPresent(PlanningListVariable.class); } else { return true; } } private DeepCloningUtils() { // No external instances. } }
if (field.isAnnotationPresent(DeepPlanningClone.class)) { return true; } Method getterMethod = ReflectionHelper.getGetterMethod(owningClass, field.getName()); return getterMethod != null && getterMethod.isAnnotationPresent(DeepPlanningClone.class);
1,868
82
1,950
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/solution/cloner/FieldCloningUtils.java
FieldCloningUtils
createExceptionOnRead
class FieldCloningUtils { static void copyBoolean(Field field, Object original, Object clone) { boolean originalValue = getBooleanFieldValue(original, field); setFieldValue(clone, field, originalValue); } private static boolean getBooleanFieldValue(Object bean, Field field) { try { return field.getBoolean(bean); } catch (IllegalAccessException e) { throw FieldCloningUtils.createExceptionOnRead(bean, field, e); } } private static void setFieldValue(Object bean, Field field, boolean value) { try { field.setBoolean(bean, value); } catch (IllegalAccessException e) { throw FieldCloningUtils.createExceptionOnWrite(bean, field, value, e); } } static void copyByte(Field field, Object original, Object clone) { byte originalValue = getByteFieldValue(original, field); setFieldValue(clone, field, originalValue); } private static byte getByteFieldValue(Object bean, Field field) { try { return field.getByte(bean); } catch (IllegalAccessException e) { throw FieldCloningUtils.createExceptionOnRead(bean, field, e); } } private static void setFieldValue(Object bean, Field field, byte value) { try { field.setByte(bean, value); } catch (IllegalAccessException e) { throw FieldCloningUtils.createExceptionOnWrite(bean, field, value, e); } } static void copyChar(Field field, Object original, Object clone) { char originalValue = getCharFieldValue(original, field); setFieldValue(clone, field, originalValue); } private static char getCharFieldValue(Object bean, Field field) { try { return field.getChar(bean); } catch (IllegalAccessException e) { throw FieldCloningUtils.createExceptionOnRead(bean, field, e); } } private static void setFieldValue(Object bean, Field field, char value) { try { field.setChar(bean, value); } catch (IllegalAccessException e) { throw FieldCloningUtils.createExceptionOnWrite(bean, field, value, e); } } static void copyShort(Field field, Object original, Object clone) { short originalValue = getShortFieldValue(original, field); setFieldValue(clone, field, originalValue); } private static short getShortFieldValue(Object bean, Field field) { try { return field.getShort(bean); } catch (IllegalAccessException e) { throw FieldCloningUtils.createExceptionOnRead(bean, field, e); } } private static void setFieldValue(Object bean, Field field, short value) { try { field.setShort(bean, value); } catch (IllegalAccessException e) { throw FieldCloningUtils.createExceptionOnWrite(bean, field, value, e); } } static void copyInt(Field field, Object original, Object clone) { int originalValue = getIntFieldValue(original, field); setFieldValue(clone, field, originalValue); } private static int getIntFieldValue(Object bean, Field field) { try { return field.getInt(bean); } catch (IllegalAccessException e) { throw FieldCloningUtils.createExceptionOnRead(bean, field, e); } } private static void setFieldValue(Object bean, Field field, int value) { try { field.setInt(bean, value); } catch (IllegalAccessException e) { throw FieldCloningUtils.createExceptionOnWrite(bean, field, value, e); } } static void copyLong(Field field, Object original, Object clone) { long originalValue = getLongFieldValue(original, field); setFieldValue(clone, field, originalValue); } private static long getLongFieldValue(Object bean, Field field) { try { return field.getLong(bean); } catch (IllegalAccessException e) { throw FieldCloningUtils.createExceptionOnRead(bean, field, e); } } private static void setFieldValue(Object bean, Field field, long value) { try { field.setLong(bean, value); } catch (IllegalAccessException e) { throw FieldCloningUtils.createExceptionOnWrite(bean, field, value, e); } } static void copyFloat(Field field, Object original, Object clone) { float originalValue = getFloatFieldValue(original, field); setFieldValue(clone, field, originalValue); } private static float getFloatFieldValue(Object bean, Field field) { try { return field.getFloat(bean); } catch (IllegalAccessException e) { throw FieldCloningUtils.createExceptionOnRead(bean, field, e); } } private static void setFieldValue(Object bean, Field field, float value) { try { field.setFloat(bean, value); } catch (IllegalAccessException e) { throw FieldCloningUtils.createExceptionOnWrite(bean, field, value, e); } } static void copyDouble(Field field, Object original, Object clone) { double originalValue = getDoubleFieldValue(original, field); setFieldValue(clone, field, originalValue); } private static double getDoubleFieldValue(Object bean, Field field) { try { return field.getDouble(bean); } catch (IllegalAccessException e) { throw FieldCloningUtils.createExceptionOnRead(bean, field, e); } } private static void setFieldValue(Object bean, Field field, double value) { try { field.setDouble(bean, value); } catch (IllegalAccessException e) { throw FieldCloningUtils.createExceptionOnWrite(bean, field, value, e); } } static void copyObject(Field field, Object original, Object clone) { Object originalValue = FieldCloningUtils.getObjectFieldValue(original, field); FieldCloningUtils.setObjectFieldValue(clone, field, originalValue); } static Object getObjectFieldValue(Object bean, Field field) { try { return field.get(bean); } catch (IllegalAccessException e) { throw createExceptionOnRead(bean, field, e); } } private static RuntimeException createExceptionOnRead(Object bean, Field field, Exception rootCause) {<FILL_FUNCTION_BODY>} static void setObjectFieldValue(Object bean, Field field, Object value) { try { field.set(bean, value); } catch (IllegalAccessException e) { throw createExceptionOnWrite(bean, field, value, e); } } private static RuntimeException createExceptionOnWrite(Object bean, Field field, Object value, Exception rootCause) { return new IllegalStateException("The class (" + bean.getClass() + ") has a field (" + field + ") which cannot be written with the value (" + value + ") to create a planning clone.", rootCause); } private FieldCloningUtils() { // No external instances. } }
return new IllegalStateException("The class (" + bean.getClass() + ") has a field (" + field + ") which cannot be read to create a planning clone.", rootCause);
1,873
46
1,919
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/solution/cloner/gizmo/GizmoCloningUtils.java
GizmoCloningUtils
getDeepClonedTypeArguments
class GizmoCloningUtils { public static Set<Class<?>> getDeepClonedClasses(SolutionDescriptor<?> solutionDescriptor, Collection<Class<?>> entitySubclasses) { Set<Class<?>> deepClonedClassSet = new HashSet<>(); Set<Class<?>> classesToProcess = new LinkedHashSet<>(solutionDescriptor.getEntityClassSet()); classesToProcess.add(solutionDescriptor.getSolutionClass()); classesToProcess.addAll(entitySubclasses); for (Class<?> clazz : classesToProcess) { deepClonedClassSet.add(clazz); for (Field field : getAllFields(clazz)) { deepClonedClassSet.addAll(getDeepClonedTypeArguments(solutionDescriptor, field.getGenericType())); if (DeepCloningUtils.isFieldDeepCloned(solutionDescriptor, field, clazz)) { deepClonedClassSet.add(field.getType()); } } } return deepClonedClassSet; } /** * @return never null */ private static Set<Class<?>> getDeepClonedTypeArguments(SolutionDescriptor<?> solutionDescriptor, Type genericType) {<FILL_FUNCTION_BODY>} private static List<Field> getAllFields(Class<?> baseClass) { Class<?> clazz = baseClass; Stream<Field> memberStream = Stream.empty(); while (clazz != null) { Stream<Field> fieldStream = Stream.of(clazz.getDeclaredFields()); memberStream = Stream.concat(memberStream, fieldStream); clazz = clazz.getSuperclass(); } return memberStream.collect(Collectors.toList()); } private GizmoCloningUtils() { // No external instances. } }
// Check the generic type arguments of the field. // It is possible for fields and methods, but not instances. if (!(genericType instanceof ParameterizedType)) { return Collections.emptySet(); } Set<Class<?>> deepClonedTypeArguments = new HashSet<>(); ParameterizedType parameterizedType = (ParameterizedType) genericType; for (Type actualTypeArgument : parameterizedType.getActualTypeArguments()) { if (actualTypeArgument instanceof Class && DeepCloningUtils.isClassDeepCloned(solutionDescriptor, (Class) actualTypeArgument)) { deepClonedTypeArguments.add((Class) actualTypeArgument); } deepClonedTypeArguments.addAll(getDeepClonedTypeArguments(solutionDescriptor, actualTypeArgument)); } return deepClonedTypeArguments;
469
207
676
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/solution/cloner/gizmo/GizmoSolutionClonerFactory.java
GizmoSolutionClonerFactory
build
class GizmoSolutionClonerFactory { /** * Returns the generated class name for a given solutionDescriptor. * (Here as accessing any method of GizmoMemberAccessorImplementor * will try to load Gizmo code) * * @param solutionDescriptor The solutionDescriptor to get the generated class name for * @return The generated class name for solutionDescriptor */ public static String getGeneratedClassName(SolutionDescriptor<?> solutionDescriptor) { return solutionDescriptor.getSolutionClass().getName() + "$OptaPlanner$SolutionCloner"; } public static <T> SolutionCloner<T> build(SolutionDescriptor<T> solutionDescriptor, GizmoClassLoader gizmoClassLoader) {<FILL_FUNCTION_BODY>} // ************************************************************************ // Private constructor // ************************************************************************ private GizmoSolutionClonerFactory() { } }
try { // Check if Gizmo on the classpath by verifying we can access one of its classes Class.forName("io.quarkus.gizmo.ClassCreator", false, Thread.currentThread().getContextClassLoader()); } catch (ClassNotFoundException e) { throw new IllegalStateException("When using the domainAccessType (" + DomainAccessType.GIZMO + ") the classpath or modulepath must contain io.quarkus.gizmo:gizmo.\n" + "Maybe add a dependency to io.quarkus.gizmo:gizmo."); } return GizmoSolutionClonerImplementor.createClonerFor(solutionDescriptor, gizmoClassLoader);
232
182
414
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/solution/cloner/gizmo/GizmoSolutionOrEntityDescriptor.java
GizmoSolutionOrEntityDescriptor
getFieldsToSolutionFieldToMemberDescriptorMap
class GizmoSolutionOrEntityDescriptor { SolutionDescriptor<?> solutionDescriptor; Map<Field, GizmoMemberDescriptor> solutionFieldToMemberDescriptorMap; Set<Field> deepClonedFields; Set<Field> shallowlyClonedFields; public GizmoSolutionOrEntityDescriptor(SolutionDescriptor<?> solutionDescriptor, Class<?> entityOrSolutionClass) { this(solutionDescriptor, entityOrSolutionClass, getFieldsToSolutionFieldToMemberDescriptorMap(entityOrSolutionClass, new HashMap<>())); } public GizmoSolutionOrEntityDescriptor(SolutionDescriptor<?> solutionDescriptor, Class<?> entityOrSolutionClass, Map<Field, GizmoMemberDescriptor> solutionFieldToMemberDescriptorMap) { this.solutionDescriptor = solutionDescriptor; this.solutionFieldToMemberDescriptorMap = solutionFieldToMemberDescriptorMap; deepClonedFields = new HashSet<>(); shallowlyClonedFields = new HashSet<>(); for (Field field : solutionFieldToMemberDescriptorMap.keySet()) { if (DeepCloningUtils.isDeepCloned(solutionDescriptor, field, entityOrSolutionClass, field.getType())) { deepClonedFields.add(field); } else { shallowlyClonedFields.add(field); } } } private static Map<Field, GizmoMemberDescriptor> getFieldsToSolutionFieldToMemberDescriptorMap(Class<?> clazz, Map<Field, GizmoMemberDescriptor> solutionFieldToMemberDescriptorMap) {<FILL_FUNCTION_BODY>} public SolutionDescriptor<?> getSolutionDescriptor() { return solutionDescriptor; } public Set<GizmoMemberDescriptor> getShallowClonedMemberDescriptors() { return solutionFieldToMemberDescriptorMap.keySet().stream() .filter(field -> shallowlyClonedFields.contains(field)) .map(solutionFieldToMemberDescriptorMap::get).collect(Collectors.toSet()); } public Set<Field> getDeepClonedFields() { return deepClonedFields; } public GizmoMemberDescriptor getMemberDescriptorForField(Field field) { return solutionFieldToMemberDescriptorMap.get(field); } }
for (Field field : clazz.getDeclaredFields()) { if (!Modifier.isStatic(field.getModifiers())) { solutionFieldToMemberDescriptorMap.put(field, new GizmoMemberDescriptor(field)); } } if (clazz.getSuperclass() != null) { getFieldsToSolutionFieldToMemberDescriptorMap(clazz.getSuperclass(), solutionFieldToMemberDescriptorMap); } return solutionFieldToMemberDescriptorMap;
573
120
693
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/valuerange/buildin/bigdecimal/BigDecimalValueRange.java
RandomBigDecimalValueRangeIterator
toString
class RandomBigDecimalValueRangeIterator extends ValueRangeIterator<BigDecimal> { private final Random workingRandom; private final long size = getSize(); public RandomBigDecimalValueRangeIterator(Random workingRandom) { this.workingRandom = workingRandom; } @Override public boolean hasNext() { return size > 0L; } @Override public BigDecimal next() { if (size <= 0L) { throw new NoSuchElementException(); } long index = RandomUtils.nextLong(workingRandom, size); return incrementUnit.multiply(BigDecimal.valueOf(index)).add(from); } } @Override public String toString() {<FILL_FUNCTION_BODY>
return "[" + from + "-" + to + ")"; // Formatting: interval (mathematics) ISO 31-11
198
35
233
<methods>public non-sealed void <init>() ,public boolean isEmpty() <variables>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/valuerange/buildin/collection/ListValueRange.java
ListValueRange
toString
class ListValueRange<T> extends AbstractCountableValueRange<T> { private final List<T> list; public ListValueRange(List<T> list) { this.list = list; } @Override public long getSize() { return list.size(); } @Override public T get(long index) { if (index > Integer.MAX_VALUE) { throw new IndexOutOfBoundsException("The index (" + index + ") must fit in an int."); } return list.get((int) index); } @Override public boolean contains(T value) { return list.contains(value); } @Override public Iterator<T> createOriginalIterator() { return list.iterator(); } @Override public Iterator<T> createRandomIterator(Random workingRandom) { return new CachedListRandomIterator<>(list, workingRandom); } @Override public String toString() {<FILL_FUNCTION_BODY>} }
// Formatting: interval (mathematics) ISO 31-11 return list.isEmpty() ? "[]" : "[" + list.get(0) + "-" + list.get(list.size() - 1) + "]";
270
63
333
<methods>public non-sealed void <init>() ,public boolean isEmpty() <variables>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/valuerange/buildin/primboolean/BooleanValueRange.java
OriginalBooleanValueRangeIterator
next
class OriginalBooleanValueRangeIterator extends ValueRangeIterator<Boolean> { private boolean hasNext = true; private Boolean upcoming = Boolean.FALSE; @Override public boolean hasNext() { return hasNext; } @Override public Boolean next() {<FILL_FUNCTION_BODY>} }
if (!hasNext) { throw new NoSuchElementException(); } Boolean next = upcoming; if (upcoming) { hasNext = false; } else { upcoming = Boolean.TRUE; } return next;
85
66
151
<methods>public non-sealed void <init>() ,public boolean isEmpty() <variables>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/valuerange/buildin/temporal/TemporalValueRange.java
OriginalTemporalValueRangeIterator
next
class OriginalTemporalValueRangeIterator extends ValueRangeIterator<Temporal_> { private long index = 0L; @Override public boolean hasNext() { return index < size; } @Override public Temporal_ next() {<FILL_FUNCTION_BODY>} }
if (index >= size) { throw new NoSuchElementException(); } // Do not use upcoming += incrementUnitAmount because 31-JAN + 1 month + 1 month returns 28-MAR Temporal_ next = get(index); index++; return next;
84
77
161
<methods>public non-sealed void <init>() ,public boolean isEmpty() <variables>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/valuerange/descriptor/AbstractFromPropertyValueRangeDescriptor.java
AbstractFromPropertyValueRangeDescriptor
processValueRangeProviderAnnotation
class AbstractFromPropertyValueRangeDescriptor<Solution_> extends AbstractValueRangeDescriptor<Solution_> { protected final MemberAccessor memberAccessor; protected boolean collectionWrapping; protected boolean arrayWrapping; protected boolean countable; public AbstractFromPropertyValueRangeDescriptor(GenuineVariableDescriptor<Solution_> variableDescriptor, boolean addNullInValueRange, MemberAccessor memberAccessor) { super(variableDescriptor, addNullInValueRange); this.memberAccessor = memberAccessor; ValueRangeProvider valueRangeProviderAnnotation = memberAccessor.getAnnotation(ValueRangeProvider.class); if (valueRangeProviderAnnotation == null) { throw new IllegalStateException("The member (" + memberAccessor + ") must have a valueRangeProviderAnnotation (" + valueRangeProviderAnnotation + ")."); } processValueRangeProviderAnnotation(valueRangeProviderAnnotation); if (addNullInValueRange && !countable) { throw new IllegalStateException("The valueRangeDescriptor (" + this + ") is nullable, but not countable (" + countable + ").\n" + "Maybe the member (" + memberAccessor + ") should return " + CountableValueRange.class.getSimpleName() + "."); } } private void processValueRangeProviderAnnotation(ValueRangeProvider valueRangeProviderAnnotation) {<FILL_FUNCTION_BODY>} // ************************************************************************ // Worker methods // ************************************************************************ @Override public boolean isCountable() { return countable; } protected ValueRange<?> readValueRange(Object bean) { Object valueRangeObject = memberAccessor.executeGetter(bean); if (valueRangeObject == null) { throw new IllegalStateException("The @" + ValueRangeProvider.class.getSimpleName() + " annotated member (" + memberAccessor + ") called on bean (" + bean + ") must not return a null valueRangeObject (" + valueRangeObject + ")."); } ValueRange<Object> valueRange; if (collectionWrapping || arrayWrapping) { List<Object> list = collectionWrapping ? transformCollectionToList((Collection<Object>) valueRangeObject) : ReflectionHelper.transformArrayToList(valueRangeObject); // Don't check the entire list for performance reasons, but do check common pitfalls if (!list.isEmpty() && (list.get(0) == null || list.get(list.size() - 1) == null)) { throw new IllegalStateException("The @" + ValueRangeProvider.class.getSimpleName() + " annotated member (" + memberAccessor + ") called on bean (" + bean + ") must not return a " + (collectionWrapping ? Collection.class.getSimpleName() : "array") + "(" + list + ") with an element that is null.\n" + "Maybe remove that null element from the dataset.\n" + "Maybe use @" + PlanningVariable.class.getSimpleName() + "(nullable = true) instead."); } valueRange = new ListValueRange<>(list); } else { valueRange = (ValueRange<Object>) valueRangeObject; } valueRange = doNullInValueRangeWrapping(valueRange); if (valueRange.isEmpty()) { throw new IllegalStateException("The @" + ValueRangeProvider.class.getSimpleName() + " annotated member (" + memberAccessor + ") called on bean (" + bean + ") must not return an empty valueRange (" + valueRangeObject + ").\n" + "Maybe apply overconstrained planning as described in the documentation."); } return valueRange; } private <T> List<T> transformCollectionToList(Collection<T> collection) { // TODO The user might not be aware of these performance pitfalls with Set and LinkedList: // - If only ValueRange.createOriginalIterator() is used, cloning a Set to a List is a waste of time. // - If the List is a LinkedList, ValueRange.createRandomIterator(Random) // and ValueRange.get(int) are not efficient. return (collection instanceof List ? (List<T>) collection : new ArrayList<>(collection)); } }
EntityDescriptor<Solution_> entityDescriptor = variableDescriptor.getEntityDescriptor(); Class<?> type = memberAccessor.getType(); collectionWrapping = Collection.class.isAssignableFrom(type); arrayWrapping = type.isArray(); if (!collectionWrapping && !arrayWrapping && !ValueRange.class.isAssignableFrom(type)) { throw new IllegalArgumentException("The entityClass (" + entityDescriptor.getEntityClass() + ") has a @" + PlanningVariable.class.getSimpleName() + " annotated property (" + variableDescriptor.getVariableName() + ") that refers to a @" + ValueRangeProvider.class.getSimpleName() + " annotated member (" + memberAccessor + ") that does not return a " + Collection.class.getSimpleName() + ", an array or a " + ValueRange.class.getSimpleName() + "."); } if (collectionWrapping) { Class<?> collectionElementClass = ConfigUtils.extractCollectionGenericTypeParameterStrictly( "solutionClass or entityClass", memberAccessor.getDeclaringClass(), memberAccessor.getType(), memberAccessor.getGenericType(), ValueRangeProvider.class, memberAccessor.getName()); if (!variableDescriptor.acceptsValueType(collectionElementClass)) { throw new IllegalArgumentException("The entityClass (" + entityDescriptor.getEntityClass() + ") has a @" + PlanningVariable.class.getSimpleName() + " annotated property (" + variableDescriptor.getVariableName() + ") that refers to a @" + ValueRangeProvider.class.getSimpleName() + " annotated member (" + memberAccessor + ") that returns a " + Collection.class.getSimpleName() + " with elements of type (" + collectionElementClass + ") which cannot be assigned to the @" + PlanningVariable.class.getSimpleName() + "'s type (" + variableDescriptor.getVariablePropertyType() + ")."); } } else if (arrayWrapping) { Class<?> arrayElementClass = type.getComponentType(); if (!variableDescriptor.acceptsValueType(arrayElementClass)) { throw new IllegalArgumentException("The entityClass (" + entityDescriptor.getEntityClass() + ") has a @" + PlanningVariable.class.getSimpleName() + " annotated property (" + variableDescriptor.getVariableName() + ") that refers to a @" + ValueRangeProvider.class.getSimpleName() + " annotated member (" + memberAccessor + ") that returns an array with elements of type (" + arrayElementClass + ") which cannot be assigned to the @" + PlanningVariable.class.getSimpleName() + "'s type (" + variableDescriptor.getVariablePropertyType() + ")."); } } countable = collectionWrapping || arrayWrapping || CountableValueRange.class.isAssignableFrom(type);
1,045
700
1,745
<methods>public void <init>(GenuineVariableDescriptor<Solution_>, boolean) ,public GenuineVariableDescriptor<Solution_> getVariableDescriptor() ,public boolean mightContainEntity() ,public java.lang.String toString() <variables>protected final non-sealed boolean addNullInValueRange,protected final non-sealed GenuineVariableDescriptor<Solution_> variableDescriptor
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/valuerange/descriptor/CompositeValueRangeDescriptor.java
CompositeValueRangeDescriptor
extractValueRange
class CompositeValueRangeDescriptor<Solution_> extends AbstractValueRangeDescriptor<Solution_> implements EntityIndependentValueRangeDescriptor<Solution_> { protected final List<ValueRangeDescriptor<Solution_>> childValueRangeDescriptorList; protected boolean entityIndependent; public CompositeValueRangeDescriptor( GenuineVariableDescriptor<Solution_> variableDescriptor, boolean addNullInValueRange, List<ValueRangeDescriptor<Solution_>> childValueRangeDescriptorList) { super(variableDescriptor, addNullInValueRange); this.childValueRangeDescriptorList = childValueRangeDescriptorList; entityIndependent = true; for (ValueRangeDescriptor<Solution_> valueRangeDescriptor : childValueRangeDescriptorList) { if (!valueRangeDescriptor.isCountable()) { throw new IllegalStateException("The valueRangeDescriptor (" + this + ") has a childValueRangeDescriptor (" + valueRangeDescriptor + ") with countable (" + valueRangeDescriptor.isCountable() + ")."); } if (!valueRangeDescriptor.isEntityIndependent()) { entityIndependent = false; } } } // ************************************************************************ // Worker methods // ************************************************************************ @Override public boolean isCountable() { return true; } @Override public boolean isEntityIndependent() { return entityIndependent; } @Override public ValueRange<?> extractValueRange(Solution_ solution, Object entity) {<FILL_FUNCTION_BODY>} @Override public ValueRange<?> extractValueRange(Solution_ solution) { List<CountableValueRange<?>> childValueRangeList = new ArrayList<>(childValueRangeDescriptorList.size()); for (ValueRangeDescriptor<Solution_> valueRangeDescriptor : childValueRangeDescriptorList) { EntityIndependentValueRangeDescriptor<Solution_> entityIndependentValueRangeDescriptor = (EntityIndependentValueRangeDescriptor) valueRangeDescriptor; childValueRangeList.add((CountableValueRange) entityIndependentValueRangeDescriptor.extractValueRange(solution)); } return doNullInValueRangeWrapping(new CompositeCountableValueRange(childValueRangeList)); } }
List<CountableValueRange<?>> childValueRangeList = new ArrayList<>(childValueRangeDescriptorList.size()); for (ValueRangeDescriptor<Solution_> valueRangeDescriptor : childValueRangeDescriptorList) { childValueRangeList.add((CountableValueRange) valueRangeDescriptor.extractValueRange(solution, entity)); } return doNullInValueRangeWrapping(new CompositeCountableValueRange(childValueRangeList));
553
109
662
<methods>public void <init>(GenuineVariableDescriptor<Solution_>, boolean) ,public GenuineVariableDescriptor<Solution_> getVariableDescriptor() ,public boolean mightContainEntity() ,public java.lang.String toString() <variables>protected final non-sealed boolean addNullInValueRange,protected final non-sealed GenuineVariableDescriptor<Solution_> variableDescriptor
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/valuerange/util/ValueRangeIterator.java
ValueRangeIterator
remove
class ValueRangeIterator<S> implements Iterator<S> { @Override public void remove() {<FILL_FUNCTION_BODY>} }
throw new UnsupportedOperationException("The optional operation remove() is not supported.");
42
21
63
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/variable/anchor/AnchorShadowVariableDescriptor.java
AnchorShadowVariableDescriptor
linkShadowSources
class AnchorShadowVariableDescriptor<Solution_> extends ShadowVariableDescriptor<Solution_> { protected VariableDescriptor<Solution_> sourceVariableDescriptor; public AnchorShadowVariableDescriptor(EntityDescriptor<Solution_> entityDescriptor, MemberAccessor variableMemberAccessor) { super(entityDescriptor, variableMemberAccessor); } @Override public void processAnnotations(DescriptorPolicy descriptorPolicy) { // Do nothing } @Override public void linkVariableDescriptors(DescriptorPolicy descriptorPolicy) { linkShadowSources(descriptorPolicy); } private void linkShadowSources(DescriptorPolicy descriptorPolicy) {<FILL_FUNCTION_BODY>} @Override public List<VariableDescriptor<Solution_>> getSourceVariableDescriptorList() { return Collections.singletonList(sourceVariableDescriptor); } @Override public Collection<Class<? extends AbstractVariableListener>> getVariableListenerClasses() { return Collections.singleton(AnchorVariableListener.class); } // ************************************************************************ // Worker methods // ************************************************************************ @Override public AnchorVariableDemand<Solution_> getProvidedDemand() { return new AnchorVariableDemand<>(sourceVariableDescriptor); } @Override public Iterable<VariableListenerWithSources<Solution_>> buildVariableListeners(SupplyManager supplyManager) { SingletonInverseVariableSupply inverseVariableSupply = supplyManager .demand(new SingletonInverseVariableDemand<>(sourceVariableDescriptor)); return new VariableListenerWithSources<>( new AnchorVariableListener<>(this, sourceVariableDescriptor, inverseVariableSupply), sourceVariableDescriptor).toCollection(); } }
AnchorShadowVariable shadowVariableAnnotation = variableMemberAccessor.getAnnotation(AnchorShadowVariable.class); String sourceVariableName = shadowVariableAnnotation.sourceVariableName(); sourceVariableDescriptor = entityDescriptor.getVariableDescriptor(sourceVariableName); if (sourceVariableDescriptor == null) { throw new IllegalArgumentException("The entityClass (" + entityDescriptor.getEntityClass() + ") has an @" + AnchorShadowVariable.class.getSimpleName() + " annotated property (" + variableMemberAccessor.getName() + ") with sourceVariableName (" + sourceVariableName + ") which is not a valid planning variable on entityClass (" + entityDescriptor.getEntityClass() + ").\n" + entityDescriptor.buildInvalidVariableNameExceptionMessage(sourceVariableName)); } if (!(sourceVariableDescriptor instanceof GenuineVariableDescriptor) || !((GenuineVariableDescriptor<Solution_>) sourceVariableDescriptor).isChained()) { throw new IllegalArgumentException("The entityClass (" + entityDescriptor.getEntityClass() + ") has an @" + AnchorShadowVariable.class.getSimpleName() + " annotated property (" + variableMemberAccessor.getName() + ") with sourceVariableName (" + sourceVariableName + ") which is not chained."); } sourceVariableDescriptor.registerSinkVariableDescriptor(this);
443
327
770
<methods>public void <init>(EntityDescriptor<Solution_>, org.optaplanner.core.impl.domain.common.accessor.MemberAccessor) ,public abstract Iterable<VariableListenerWithSources<Solution_>> buildVariableListeners(org.optaplanner.core.impl.domain.variable.supply.SupplyManager) ,public int getGlobalShadowOrder() ,public abstract Demand<?> getProvidedDemand() ,public abstract List<VariableDescriptor<Solution_>> getSourceVariableDescriptorList() ,public abstract Collection<Class<? extends AbstractVariableListener#RAW>> getVariableListenerClasses() ,public boolean hasVariableListener() ,public boolean isGenuineAndUninitialized(java.lang.Object) ,public abstract void processAnnotations(org.optaplanner.core.impl.domain.policy.DescriptorPolicy) ,public void setGlobalShadowOrder(int) ,public java.lang.String toString() <variables>private int globalShadowOrder
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/variable/anchor/AnchorVariableDemand.java
AnchorVariableDemand
createExternalizedSupply
class AnchorVariableDemand<Solution_> extends AbstractVariableDescriptorBasedDemand<Solution_, AnchorVariableSupply> { public AnchorVariableDemand(VariableDescriptor<Solution_> sourceVariableDescriptor) { super(sourceVariableDescriptor); } // ************************************************************************ // Creation method // ************************************************************************ @Override public AnchorVariableSupply createExternalizedSupply(SupplyManager supplyManager) {<FILL_FUNCTION_BODY>} }
SingletonInverseVariableSupply inverseVariableSupply = supplyManager .demand(new SingletonInverseVariableDemand<>(variableDescriptor)); return new ExternalizedAnchorVariableSupply<>(variableDescriptor, inverseVariableSupply);
127
60
187
<methods>public final boolean equals(java.lang.Object) ,public final int hashCode() ,public final java.lang.String toString() <variables>protected final non-sealed VariableDescriptor<Solution_> variableDescriptor
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/variable/anchor/ExternalizedAnchorVariableSupply.java
ExternalizedAnchorVariableSupply
beforeEntityRemoved
class ExternalizedAnchorVariableSupply<Solution_> implements SourcedVariableListener<Solution_>, VariableListener<Solution_, Object>, AnchorVariableSupply { protected final VariableDescriptor<Solution_> previousVariableDescriptor; protected final SingletonInverseVariableSupply nextVariableSupply; protected Map<Object, Object> anchorMap = null; public ExternalizedAnchorVariableSupply(VariableDescriptor<Solution_> previousVariableDescriptor, SingletonInverseVariableSupply nextVariableSupply) { this.previousVariableDescriptor = previousVariableDescriptor; this.nextVariableSupply = nextVariableSupply; } @Override public VariableDescriptor<Solution_> getSourceVariableDescriptor() { return previousVariableDescriptor; } @Override public void resetWorkingSolution(ScoreDirector<Solution_> scoreDirector) { anchorMap = new IdentityHashMap<>(); previousVariableDescriptor.getEntityDescriptor().visitAllEntities(scoreDirector.getWorkingSolution(), this::insert); } @Override public void close() { anchorMap = null; } @Override public void beforeEntityAdded(ScoreDirector<Solution_> scoreDirector, Object entity) { // Do nothing } @Override public void afterEntityAdded(ScoreDirector<Solution_> scoreDirector, Object entity) { insert(entity); } @Override public void beforeVariableChanged(ScoreDirector<Solution_> scoreDirector, Object entity) { // No need to retract() because the insert (which is guaranteed to be called later) affects the same trailing entities. } @Override public void afterVariableChanged(ScoreDirector<Solution_> scoreDirector, Object entity) { insert(entity); } @Override public void beforeEntityRemoved(ScoreDirector<Solution_> scoreDirector, Object entity) {<FILL_FUNCTION_BODY>} @Override public void afterEntityRemoved(ScoreDirector<Solution_> scoreDirector, Object entity) { // Do nothing } protected void insert(Object entity) { Object previousEntity = previousVariableDescriptor.getValue(entity); Object anchor; if (previousEntity == null) { anchor = null; } else if (previousVariableDescriptor.isValuePotentialAnchor(previousEntity)) { anchor = previousEntity; } else { anchor = anchorMap.get(previousEntity); } Object nextEntity = entity; while (nextEntity != null && anchorMap.get(nextEntity) != anchor) { anchorMap.put(nextEntity, anchor); nextEntity = nextVariableSupply.getInverseSingleton(nextEntity); } } @Override public Object getAnchor(Object entity) { return anchorMap.get(entity); } @Override public String toString() { return getClass().getSimpleName() + "(" + previousVariableDescriptor.getVariableName() + ")"; } }
boolean removeSucceeded = anchorMap.remove(entity) != null; if (!removeSucceeded) { throw new IllegalStateException("The supply (" + this + ") is corrupted," + " because the entity (" + entity + ") for sourceVariable (" + previousVariableDescriptor.getVariableName() + ") cannot be retracted: it was never inserted."); } // No need to retract the trailing entities because they will be removed too or change their previousVariable
782
120
902
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/variable/custom/CustomShadowVariableDescriptor.java
CustomShadowVariableDescriptor
linkSourceVariableDescriptorToListenerClass
class CustomShadowVariableDescriptor<Solution_> extends ShadowVariableDescriptor<Solution_> { private final Map<Class<? extends AbstractVariableListener>, List<VariableDescriptor<Solution_>>> listenerClassToSourceDescriptorListMap = new HashMap<>(); public CustomShadowVariableDescriptor(EntityDescriptor<Solution_> entityDescriptor, MemberAccessor variableMemberAccessor) { super(entityDescriptor, variableMemberAccessor); } @Override public void processAnnotations(DescriptorPolicy descriptorPolicy) { // Do nothing } @Override public void linkVariableDescriptors(DescriptorPolicy descriptorPolicy) { for (ShadowVariable shadowVariable : variableMemberAccessor.getDeclaredAnnotationsByType(ShadowVariable.class)) { linkSourceVariableDescriptorToListenerClass(shadowVariable); } } private void linkSourceVariableDescriptorToListenerClass(ShadowVariable shadowVariable) {<FILL_FUNCTION_BODY>} @Override public List<VariableDescriptor<Solution_>> getSourceVariableDescriptorList() { return listenerClassToSourceDescriptorListMap.values().stream() .flatMap(Collection::stream) .distinct() .collect(Collectors.toList()); } @Override public Collection<Class<? extends AbstractVariableListener>> getVariableListenerClasses() { return listenerClassToSourceDescriptorListMap.keySet(); } // ************************************************************************ // Worker methods // ************************************************************************ @Override public Demand<?> getProvidedDemand() { throw new UnsupportedOperationException("Custom shadow variable cannot be demanded."); } @Override public Iterable<VariableListenerWithSources<Solution_>> buildVariableListeners(SupplyManager supplyManager) { return listenerClassToSourceDescriptorListMap.entrySet().stream().map(classListEntry -> { AbstractVariableListener<Solution_, Object> variableListener = ConfigUtils.newInstance(this::toString, "variableListenerClass", classListEntry.getKey()); return new VariableListenerWithSources<>(variableListener, classListEntry.getValue()); }).collect(Collectors.toList()); } }
EntityDescriptor<Solution_> sourceEntityDescriptor; Class<?> sourceEntityClass = shadowVariable.sourceEntityClass(); if (sourceEntityClass.equals(ShadowVariable.NullEntityClass.class)) { sourceEntityDescriptor = entityDescriptor; } else { sourceEntityDescriptor = entityDescriptor.getSolutionDescriptor().findEntityDescriptor(sourceEntityClass); if (sourceEntityDescriptor == null) { throw new IllegalArgumentException("The entityClass (" + entityDescriptor.getEntityClass() + ") has a @" + ShadowVariable.class.getSimpleName() + " annotated property (" + variableMemberAccessor.getName() + ") with a sourceEntityClass (" + sourceEntityClass + ") which is not a valid planning entity." + "\nMaybe check the annotations of the class (" + sourceEntityClass + ")." + "\nMaybe add the class (" + sourceEntityClass + ") among planning entities in the solver configuration."); } } String sourceVariableName = shadowVariable.sourceVariableName(); VariableDescriptor<Solution_> sourceVariableDescriptor = sourceEntityDescriptor.getVariableDescriptor(sourceVariableName); if (sourceVariableDescriptor == null) { throw new IllegalArgumentException("The entityClass (" + entityDescriptor.getEntityClass() + ") has a @" + ShadowVariable.class.getSimpleName() + " annotated property (" + variableMemberAccessor.getName() + ") with sourceVariableName (" + sourceVariableName + ") which is not a valid planning variable on entityClass (" + sourceEntityDescriptor.getEntityClass() + ").\n" + sourceEntityDescriptor.buildInvalidVariableNameExceptionMessage(sourceVariableName)); } Class<? extends AbstractVariableListener> variableListenerClass = shadowVariable.variableListenerClass(); if (sourceVariableDescriptor.isGenuineListVariable() && !ListVariableListener.class.isAssignableFrom(variableListenerClass)) { throw new IllegalArgumentException("The entityClass (" + entityDescriptor.getEntityClass() + ") has a @" + ShadowVariable.class.getSimpleName() + " annotated property (" + variableMemberAccessor.getName() + ") with sourceVariable (" + sourceVariableDescriptor.getSimpleEntityAndVariableName() + ") which is a list variable but the variableListenerClass (" + variableListenerClass + ") is not a " + ListVariableListener.class.getSimpleName() + ".\n" + "Maybe make the variableListenerClass (" + variableListenerClass.getSimpleName() + ") implement " + ListVariableListener.class.getSimpleName() + "."); } if (!sourceVariableDescriptor.isGenuineListVariable() && !VariableListener.class.isAssignableFrom(variableListenerClass)) { throw new IllegalArgumentException("The entityClass (" + entityDescriptor.getEntityClass() + ") has a @" + ShadowVariable.class.getSimpleName() + " annotated property (" + variableMemberAccessor.getName() + ") with sourceVariable (" + sourceVariableDescriptor.getSimpleEntityAndVariableName() + ") which is a basic variable but the variableListenerClass (" + variableListenerClass + ") is not a " + VariableListener.class.getSimpleName() + ".\n" + "Maybe make the variableListenerClass (" + variableListenerClass.getSimpleName() + ") implement " + VariableListener.class.getSimpleName() + "."); } sourceVariableDescriptor.registerSinkVariableDescriptor(this); listenerClassToSourceDescriptorListMap .computeIfAbsent(variableListenerClass, k -> new ArrayList<>()) .add(sourceVariableDescriptor);
541
869
1,410
<methods>public void <init>(EntityDescriptor<Solution_>, org.optaplanner.core.impl.domain.common.accessor.MemberAccessor) ,public abstract Iterable<VariableListenerWithSources<Solution_>> buildVariableListeners(org.optaplanner.core.impl.domain.variable.supply.SupplyManager) ,public int getGlobalShadowOrder() ,public abstract Demand<?> getProvidedDemand() ,public abstract List<VariableDescriptor<Solution_>> getSourceVariableDescriptorList() ,public abstract Collection<Class<? extends AbstractVariableListener#RAW>> getVariableListenerClasses() ,public boolean hasVariableListener() ,public boolean isGenuineAndUninitialized(java.lang.Object) ,public abstract void processAnnotations(org.optaplanner.core.impl.domain.policy.DescriptorPolicy) ,public void setGlobalShadowOrder(int) ,public java.lang.String toString() <variables>private int globalShadowOrder
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/variable/descriptor/BasicVariableDescriptor.java
BasicVariableDescriptor
processChained
class BasicVariableDescriptor<Solution_> extends GenuineVariableDescriptor<Solution_> { private boolean chained; private boolean nullable; // ************************************************************************ // Constructors and simple getters/setters // ************************************************************************ public BasicVariableDescriptor(EntityDescriptor<Solution_> entityDescriptor, MemberAccessor variableMemberAccessor) { super(entityDescriptor, variableMemberAccessor); } // ************************************************************************ // Lifecycle methods // ************************************************************************ @Override protected void processPropertyAnnotations(DescriptorPolicy descriptorPolicy) { PlanningVariable planningVariableAnnotation = variableMemberAccessor.getAnnotation(PlanningVariable.class); processNullable(planningVariableAnnotation); processChained(planningVariableAnnotation); processValueRangeRefs(descriptorPolicy, planningVariableAnnotation.valueRangeProviderRefs()); processStrength(planningVariableAnnotation.strengthComparatorClass(), planningVariableAnnotation.strengthWeightFactoryClass()); } private void processNullable(PlanningVariable planningVariableAnnotation) { nullable = planningVariableAnnotation.nullable(); if (nullable && variableMemberAccessor.getType().isPrimitive()) { throw new IllegalArgumentException("The entityClass (" + entityDescriptor.getEntityClass() + ") has a @" + PlanningVariable.class.getSimpleName() + " annotated property (" + variableMemberAccessor.getName() + ") with nullable (" + nullable + "), which is not compatible with the primitive propertyType (" + variableMemberAccessor.getType() + ")."); } } private void processChained(PlanningVariable planningVariableAnnotation) {<FILL_FUNCTION_BODY>} // ************************************************************************ // Worker methods // ************************************************************************ @Override public boolean isListVariable() { return false; } @Override public boolean isChained() { return chained; } @Override public boolean isNullable() { return nullable; } @Override public boolean acceptsValueType(Class<?> valueType) { return getVariablePropertyType().isAssignableFrom(valueType); } // ************************************************************************ // Extraction methods // ************************************************************************ @Override public boolean isInitialized(Object entity) { if (isNullable()) { return true; } Object variable = getValue(entity); return variable != null; } }
chained = planningVariableAnnotation.graphType() == PlanningVariableGraphType.CHAINED; if (!chained) { return; } if (!acceptsValueType(entityDescriptor.getEntityClass())) { throw new IllegalArgumentException("The entityClass (" + entityDescriptor.getEntityClass() + ") has a @" + PlanningVariable.class.getSimpleName() + " annotated property (" + variableMemberAccessor.getName() + ") with chained (" + chained + ") and propertyType (" + getVariablePropertyType() + ") which is not a superclass/interface of or the same as the entityClass (" + entityDescriptor.getEntityClass() + ").\n" + "If an entity's chained planning variable cannot point to another entity of the same class," + " then it is impossible to make a chain longer than 1 entity and therefore chaining is useless."); } if (nullable) { throw new IllegalArgumentException("The entityClass (" + entityDescriptor.getEntityClass() + ") has a @" + PlanningVariable.class.getSimpleName() + " annotated property (" + variableMemberAccessor.getName() + ") with chained (" + chained + "), which is not compatible with nullable (" + nullable + ")."); }
627
311
938
<methods>public void <init>(EntityDescriptor<Solution_>, org.optaplanner.core.impl.domain.common.accessor.MemberAccessor) ,public abstract boolean acceptsValueType(Class<?>) ,public SelectionSorter<Solution_,java.lang.Object> getDecreasingStrengthSorter() ,public SelectionSorter<Solution_,java.lang.Object> getIncreasingStrengthSorter() ,public SelectionFilter<Solution_,java.lang.Object> getMovableChainedTrailingValueFilter() ,public long getValueCount(Solution_, java.lang.Object) ,public ValueRangeDescriptor<Solution_> getValueRangeDescriptor() ,public boolean hasMovableChainedTrailingValueFilter() ,public abstract boolean isChained() ,public boolean isGenuineAndUninitialized(java.lang.Object) ,public abstract boolean isInitialized(java.lang.Object) ,public abstract boolean isListVariable() ,public abstract boolean isNullable() ,public boolean isReinitializable(java.lang.Object) ,public boolean isValueRangeEntityIndependent() ,public void linkVariableDescriptors(org.optaplanner.core.impl.domain.policy.DescriptorPolicy) ,public void processAnnotations(org.optaplanner.core.impl.domain.policy.DescriptorPolicy) ,public java.lang.String toString() <variables>private SelectionSorter<Solution_,java.lang.Object> decreasingStrengthSorter,private SelectionSorter<Solution_,java.lang.Object> increasingStrengthSorter,private SelectionFilter<Solution_,java.lang.Object> movableChainedTrailingValueFilter,private ValueRangeDescriptor<Solution_> valueRangeDescriptor
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/variable/descriptor/ListVariableDescriptor.java
ListVariableDescriptor
processValueRangeRefs
class ListVariableDescriptor<Solution_> extends GenuineVariableDescriptor<Solution_> { // ************************************************************************ // Constructors and simple getters/setters // ************************************************************************ public ListVariableDescriptor(EntityDescriptor<Solution_> entityDescriptor, MemberAccessor variableMemberAccessor) { super(entityDescriptor, variableMemberAccessor); } // ************************************************************************ // Lifecycle methods // ************************************************************************ @Override protected void processPropertyAnnotations(DescriptorPolicy descriptorPolicy) { PlanningListVariable planningVariableAnnotation = variableMemberAccessor.getAnnotation(PlanningListVariable.class); processValueRangeRefs(descriptorPolicy, planningVariableAnnotation.valueRangeProviderRefs()); } @Override protected void processValueRangeRefs(DescriptorPolicy descriptorPolicy, String[] valueRangeProviderRefs) {<FILL_FUNCTION_BODY>} // ************************************************************************ // Worker methods // ************************************************************************ @Override public boolean isGenuineListVariable() { return true; } @Override public boolean isListVariable() { return true; } @Override public boolean isChained() { return false; } @Override public boolean isNullable() { return false; } @Override public boolean acceptsValueType(Class<?> valueType) { return getElementType().isAssignableFrom(valueType); } public Class<?> getElementType() { return ConfigUtils.extractCollectionGenericTypeParameterStrictly( "entityClass", entityDescriptor.getEntityClass(), variableMemberAccessor.getType(), variableMemberAccessor.getGenericType(), PlanningListVariable.class, variableMemberAccessor.getName()); } // ************************************************************************ // Extraction methods // ************************************************************************ @Override public boolean isInitialized(Object entity) { return true; } public List<Object> getListVariable(Object entity) { return (List<Object>) getValue(entity); } public Object removeElement(Object entity, int index) { return getListVariable(entity).remove(index); } public void addElement(Object entity, int index, Object element) { getListVariable(entity).add(index, element); } public Object getElement(Object entity, int index) { return getListVariable(entity).get(index); } public Object setElement(Object entity, int index, Object element) { return getListVariable(entity).set(index, element); } public int getListSize(Object entity) { return getListVariable(entity).size(); } }
List<String> fromEntityValueRangeProviderRefs = Arrays.stream(valueRangeProviderRefs) .filter(descriptorPolicy::hasFromEntityValueRangeProvider) .collect(Collectors.toList()); if (!fromEntityValueRangeProviderRefs.isEmpty()) { throw new IllegalArgumentException("@" + ValueRangeProvider.class.getSimpleName() + " on a @" + PlanningEntity.class.getSimpleName() + " is not supported with a list variable (" + this + ").\n" + "Maybe move the valueRangeProvider" + (fromEntityValueRangeProviderRefs.size() > 1 ? "s" : "") + " (" + fromEntityValueRangeProviderRefs + ") from the entity class to the @" + PlanningSolution.class.getSimpleName() + " class."); } super.processValueRangeRefs(descriptorPolicy, valueRangeProviderRefs);
695
221
916
<methods>public void <init>(EntityDescriptor<Solution_>, org.optaplanner.core.impl.domain.common.accessor.MemberAccessor) ,public abstract boolean acceptsValueType(Class<?>) ,public SelectionSorter<Solution_,java.lang.Object> getDecreasingStrengthSorter() ,public SelectionSorter<Solution_,java.lang.Object> getIncreasingStrengthSorter() ,public SelectionFilter<Solution_,java.lang.Object> getMovableChainedTrailingValueFilter() ,public long getValueCount(Solution_, java.lang.Object) ,public ValueRangeDescriptor<Solution_> getValueRangeDescriptor() ,public boolean hasMovableChainedTrailingValueFilter() ,public abstract boolean isChained() ,public boolean isGenuineAndUninitialized(java.lang.Object) ,public abstract boolean isInitialized(java.lang.Object) ,public abstract boolean isListVariable() ,public abstract boolean isNullable() ,public boolean isReinitializable(java.lang.Object) ,public boolean isValueRangeEntityIndependent() ,public void linkVariableDescriptors(org.optaplanner.core.impl.domain.policy.DescriptorPolicy) ,public void processAnnotations(org.optaplanner.core.impl.domain.policy.DescriptorPolicy) ,public java.lang.String toString() <variables>private SelectionSorter<Solution_,java.lang.Object> decreasingStrengthSorter,private SelectionSorter<Solution_,java.lang.Object> increasingStrengthSorter,private SelectionFilter<Solution_,java.lang.Object> movableChainedTrailingValueFilter,private ValueRangeDescriptor<Solution_> valueRangeDescriptor
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/variable/index/ExternalizedIndexVariableSupply.java
ExternalizedIndexVariableSupply
updateIndexes
class ExternalizedIndexVariableSupply<Solution_> implements SourcedVariableListener<Solution_>, ListVariableListener<Solution_, Object, Object>, IndexVariableSupply { protected final ListVariableDescriptor<Solution_> sourceVariableDescriptor; protected Map<Object, Integer> indexMap = null; public ExternalizedIndexVariableSupply(ListVariableDescriptor<Solution_> sourceVariableDescriptor) { this.sourceVariableDescriptor = sourceVariableDescriptor; } @Override public VariableDescriptor<Solution_> getSourceVariableDescriptor() { return sourceVariableDescriptor; } @Override public void resetWorkingSolution(ScoreDirector<Solution_> scoreDirector) { indexMap = new IdentityHashMap<>(); sourceVariableDescriptor.getEntityDescriptor().visitAllEntities(scoreDirector.getWorkingSolution(), this::insert); } @Override public void close() { indexMap = null; } @Override public void beforeEntityAdded(ScoreDirector<Solution_> scoreDirector, Object entity) { // Do nothing } @Override public void afterEntityAdded(ScoreDirector<Solution_> scoreDirector, Object entity) { insert(entity); } @Override public void afterListVariableElementUnassigned(ScoreDirector<Solution_> scoreDirector, Object element) { Integer oldIndex = indexMap.remove(element); if (oldIndex == null) { throw new IllegalStateException("The supply (" + this + ") is corrupted," + " because the element (" + element + ") has an oldIndex (" + oldIndex + ") which is null."); } } @Override public void beforeListVariableChanged(ScoreDirector<Solution_> scoreDirector, Object entity, int fromIndex, int toIndex) { // Do nothing } @Override public void afterListVariableChanged(ScoreDirector<Solution_> scoreDirector, Object entity, int fromIndex, int toIndex) { updateIndexes(entity, fromIndex); } @Override public void beforeEntityRemoved(ScoreDirector<Solution_> scoreDirector, Object entity) { // Do nothing } @Override public void afterEntityRemoved(ScoreDirector<Solution_> scoreDirector, Object entity) { // When the entity is removed, its values become unassigned. An unassigned value has no inverse entity and no index. retract(entity); } private void insert(Object entity) { List<Object> listVariable = sourceVariableDescriptor.getListVariable(entity); int index = 0; for (Object element : listVariable) { Integer oldIndex = indexMap.put(element, index); if (oldIndex != null) { throw new IllegalStateException("The supply (" + this + ") is corrupted," + " because the element (" + element + ") at index (" + index + ") has an oldIndex (" + oldIndex + ") which is not null."); } index++; } } private void retract(Object entity) { List<Object> listVariable = sourceVariableDescriptor.getListVariable(entity); int index = 0; for (Object element : listVariable) { Integer oldIndex = indexMap.remove(element); if (!Objects.equals(oldIndex, index)) { throw new IllegalStateException("The supply (" + this + ") is corrupted," + " because the element (" + element + ") at index (" + index + ") has an oldIndex (" + oldIndex + ") which is unexpected."); } index++; } } private void updateIndexes(Object entity, int startIndex) {<FILL_FUNCTION_BODY>} @Override public Integer getIndex(Object element) { return indexMap.get(element); } @Override public String toString() { return getClass().getSimpleName() + "(" + sourceVariableDescriptor.getVariableName() + ")"; } }
List<Object> listVariable = sourceVariableDescriptor.getListVariable(entity); for (int index = startIndex; index < listVariable.size(); index++) { Object element = listVariable.get(index); Integer oldIndex = indexMap.put(element, index); // The first element is allowed to have a null oldIndex because it might have been just assigned. if (oldIndex == null && index != startIndex) { throw new IllegalStateException("The supply (" + this + ") is corrupted," + " because the element (" + element + ") at index (" + index + ") has an oldIndex (" + oldIndex + ") which is null."); } }
1,035
172
1,207
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/variable/index/IndexShadowVariableDescriptor.java
IndexShadowVariableDescriptor
linkShadowSources
class IndexShadowVariableDescriptor<Solution_> extends ShadowVariableDescriptor<Solution_> { protected ListVariableDescriptor<Solution_> sourceVariableDescriptor; public IndexShadowVariableDescriptor( EntityDescriptor<Solution_> entityDescriptor, MemberAccessor variableMemberAccessor) { super(entityDescriptor, variableMemberAccessor); if (!variableMemberAccessor.getType().equals(Integer.class) && !variableMemberAccessor.getType().equals(Long.class)) { throw new IllegalStateException("The entityClass (" + entityDescriptor.getEntityClass() + ") has an @" + IndexShadowVariable.class.getSimpleName() + " annotated member (" + variableMemberAccessor + ") of type (" + variableMemberAccessor.getType() + ") which cannot represent an index in a list.\n" + "The @" + IndexShadowVariable.class.getSimpleName() + " annotated member type must be " + Integer.class + " or " + Long.class + "."); } } @Override public void processAnnotations(DescriptorPolicy descriptorPolicy) { // Do nothing } @Override public void linkVariableDescriptors(DescriptorPolicy descriptorPolicy) { linkShadowSources(descriptorPolicy); } private void linkShadowSources(DescriptorPolicy descriptorPolicy) {<FILL_FUNCTION_BODY>} @Override public List<VariableDescriptor<Solution_>> getSourceVariableDescriptorList() { return Collections.singletonList(sourceVariableDescriptor); } @Override public Collection<Class<? extends AbstractVariableListener>> getVariableListenerClasses() { return Collections.singleton(IndexVariableListener.class); } @Override public IndexVariableDemand<Solution_> getProvidedDemand() { return new IndexVariableDemand<>(sourceVariableDescriptor); } @Override public Iterable<VariableListenerWithSources<Solution_>> buildVariableListeners(SupplyManager supplyManager) { return new VariableListenerWithSources<>(new IndexVariableListener<>(this, sourceVariableDescriptor), sourceVariableDescriptor).toCollection(); } @Override public Integer getValue(Object entity) { return (Integer) super.getValue(entity); } }
String sourceVariableName = variableMemberAccessor.getAnnotation(IndexShadowVariable.class).sourceVariableName(); List<EntityDescriptor<Solution_>> entitiesWithSourceVariable = entityDescriptor.getSolutionDescriptor().getEntityDescriptors().stream() .filter(entityDescriptor -> entityDescriptor.hasVariableDescriptor(sourceVariableName)) .collect(Collectors.toList()); if (entitiesWithSourceVariable.isEmpty()) { throw new IllegalArgumentException("The entityClass (" + entityDescriptor.getEntityClass() + ") has an @" + IndexShadowVariable.class.getSimpleName() + " annotated property (" + variableMemberAccessor.getName() + ") with sourceVariableName (" + sourceVariableName + ") which is not a valid planning variable on any of the entity classes (" + entityDescriptor.getSolutionDescriptor().getEntityDescriptors() + ")."); } if (entitiesWithSourceVariable.size() > 1) { throw new IllegalArgumentException("The entityClass (" + entityDescriptor.getEntityClass() + ") has an @" + IndexShadowVariable.class.getSimpleName() + " annotated property (" + variableMemberAccessor.getName() + ") with sourceVariableName (" + sourceVariableName + ") which is not a unique planning variable." + " A planning variable with the name (" + sourceVariableName + ") exists on multiple entity classes (" + entitiesWithSourceVariable + ")."); } VariableDescriptor<Solution_> variableDescriptor = entitiesWithSourceVariable.get(0).getVariableDescriptor(sourceVariableName); if (variableDescriptor == null) { throw new IllegalStateException( "Impossible state: variableDescriptor (" + variableDescriptor + ") is null" + " but previous checks indicate that the entityClass (" + entitiesWithSourceVariable.get(0) + ") has a planning variable with sourceVariableName (" + sourceVariableName + ")."); } if (!(variableDescriptor instanceof ListVariableDescriptor)) { throw new IllegalArgumentException("The entityClass (" + entityDescriptor.getEntityClass() + ") has an @" + IndexShadowVariable.class.getSimpleName() + " annotated property (" + variableMemberAccessor.getName() + ") with sourceVariableName (" + sourceVariableName + ") which is not a @" + PlanningListVariable.class.getSimpleName() + "."); } sourceVariableDescriptor = (ListVariableDescriptor<Solution_>) variableDescriptor; sourceVariableDescriptor.registerSinkVariableDescriptor(this);
571
602
1,173
<methods>public void <init>(EntityDescriptor<Solution_>, org.optaplanner.core.impl.domain.common.accessor.MemberAccessor) ,public abstract Iterable<VariableListenerWithSources<Solution_>> buildVariableListeners(org.optaplanner.core.impl.domain.variable.supply.SupplyManager) ,public int getGlobalShadowOrder() ,public abstract Demand<?> getProvidedDemand() ,public abstract List<VariableDescriptor<Solution_>> getSourceVariableDescriptorList() ,public abstract Collection<Class<? extends AbstractVariableListener#RAW>> getVariableListenerClasses() ,public boolean hasVariableListener() ,public boolean isGenuineAndUninitialized(java.lang.Object) ,public abstract void processAnnotations(org.optaplanner.core.impl.domain.policy.DescriptorPolicy) ,public void setGlobalShadowOrder(int) ,public java.lang.String toString() <variables>private int globalShadowOrder
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/variable/index/IndexVariableListener.java
IndexVariableListener
updateIndexes
class IndexVariableListener<Solution_> implements ListVariableListener<Solution_, Object, Object>, IndexVariableSupply { protected final IndexShadowVariableDescriptor<Solution_> shadowVariableDescriptor; protected final ListVariableDescriptor<Solution_> sourceVariableDescriptor; private static final int NEVER_QUIT_EARLY = Integer.MAX_VALUE; public IndexVariableListener( IndexShadowVariableDescriptor<Solution_> shadowVariableDescriptor, ListVariableDescriptor<Solution_> sourceVariableDescriptor) { this.shadowVariableDescriptor = shadowVariableDescriptor; this.sourceVariableDescriptor = sourceVariableDescriptor; } @Override public void beforeEntityAdded(ScoreDirector<Solution_> scoreDirector, Object entity) { // Do nothing } @Override public void afterEntityAdded(ScoreDirector<Solution_> scoreDirector, Object entity) { updateIndexes((InnerScoreDirector<Solution_, ?>) scoreDirector, entity, 0, NEVER_QUIT_EARLY); } @Override public void beforeEntityRemoved(ScoreDirector<Solution_> scoreDirector, Object entity) { // Do nothing } @Override public void afterEntityRemoved(ScoreDirector<Solution_> scoreDirector, Object entity) { InnerScoreDirector<Solution_, ?> innerScoreDirector = (InnerScoreDirector<Solution_, ?>) scoreDirector; List<Object> listVariable = sourceVariableDescriptor.getListVariable(entity); for (Object element : listVariable) { innerScoreDirector.beforeVariableChanged(shadowVariableDescriptor, element); shadowVariableDescriptor.setValue(element, null); innerScoreDirector.afterVariableChanged(shadowVariableDescriptor, element); } } @Override public void afterListVariableElementUnassigned(ScoreDirector<Solution_> scoreDirector, Object element) { InnerScoreDirector<Solution_, ?> innerScoreDirector = (InnerScoreDirector<Solution_, ?>) scoreDirector; innerScoreDirector.beforeVariableChanged(shadowVariableDescriptor, element); shadowVariableDescriptor.setValue(element, null); innerScoreDirector.afterVariableChanged(shadowVariableDescriptor, element); } @Override public void beforeListVariableChanged(ScoreDirector<Solution_> scoreDirector, Object entity, int fromIndex, int toIndex) { // Do nothing } @Override public void afterListVariableChanged(ScoreDirector<Solution_> scoreDirector, Object entity, int fromIndex, int toIndex) { InnerScoreDirector<Solution_, ?> innerScoreDirector = (InnerScoreDirector<Solution_, ?>) scoreDirector; updateIndexes(innerScoreDirector, entity, fromIndex, toIndex); } private void updateIndexes(InnerScoreDirector<Solution_, ?> scoreDirector, Object entity, int fromIndex, int toIndex) {<FILL_FUNCTION_BODY>} @Override public Integer getIndex(Object planningValue) { return shadowVariableDescriptor.getValue(planningValue); } }
List<Object> listVariable = sourceVariableDescriptor.getListVariable(entity); for (int i = fromIndex; i < listVariable.size(); i++) { Object element = listVariable.get(i); Integer oldIndex = shadowVariableDescriptor.getValue(element); if (!Objects.equals(oldIndex, i)) { scoreDirector.beforeVariableChanged(shadowVariableDescriptor, element); shadowVariableDescriptor.setValue(element, i); scoreDirector.afterVariableChanged(shadowVariableDescriptor, element); } else if (i >= toIndex) { // Do not quit early while inside the affected subList range. // Example 1. When X is moved from Ann[3] to Beth[3], we need to start updating Beth's elements at index 3 // where X already has the expected index, but quitting there would be incorrect because all the elements // above X need their indexes incremented. // Example 2. After ListSwapMove(Ann, 5, 9), the listener must not quit at index 6, but it can quit at index 10. return; } }
781
273
1,054
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/variable/inverserelation/CollectionInverseVariableListener.java
CollectionInverseVariableListener
retract
class CollectionInverseVariableListener<Solution_> implements VariableListener<Solution_, Object>, CollectionInverseVariableSupply { protected final InverseRelationShadowVariableDescriptor<Solution_> shadowVariableDescriptor; protected final VariableDescriptor<Solution_> sourceVariableDescriptor; public CollectionInverseVariableListener(InverseRelationShadowVariableDescriptor<Solution_> shadowVariableDescriptor, VariableDescriptor<Solution_> sourceVariableDescriptor) { this.shadowVariableDescriptor = shadowVariableDescriptor; this.sourceVariableDescriptor = sourceVariableDescriptor; } @Override public void beforeEntityAdded(ScoreDirector<Solution_> scoreDirector, Object entity) { // Do nothing } @Override public void afterEntityAdded(ScoreDirector<Solution_> scoreDirector, Object entity) { insert((InnerScoreDirector<Solution_, ?>) scoreDirector, entity); } @Override public void beforeVariableChanged(ScoreDirector<Solution_> scoreDirector, Object entity) { retract((InnerScoreDirector<Solution_, ?>) scoreDirector, entity); } @Override public void afterVariableChanged(ScoreDirector<Solution_> scoreDirector, Object entity) { insert((InnerScoreDirector<Solution_, ?>) scoreDirector, entity); } @Override public void beforeEntityRemoved(ScoreDirector<Solution_> scoreDirector, Object entity) { retract((InnerScoreDirector<Solution_, ?>) scoreDirector, entity); } @Override public void afterEntityRemoved(ScoreDirector<Solution_> scoreDirector, Object entity) { // Do nothing } protected void insert(InnerScoreDirector<Solution_, ?> scoreDirector, Object entity) { Object shadowEntity = sourceVariableDescriptor.getValue(entity); if (shadowEntity != null) { Collection shadowCollection = (Collection) shadowVariableDescriptor.getValue(shadowEntity); if (shadowCollection == null) { throw new IllegalStateException("The entity (" + entity + ") has a variable (" + sourceVariableDescriptor.getVariableName() + ") with value (" + shadowEntity + ") which has a sourceVariableName variable (" + shadowVariableDescriptor.getVariableName() + ") with a value (" + shadowCollection + ") which is null.\n" + "Verify the consistency of your input problem for that bi-directional relationship.\n" + "Every non-singleton inverse variable can never be null. It should at least be an empty " + Collection.class.getSimpleName() + " instead."); } scoreDirector.beforeVariableChanged(shadowVariableDescriptor, shadowEntity); boolean added = shadowCollection.add(entity); if (!added) { throw new IllegalStateException("The entity (" + entity + ") has a variable (" + sourceVariableDescriptor.getVariableName() + ") with value (" + shadowEntity + ") which has a sourceVariableName variable (" + shadowVariableDescriptor.getVariableName() + ") with a value (" + shadowCollection + ") which already contained the entity (" + entity + ").\n" + "Verify the consistency of your input problem for that bi-directional relationship."); } scoreDirector.afterVariableChanged(shadowVariableDescriptor, shadowEntity); } } protected void retract(InnerScoreDirector<Solution_, ?> scoreDirector, Object entity) {<FILL_FUNCTION_BODY>} @Override public Collection<?> getInverseCollection(Object planningValue) { return (Collection<?>) shadowVariableDescriptor.getValue(planningValue); } }
Object shadowEntity = sourceVariableDescriptor.getValue(entity); if (shadowEntity != null) { Collection shadowCollection = (Collection) shadowVariableDescriptor.getValue(shadowEntity); if (shadowCollection == null) { throw new IllegalStateException("The entity (" + entity + ") has a variable (" + sourceVariableDescriptor.getVariableName() + ") with value (" + shadowEntity + ") which has a sourceVariableName variable (" + shadowVariableDescriptor.getVariableName() + ") with a value (" + shadowCollection + ") which is null.\n" + "Verify the consistency of your input problem for that bi-directional relationship.\n" + "Every non-singleton inverse variable can never be null. It should at least be an empty " + Collection.class.getSimpleName() + " instead."); } scoreDirector.beforeVariableChanged(shadowVariableDescriptor, shadowEntity); boolean removed = shadowCollection.remove(entity); if (!removed) { throw new IllegalStateException("The entity (" + entity + ") has a variable (" + sourceVariableDescriptor.getVariableName() + ") with value (" + shadowEntity + ") which has a sourceVariableName variable (" + shadowVariableDescriptor.getVariableName() + ") with a value (" + shadowCollection + ") which did not contain the entity (" + entity + ").\n" + "Verify the consistency of your input problem for that bi-directional relationship."); } scoreDirector.afterVariableChanged(shadowVariableDescriptor, shadowEntity); }
906
369
1,275
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/variable/inverserelation/ExternalizedCollectionInverseVariableSupply.java
ExternalizedCollectionInverseVariableSupply
insert
class ExternalizedCollectionInverseVariableSupply<Solution_> implements SourcedVariableListener<Solution_>, VariableListener<Solution_, Object>, CollectionInverseVariableSupply { protected final VariableDescriptor<Solution_> sourceVariableDescriptor; protected Map<Object, Set<Object>> inverseEntitySetMap = null; public ExternalizedCollectionInverseVariableSupply(VariableDescriptor<Solution_> sourceVariableDescriptor) { this.sourceVariableDescriptor = sourceVariableDescriptor; } @Override public VariableDescriptor<Solution_> getSourceVariableDescriptor() { return sourceVariableDescriptor; } @Override public void resetWorkingSolution(ScoreDirector<Solution_> scoreDirector) { inverseEntitySetMap = new IdentityHashMap<>(); sourceVariableDescriptor.getEntityDescriptor().visitAllEntities(scoreDirector.getWorkingSolution(), this::insert); } @Override public void close() { inverseEntitySetMap = null; } @Override public void beforeEntityAdded(ScoreDirector<Solution_> scoreDirector, Object entity) { // Do nothing } @Override public void afterEntityAdded(ScoreDirector<Solution_> scoreDirector, Object entity) { insert(entity); } @Override public void beforeVariableChanged(ScoreDirector<Solution_> scoreDirector, Object entity) { retract(entity); } @Override public void afterVariableChanged(ScoreDirector<Solution_> scoreDirector, Object entity) { insert(entity); } @Override public void beforeEntityRemoved(ScoreDirector<Solution_> scoreDirector, Object entity) { retract(entity); } @Override public void afterEntityRemoved(ScoreDirector<Solution_> scoreDirector, Object entity) { // Do nothing } protected void insert(Object entity) {<FILL_FUNCTION_BODY>} protected void retract(Object entity) { Object value = sourceVariableDescriptor.getValue(entity); if (value == null) { return; } Set<Object> inverseEntitySet = inverseEntitySetMap.get(value); boolean removeSucceeded = inverseEntitySet.remove(entity); if (!removeSucceeded) { throw new IllegalStateException("The supply (" + this + ") is corrupted," + " because the entity (" + entity + ") for sourceVariable (" + sourceVariableDescriptor.getVariableName() + ") cannot be retracted: it was never inserted."); } if (inverseEntitySet.isEmpty()) { inverseEntitySetMap.put(value, null); } } @Override public Collection<?> getInverseCollection(Object value) { Set<Object> inverseEntitySet = inverseEntitySetMap.get(value); if (inverseEntitySet == null) { return Collections.emptySet(); } return inverseEntitySet; } @Override public String toString() { return getClass().getSimpleName() + "(" + sourceVariableDescriptor.getVariableName() + ")"; } }
Object value = sourceVariableDescriptor.getValue(entity); if (value == null) { return; } Set<Object> inverseEntitySet = inverseEntitySetMap.computeIfAbsent(value, k -> Collections.newSetFromMap(new IdentityHashMap<>())); boolean addSucceeded = inverseEntitySet.add(entity); if (!addSucceeded) { throw new IllegalStateException("The supply (" + this + ") is corrupted," + " because the entity (" + entity + ") for sourceVariable (" + sourceVariableDescriptor.getVariableName() + ") cannot be inserted: it was already inserted."); }
812
164
976
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/variable/listener/support/AbstractNotifiable.java
AbstractNotifiable
buildNotifiable
class AbstractNotifiable<Solution_, T extends AbstractVariableListener<Solution_, Object>> implements EntityNotifiable<Solution_> { private final ScoreDirector<Solution_> scoreDirector; private final T variableListener; private final Collection<Notification<Solution_, ? super T>> notificationQueue; private final int globalOrder; static <Solution_> EntityNotifiable<Solution_> buildNotifiable( ScoreDirector<Solution_> scoreDirector, AbstractVariableListener<Solution_, Object> variableListener, int globalOrder) {<FILL_FUNCTION_BODY>} AbstractNotifiable(ScoreDirector<Solution_> scoreDirector, T variableListener, Collection<Notification<Solution_, ? super T>> notificationQueue, int globalOrder) { this.scoreDirector = scoreDirector; this.variableListener = variableListener; this.notificationQueue = notificationQueue; this.globalOrder = globalOrder; } @Override public void notifyBefore(EntityNotification<Solution_> notification) { if (notificationQueue.add(notification)) { notification.triggerBefore(variableListener, scoreDirector); } } protected boolean storeForLater(Notification<Solution_, T> notification) { return notificationQueue.add(notification); } protected void triggerBefore(Notification<Solution_, T> notification) { notification.triggerBefore(variableListener, scoreDirector); } @Override public void resetWorkingSolution() { variableListener.resetWorkingSolution(scoreDirector); } @Override public void closeVariableListener() { variableListener.close(); } @Override public void triggerAllNotifications() { int notifiedCount = 0; for (Notification<Solution_, ? super T> notification : notificationQueue) { notification.triggerAfter(variableListener, scoreDirector); notifiedCount++; } if (notifiedCount != notificationQueue.size()) { throw new IllegalStateException("The variableListener (" + variableListener.getClass() + ") has been notified with notifiedCount (" + notifiedCount + ") but after being triggered, its notificationCount (" + notificationQueue.size() + ") is different.\n" + "Maybe that variableListener (" + variableListener.getClass() + ") changed an upstream shadow variable (which is illegal)."); } notificationQueue.clear(); } @Override public String toString() { return "(" + globalOrder + ") " + variableListener; } }
if (variableListener instanceof ListVariableListener) { return new ListVariableListenerNotifiable<>( scoreDirector, ((ListVariableListener<Solution_, Object, Object>) variableListener), new ArrayDeque<>(), globalOrder); } else { VariableListener<Solution_, Object> basicVariableListener = (VariableListener<Solution_, Object>) variableListener; return new VariableListenerNotifiable<>( scoreDirector, basicVariableListener, basicVariableListener.requiresUniqueEntityEvents() ? new ListBasedScalingOrderedSet<>() : new ArrayDeque<>(), globalOrder); }
656
162
818
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/variable/listener/support/AbstractNotification.java
AbstractNotification
equals
class AbstractNotification { protected final Object entity; protected AbstractNotification(Object entity) { this.entity = entity; } /** * Warning: do not test equality of {@link AbstractNotification}s for different {@link VariableListener}s * (so {@link ShadowVariableDescriptor}s) because equality does not take those into account (for performance)! * * @param o sometimes null * @return true if same entity instance and the same type */ @Override public boolean equals(Object o) {<FILL_FUNCTION_BODY>} @Override public int hashCode() { return Objects.hash(System.identityHashCode(entity), getClass()); } }
if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } AbstractNotification that = (AbstractNotification) o; return entity.equals(that.entity);
182
70
252
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/variable/listener/support/ElementUnassignedNotification.java
ElementUnassignedNotification
triggerBefore
class ElementUnassignedNotification<Solution_> implements ListVariableNotification<Solution_> { private final Object element; ElementUnassignedNotification(Object element) { this.element = element; } @Override public void triggerBefore(ListVariableListener<Solution_, Object, Object> variableListener, ScoreDirector<Solution_> scoreDirector) {<FILL_FUNCTION_BODY>} @Override public void triggerAfter(ListVariableListener<Solution_, Object, Object> variableListener, ScoreDirector<Solution_> scoreDirector) { variableListener.afterListVariableElementUnassigned(scoreDirector, element); } @Override public String toString() { return "ElementUnassigned(" + element + ")"; } }
throw new UnsupportedOperationException("ListVariableListeners do not listen for this event.");
204
23
227
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/variable/listener/support/ListVariableChangedNotification.java
ListVariableChangedNotification
toString
class ListVariableChangedNotification<Solution_> extends AbstractNotification implements ListVariableNotification<Solution_> { private final int fromIndex; private final int toIndex; ListVariableChangedNotification(Object entity, int fromIndex, int toIndex) { super(entity); this.fromIndex = fromIndex; this.toIndex = toIndex; } @Override public void triggerBefore(ListVariableListener<Solution_, Object, Object> variableListener, ScoreDirector<Solution_> scoreDirector) { variableListener.beforeListVariableChanged(scoreDirector, entity, fromIndex, toIndex); } @Override public void triggerAfter(ListVariableListener<Solution_, Object, Object> variableListener, ScoreDirector<Solution_> scoreDirector) { variableListener.afterListVariableChanged(scoreDirector, entity, fromIndex, toIndex); } @Override public String toString() {<FILL_FUNCTION_BODY>} }
return "ListVariableChangedNotification(" + entity + "[" + fromIndex + ".." + toIndex + "])";
253
31
284
<methods>public boolean equals(java.lang.Object) ,public int hashCode() <variables>protected final non-sealed java.lang.Object entity
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/variable/listener/support/violation/ShadowVariableSnapshot.java
ShadowVariableSnapshot
validate
class ShadowVariableSnapshot { private final ShadowVariableDescriptor<?> shadowVariableDescriptor; private final Object entity; private final Object originalValue; private ShadowVariableSnapshot(ShadowVariableDescriptor<?> shadowVariableDescriptor, Object entity, Object originalValue) { this.shadowVariableDescriptor = shadowVariableDescriptor; this.entity = entity; this.originalValue = originalValue; } static ShadowVariableSnapshot of(ShadowVariableDescriptor<?> shadowVariableDescriptor, Object entity) { return new ShadowVariableSnapshot(shadowVariableDescriptor, entity, shadowVariableDescriptor.getValue(entity)); } void validate(Consumer<String> violationMessageConsumer) {<FILL_FUNCTION_BODY>} ShadowVariableDescriptor<?> getShadowVariableDescriptor() { return shadowVariableDescriptor; } @Override public String toString() { return entity + "." + shadowVariableDescriptor.getVariableName() + " = " + originalValue; } }
Object newValue = shadowVariableDescriptor.getValue(entity); if (!Objects.equals(originalValue, newValue)) { violationMessageConsumer.accept(" The entity (" + entity + ")'s shadow variable (" + shadowVariableDescriptor.getSimpleEntityAndVariableName() + ")'s corrupted value (" + originalValue + ") changed to uncorrupted value (" + newValue + ") after all variable listeners were triggered without changes to the genuine variables.\n" + " Maybe one of the listeners (" + shadowVariableDescriptor.getVariableListenerClasses().stream() .map(Class::getSimpleName) .collect(Collectors.toList()) + ") for that shadow variable (" + shadowVariableDescriptor.getSimpleEntityAndVariableName() + ") forgot to update it when one of its sourceVariables (" + shadowVariableDescriptor.getSourceVariableDescriptorList().stream() .map(VariableDescriptor::getSimpleEntityAndVariableName) .collect(Collectors.toList()) + ") changed.\n" + " Or vice versa, maybe one of the listeners computes this shadow variable using a planning variable" + " that is not declared as its source." + " Use the repeatable @" + ShadowVariable.class.getSimpleName() + " annotation for each source variable that is used to compute this shadow variable." + "\n"); }
246
328
574
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/variable/listener/support/violation/ShadowVariablesAssert.java
ShadowVariablesAssert
format
class ShadowVariablesAssert { private final List<ShadowVariableSnapshot> shadowVariableSnapshots; private ShadowVariablesAssert(List<ShadowVariableSnapshot> shadowVariableSnapshots) { this.shadowVariableSnapshots = shadowVariableSnapshots; } public static <Solution_> ShadowVariablesAssert takeSnapshot( SolutionDescriptor<Solution_> solutionDescriptor, Solution_ workingSolution) { List<ShadowVariableSnapshot> shadowVariableSnapshots = new ArrayList<>(); solutionDescriptor.visitAllEntities(workingSolution, entity -> solutionDescriptor.findEntityDescriptorOrFail(entity.getClass()) .getShadowVariableDescriptors().stream() .map(shadowVariableDescriptor -> ShadowVariableSnapshot.of(shadowVariableDescriptor, entity)) .forEach(shadowVariableSnapshots::add)); return new ShadowVariablesAssert(shadowVariableSnapshots); } /** * Takes a look at the shadow variables of all entities and compares them against the recorded state. Every difference * is added to the violation message. The first N differences up to the {@code violationDisplayLimit} are displayed * in detail; the number of violations exceeding the display limit is reported at the end. The limit applies per each * shadow variable descriptor. * <p> * This method should be called after a forceful trigger of variable listeners. * * @param violationDisplayLimit maximum number of violations reported per shadow variable descriptor * @return description of the violations or {@code null} if there are none */ public String createShadowVariablesViolationMessage(long violationDisplayLimit) { Map<ShadowVariableDescriptor<?>, List<String>> violationListMap = collectViolations(); if (violationListMap.isEmpty()) { return null; } return format(violationListMap, violationDisplayLimit); } private Map<ShadowVariableDescriptor<?>, List<String>> collectViolations() { Map<ShadowVariableDescriptor<?>, List<String>> violationListMap = new TreeMap<>( comparing(ShadowVariableDescriptor::getGlobalShadowOrder)); for (ShadowVariableSnapshot shadowVariableSnapshot : shadowVariableSnapshots) { shadowVariableSnapshot.validate(violationMessage -> violationListMap .computeIfAbsent(shadowVariableSnapshot.getShadowVariableDescriptor(), k -> new ArrayList<>()) .add(violationMessage)); } return violationListMap; } private String format(Map<ShadowVariableDescriptor<?>, List<String>> violationListMap, long violationDisplayLimit) {<FILL_FUNCTION_BODY>} }
StringBuilder message = new StringBuilder(); violationListMap.forEach((shadowVariableDescriptor, violationList) -> { violationList.stream().limit(violationDisplayLimit).forEach(message::append); if (violationList.size() >= violationDisplayLimit) { message.append(" ... ").append(violationList.size() - violationDisplayLimit) .append(" more\n"); } }); return message.toString();
650
112
762
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/domain/variable/supply/AbstractVariableDescriptorBasedDemand.java
AbstractVariableDescriptorBasedDemand
hashCode
class AbstractVariableDescriptorBasedDemand<Solution_, Supply_ extends Supply> implements Demand<Supply_> { protected final VariableDescriptor<Solution_> variableDescriptor; protected AbstractVariableDescriptorBasedDemand(VariableDescriptor<Solution_> variableDescriptor) { this.variableDescriptor = Objects.requireNonNull(variableDescriptor); } @Override public final boolean equals(Object other) { if (this == other) return true; if (other == null || getClass() != other.getClass()) return false; AbstractVariableDescriptorBasedDemand<?, ?> that = (AbstractVariableDescriptorBasedDemand<?, ?>) other; return Objects.equals(variableDescriptor, that.variableDescriptor); } @Override public final int hashCode() {<FILL_FUNCTION_BODY>} @Override public final String toString() { return getClass().getSimpleName() + "(" + variableDescriptor.getSimpleEntityAndVariableName() + ")"; } }
// Don't use Objects.hashCode(...) as that would create varargs array on the hot path. int result = this.getClass().getName().hashCode(); result = 31 * result + variableDescriptor.hashCode(); return result;
260
62
322
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/exhaustivesearch/node/comparator/BreadthFirstNodeComparator.java
BreadthFirstNodeComparator
compare
class BreadthFirstNodeComparator implements Comparator<ExhaustiveSearchNode> { private final boolean scoreBounderEnabled; public BreadthFirstNodeComparator(boolean scoreBounderEnabled) { this.scoreBounderEnabled = scoreBounderEnabled; } @Override public int compare(ExhaustiveSearchNode a, ExhaustiveSearchNode b) {<FILL_FUNCTION_BODY>} }
// Investigate shallower nodes first int aDepth = a.getDepth(); int bDepth = b.getDepth(); if (aDepth < bDepth) { return 1; } else if (aDepth > bDepth) { return -1; } // Investigate better score first (ignore initScore to avoid depth first ordering) int scoreComparison = a.getScore().withInitScore(0).compareTo(b.getScore().withInitScore(0)); if (scoreComparison < 0) { return -1; } else if (scoreComparison > 0) { return 1; } if (scoreBounderEnabled) { // Investigate better optimistic bound first int optimisticBoundComparison = a.getOptimisticBound().compareTo(b.getOptimisticBound()); if (optimisticBoundComparison < 0) { return -1; } else if (optimisticBoundComparison > 0) { return 1; } } // No point to investigating higher parent breadth index first (no impact on the churn on workingSolution) // Investigate lower breadth index first (to respect ValueSortingManner) return Long.compare(b.getBreadth(), a.getBreadth());
114
316
430
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/exhaustivesearch/node/comparator/OptimisticBoundFirstNodeComparator.java
OptimisticBoundFirstNodeComparator
compare
class OptimisticBoundFirstNodeComparator implements Comparator<ExhaustiveSearchNode> { public OptimisticBoundFirstNodeComparator(boolean scoreBounderEnabled) { if (!scoreBounderEnabled) { throw new IllegalArgumentException("This " + getClass().getSimpleName() + " only works if scoreBounderEnabled (" + scoreBounderEnabled + ") is true."); } } @Override public int compare(ExhaustiveSearchNode a, ExhaustiveSearchNode b) {<FILL_FUNCTION_BODY>} }
// Investigate better optimistic bound first (ignore initScore to avoid depth first ordering) int optimisticBoundComparison = a.getOptimisticBound().compareTo(b.getOptimisticBound()); if (optimisticBoundComparison < 0) { return -1; } else if (optimisticBoundComparison > 0) { return 1; } // Investigate better score first int scoreComparison = a.getScore().withInitScore(0).compareTo(b.getScore().withInitScore(0)); if (scoreComparison < 0) { return -1; } else if (scoreComparison > 0) { return 1; } // Investigate deeper first int aDepth = a.getDepth(); int bDepth = b.getDepth(); if (aDepth < bDepth) { return -1; } else if (aDepth > bDepth) { return 1; } // Investigate higher parent breadth index first (to reduce on the churn on workingSolution) long aParentBreadth = a.getParentBreadth(); long bParentBreadth = b.getParentBreadth(); if (aParentBreadth < bParentBreadth) { return -1; } else if (aParentBreadth > bParentBreadth) { return 1; } // Investigate lower breadth index first (to respect ValueSortingManner) return Long.compare(b.getBreadth(), a.getBreadth());
141
383
524
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/exhaustivesearch/node/comparator/OriginalOrderNodeComparator.java
OriginalOrderNodeComparator
compare
class OriginalOrderNodeComparator implements Comparator<ExhaustiveSearchNode> { @Override public int compare(ExhaustiveSearchNode a, ExhaustiveSearchNode b) {<FILL_FUNCTION_BODY>} }
// Investigate deeper first int aDepth = a.getDepth(); int bDepth = b.getDepth(); if (aDepth < bDepth) { return -1; } else if (aDepth > bDepth) { return 1; } // Investigate lower breadth index first (to respect ValueSortingManner) return Long.compare(b.getBreadth(), a.getBreadth());
64
111
175
<no_super_class>
apache_incubator-kie-optaplanner
incubator-kie-optaplanner/core/optaplanner-core-impl/src/main/java/org/optaplanner/core/impl/exhaustivesearch/node/comparator/ScoreFirstNodeComparator.java
ScoreFirstNodeComparator
compare
class ScoreFirstNodeComparator implements Comparator<ExhaustiveSearchNode> { public ScoreFirstNodeComparator(boolean scoreBounderEnabled) { if (!scoreBounderEnabled) { throw new IllegalArgumentException("This " + getClass().getSimpleName() + " only works if scoreBounderEnabled (" + scoreBounderEnabled + ") is true."); } } @Override public int compare(ExhaustiveSearchNode a, ExhaustiveSearchNode b) {<FILL_FUNCTION_BODY>} }
// Investigate better score first (ignore initScore to avoid depth first ordering) int scoreComparison = a.getScore().withInitScore(0).compareTo(b.getScore().withInitScore(0)); if (scoreComparison < 0) { return -1; } else if (scoreComparison > 0) { return 1; } // Investigate better optimistic bound first int optimisticBoundComparison = a.getOptimisticBound().compareTo(b.getOptimisticBound()); if (optimisticBoundComparison < 0) { return -1; } else if (optimisticBoundComparison > 0) { return 1; } // Investigate deeper first int aDepth = a.getDepth(); int bDepth = b.getDepth(); if (aDepth < bDepth) { return -1; } else if (aDepth > bDepth) { return 1; } // Investigate higher parent breadth index first (to reduce on the churn on workingSolution) long aParentBreadth = a.getParentBreadth(); long bParentBreadth = b.getParentBreadth(); if (aParentBreadth < bParentBreadth) { return -1; } else if (aParentBreadth > bParentBreadth) { return 1; } // Investigate lower breadth index first (to respect ValueSortingManner) return Long.compare(b.getBreadth(), a.getBreadth());
139
383
522
<no_super_class>