/*
 * ARX: Efficient, Stable and Optimal Data Anonymization
 * Copyright (C) 2012 - 2014 Florian Kohlmayer, Fabian Prasser
 * 
 * This program 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.
 * 
 * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
 */

package org.deidentifier.arx.metric;

/**
 * This class implements a default information loss which represents one single
 * metric. Note: this class has a natural ordering that is inconsistent with equals.
 * 
 * @author Prasser, Kohlmayer
 */
class InformationLossDefault extends InformationLoss {

    /** Max value */
    public static final InformationLoss MAX              = new InformationLossDefault(Double.MAX_VALUE);

    /** Min value */
    public static final InformationLoss MIN              = new InformationLossDefault(0);

    /**
     * 
     */
    private static final long           serialVersionUID = -4341081298410703417L;

    /** Current value */
    private double                      value;

    InformationLossDefault(final double value) {
        this.value = value;
    }

    @Override
    public int compareTo(final InformationLoss o) {
        if (getValue() > o.getValue()) {
            return 1;
        } else if (getValue() < o.getValue()) {
            return -1;
        } else {
            return 0;
        }
    }

    @Override
    public double getValue() {
        return value;
    }

    @Override
    public void max(final InformationLoss other) {
        if (other == null) { return; }
        if (other.getValue() > getValue()) {
            value = other.getValue();
        }
    }

    @Override
    public void min(final InformationLoss other) {
        if (other == null) { return; }
        if (other.getValue() < getValue()) {
            value = other.getValue();
        }
    }

    @Override
    protected InformationLoss clone() {
        return new InformationLossDefault(value);
    }
}

@@ -907,82 +907,8 @@
 ric.
- Note: this class has a natural ordering that is inconsistent with equals.
 %0A * 
@@ -1248,21 +1248,25 @@
  /**
-%0A     * %0A    
+ serialVersionUID
  */%0A
@@ -2352,11 +2352,649 @@
 );%0A    %7D
+%0A%0A    @Override%0A    public int hashCode() %7B%0A        final int prime = 31;%0A        int result = 1;%0A        long temp;%0A        temp = Double.doubleToLongBits(value);%0A        result = prime * result + (int) (temp %5E (temp %3E%3E%3E 32));%0A        return result;%0A    %7D%0A%0A    @Override%0A    public boolean equals(Object obj) %7B%0A        if (this == obj) return true;%0A        if (obj == null) return false;%0A        if (getClass() != obj.getClass()) return false;%0A        InformationLossDefault other = (InformationLossDefault) obj;%0A        if (Double.doubleToLongBits(value) != Double.doubleToLongBits(other.value)) return false;%0A        return true;%0A    %7D
 %0A%7D%0A

Implement equals() and hashCode() in class InformationLoss