/** * Base implementation for the {@link Comparable#compareTo(Object)} method. This method will work only if the provided input object is a * {@link DefaultDomainElement1D}. * * <p> * Two {@link DefaultDomainElement1D}s are compared by comparing their lower bounds in order to establish an order between them. * * @return a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. * * @throws ClassCastException if the specified object's type prevents it from being compared to this Object. * * @see Comparable#compareTo(Object) * @todo we could improve this check for the specific case when the two minimums are equal */ public int compareTo(DomainElement1D o) { if (o instanceof DefaultDomainElement1D) return new Double(inputMinimum).compareTo(((DefaultDomainElement1D) o).inputMinimum); return new Double(inputMinimum).compareTo(o.getRange().getMin().doubleValue()); }
/** * Base implementation for the {@link Comparable#compareTo(Object)} method. This method will work only if the provided input object is a * {@link DefaultDomainElement1D}. * * <p> * Two {@link DefaultDomainElement1D}s are compared by comparing their lower bounds in order to establish an order between them. * * @return a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. * * @throws ClassCastException if the specified object's type prevents it from being compared to this Object. * * @see Comparable#compareTo(Object) * @todo we could improve this check for the specific case when the two minimums are equal */ public int compareTo(DomainElement1D o) { if (o instanceof DefaultDomainElement1D) return new Double(inputMinimum).compareTo(((DefaultDomainElement1D) o).inputMinimum); return new Double(inputMinimum).compareTo(o.getRange().getMin().doubleValue()); }
/** * Checks whether or not two DomainElement1Ds input range overlaps * * @param domainElements to be checked * @param idx index to start with */ public static void domainElementsOverlap(DomainElement1D[] domainElements, int idx) { // Two domain elements have overlapping ranges; // Format an error message............... final Range range1 = domainElements[idx - 1].getRange(); final Range range2 = domainElements[idx].getRange(); final Number[] args = new Number[] { range1.getMin(), range1.getMax(), range2.getMin(), range2.getMax() }; String[] results = new String[4]; for (int j = 0; j < args.length; j++) { final double value = (args[j]).doubleValue(); if (Double.isNaN(value)) { String hex = Long.toHexString(Double.doubleToRawLongBits(value)); results[j] = "NaN(" + hex + ')'; } else { results[j] = value + ""; } } throw new IllegalArgumentException("Provided ranges are overlapping:" + results[0] + " : " + results[1] + " / " + results[2] + " : " + results[3]); }
/** * Checks whether or not two DomainElement1Ds input range overlaps * * @param domainElements to be checked * @param idx index to start with */ public static void domainElementsOverlap(DomainElement1D[] domainElements, int idx) { // Two domain elements have overlapping ranges; // Format an error message............... final Range range1 = domainElements[idx - 1].getRange(); final Range range2 = domainElements[idx].getRange(); final Number[] args = new Number[] { range1.getMin(), range1.getMax(), range2.getMin(), range2.getMax() }; String[] results = new String[4]; for (int j = 0; j < args.length; j++) { final double value = (args[j]).doubleValue(); if (Double.isNaN(value)) { String hex = Long.toHexString(Double.doubleToRawLongBits(value)); results[j] = "NaN(" + hex + ')'; } else { results[j] = value + ""; } } throw new IllegalArgumentException("Provided ranges are overlapping:" + results[0] + " : " + results[1] + " / " + results[2] + " : " + results[3]); }