view flys-backend/src/main/java/de/intevation/flys/utils/EpsilonComparator.java @ 5200:42bb6ff78d1b 2.9.11

Directly set the connectionInitSqls on the datasource Somehow the factory fails to set the connectionInitSqls if we add it to the dbcpProperties. So we now set it directly
author Andre Heinecke <aheinecke@intevation.de>
date Fri, 08 Mar 2013 11:48:33 +0100
parents ce6b9945bf8e
children
line wrap: on
line source
package de.intevation.flys.utils;

import java.util.Comparator;

/** Comparator with some tolerance (epsilon). */
public class EpsilonComparator implements Comparator<Double>
{
    public static final double EPSILON = 1e-4;

    /** Ready-made comparator with 1e-4 tolerance. */
    public static final EpsilonComparator CMP = new EpsilonComparator(EPSILON);

    private double epsilon;

    public EpsilonComparator(double epsilon) {
        this.epsilon = epsilon;
    }

    @Override
    public int compare(Double a, Double b) {
        double diff = a - b;
        if (diff < -epsilon) return -1;
        if (diff >  epsilon) return +1;
        return 0;
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org