org.optaplanner.examples.common.experimental.impl.Interval Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of optaplanner-examples Show documentation
Show all versions of optaplanner-examples Show documentation
OptaPlanner solves planning problems.
This lightweight, embeddable planning engine implements powerful and scalable algorithms
to optimize business resource scheduling and planning.
This module contains the examples which demonstrate how to use it in a normal Java application.
package org.optaplanner.examples.common.experimental.impl;
import java.util.function.Function;
public final class Interval> {
private final Interval_ value;
private final IntervalSplitPoint startSplitPoint;
private final IntervalSplitPoint endSplitPoint;
public Interval(Interval_ value, Function startMapping,
Function endMapping) {
this.value = value;
Point_ start = startMapping.apply(value);
Point_ end = endMapping.apply(value);
this.startSplitPoint = new IntervalSplitPoint<>(start);
if (start == end) {
this.endSplitPoint = this.startSplitPoint;
} else {
this.endSplitPoint = new IntervalSplitPoint<>(end);
}
}
public Interval_ getValue() {
return value;
}
public Point_ getStart() {
return startSplitPoint.splitPoint;
}
public Point_ getEnd() {
return endSplitPoint.splitPoint;
}
public IntervalSplitPoint getStartSplitPoint() {
return startSplitPoint;
}
public IntervalSplitPoint getEndSplitPoint() {
return endSplitPoint;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
Interval, ?> that = (Interval, ?>) o;
return value == that.value;
}
@Override
public int hashCode() {
return System.identityHashCode(value);
}
@Override
public String toString() {
return "Interval{" +
"value=" + value +
", start=" + getStart() +
", end=" + getEnd() +
'}';
}
}