/*
 * This file is part of JaTeCS.
 *
 * JaTeCS is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * JaTeCS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with JaTeCS.  If not, see <http://www.gnu.org/licenses/>.
 *
 * The software has been mainly developed by (in alphabetical order):
 * - Andrea Esuli (andrea.esuli@isti.cnr.it)
 * - Tiziano Fagni (tiziano.fagni@isti.cnr.it)
 * - Alejandro Moreo Fernández (alejandro.moreo@isti.cnr.it)
 * Other past contributors were:
 * - Giacomo Berardi (giacomo.berardi@isti.cnr.it)
 */

package it.cnr.jatecs.indexing.discretization;


public class DiscreteBin implements Comparable<DiscreteBin> {
    private double startValue;
    private double endValue;

    public DiscreteBin(double startValue, double endValue) {
        this.startValue = startValue;
        this.endValue = endValue;
    }

    public double getStartValue() {
        return startValue;
    }

    public void setStartValue(double startValue) {
        this.startValue = startValue;
    }

    public double getEndValue() {
        return endValue;
    }

    public void setEndValue(double endValue) {
        this.endValue = endValue;
    }

    @Override
    public int compareTo(DiscreteBin o) {
        if (o == null)
            throw new NullPointerException("The specified object is 'null'");

        if (startValue < o.startValue)
            return -1;
        else if (startValue > o.startValue)
            return 1;
        else {
            if (endValue < o.endValue)
                return -1;
            else if (endValue > o.endValue)
                return 1;
            else
                return 0;
        }
    }

    @Override
    public boolean equals(Object obj) {
        if (!(obj instanceof DiscreteBin))
            return false;

        DiscreteBin bin = (DiscreteBin) obj;
        return compareTo(bin) == 0;
    }

    @Override
    public String toString() {
        return "Start: " + startValue + " End: " + endValue;
    }
}
