All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.optaplanner.examples.common.experimental.impl.Interval Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 9.44.0.Final
Show newest version
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() +
                '}';
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy