/** * Compares this unit with the given object for equality, * optionally ignoring metadata and rounding errors. */ @Override public boolean equals(final Object other, final ComparisonMode mode) { if (other == null || other.getClass() != getClass()) { return false; } if (mode.isIgnoringMetadata()) { return true; } final AbstractUnit<?> that = (AbstractUnit<?>) other; return equals(epsg, that.epsg) && equals(scope, that.scope) && Objects.equals(symbol, that.symbol); }
/** * Compares this converter with the given object for equality, optionally ignoring rounding errors. */ @Override public boolean equals(final Object other, final ComparisonMode mode) { if (mode.isApproximative()) { return (other instanceof LinearConverter) && equivalent((LinearConverter) other); } else { return equals(other); } }
/** * Returns {@code true} if this comparison uses a tolerance threshold. * This method currently returns {@code true} for {@code APPROXIMATIVE} or {@code DEBUG} only, * but this list may be extended in future SIS versions. * * @return whether this comparison uses a tolerance threshold. * * @since 0.6 */ public boolean isApproximative() { return ordinal() >= APPROXIMATIVE.ordinal(); }
if (!mode.isApproximative()) { final int tc = hashCode; if (tc != 0) { if (mode.isIgnoringMetadata()) { return true;
try { final ReferenceSystem def = CRS.forCode(identifier); final ComparisonMode c = ComparisonMode.equalityLevel(def, rs); if (c == null) { state = State.MISMATCH;
if (!mode.isApproximative()) { final int tc = hashCode; if (tc != 0) { if (mode.isIgnoringMetadata()) { return true;
/** * Compares this unit with the given object for equality, * optionally ignoring metadata and rounding errors. */ @Override public boolean equals(final Object other, final ComparisonMode mode) { if (other == null || other.getClass() != getClass()) { return false; } if (mode.isIgnoringMetadata()) { return true; } final AbstractUnit<?> that = (AbstractUnit<?>) other; return equals(epsg, that.epsg) && equals(scope, that.scope) && Objects.equals(symbol, that.symbol); }
/** * Compares this converter with the given object for equality, optionally ignoring rounding errors. */ @Override public boolean equals(final Object other, final ComparisonMode mode) { if (mode.isApproximative()) { return (other instanceof LinearConverter) && equivalent((LinearConverter) other); } else { return equals(other); } }
/** * Returns {@code true} if this comparison ignores metadata. * This method currently returns {@code true} for {@code IGNORE_METADATA}, {@code APPROXIMATIVE} * or {@code DEBUG} only, but this list may be extended in future SIS versions. * * @return whether this comparison ignore metadata. * * @since 0.6 */ public boolean isIgnoringMetadata() { return ordinal() >= IGNORE_METADATA.ordinal(); }
if (other == null) return false; if (proxy.getClass() == other.getClass()) { if (mode.isIgnoringMetadata()) { return true;
/** * Returns {@code true} if the given values are approximatively equal given the comparison mode. * In mode {@code APPROXIMATIVE} or {@code DEBUG}, this method will compute a relative comparison * threshold from the {@link #COMPARISON_THRESHOLD} constant. * * <p>This method does not thrown {@link AssertionError} in {@link ComparisonMode#DEBUG}. * It is caller responsibility to handle the {@code DEBUG} case.</p> * * @param v1 the first value to compare. * @param v2 the second value to compare. * @param mode the comparison mode to use for comparing the numbers. * @return {@code true} if both values are considered equal for the given comparison mode. */ public static boolean epsilonEqual(final double v1, final double v2, final ComparisonMode mode) { if (mode.isApproximative()) { final double mg = max(abs(v1), abs(v2)); if (mg != Double.POSITIVE_INFINITY) { return epsilonEqual(v1, v2, COMPARISON_THRESHOLD * mg); } } return equals(v1, v2); }
/** * Returns {@code true} if this comparison uses a tolerance threshold. * This method currently returns {@code true} for {@code APPROXIMATIVE} or {@code DEBUG} only, * but this list may be extended in future SIS versions. * * @return whether this comparison uses a tolerance threshold. * * @since 0.6 */ public boolean isApproximative() { return ordinal() >= APPROXIMATIVE.ordinal(); }
if (other == null) return false; if (proxy.getClass() == other.getClass()) { if (mode.isIgnoringMetadata()) { return true;
/** * Returns {@code true} if the given values are approximately equal given the comparison mode. * In mode {@code APPROXIMATIVE} or {@code DEBUG}, this method will compute a relative comparison * threshold from the {@link #COMPARISON_THRESHOLD} constant. * * <p>This method does not thrown {@link AssertionError} in {@link ComparisonMode#DEBUG}. * It is caller responsibility to handle the {@code DEBUG} case.</p> * * @param v1 the first value to compare. * @param v2 the second value to compare. * @param mode the comparison mode to use for comparing the numbers. * @return {@code true} if both values are considered equal for the given comparison mode. */ public static boolean epsilonEqual(final double v1, final double v2, final ComparisonMode mode) { if (mode.isApproximative()) { final double mg = max(abs(v1), abs(v2)); if (mg != Double.POSITIVE_INFINITY) { return epsilonEqual(v1, v2, COMPARISON_THRESHOLD * mg); } } return equals(v1, v2); }
/** * Returns {@code true} if this comparison ignores metadata. * This method currently returns {@code true} for {@code IGNORE_METADATA}, {@code APPROXIMATIVE} * or {@code DEBUG} only, but this list may be extended in future SIS versions. * * @return whether this comparison ignore metadata. * * @since 0.6 */ public boolean isIgnoringMetadata() { return ordinal() >= IGNORE_METADATA.ordinal(); }
/** * Compares the given objects for equality, ignoring parameter order in "ignore metadata" mode. */ static boolean equals(final Parameters expected, final ParameterValueGroup actual, final ComparisonMode mode) { if (!Utilities.deepEquals(expected.getDescriptor(), actual.getDescriptor(), mode)) { return false; } if (!mode.isIgnoringMetadata()) { return Utilities.deepEquals(expected.values(), actual.values(), mode); } final List<GeneralParameterValue> values = new LinkedList<>(expected.values()); scan: for (final GeneralParameterValue param : actual.values()) { final Iterator<GeneralParameterValue> it = values.iterator(); while (it.hasNext()) { if (Utilities.deepEquals(it.next(), param, mode)) { it.remove(); continue scan; } } return false; // A parameter from 'actual' has not been found in 'expected'. } return values.isEmpty(); }
return false; final boolean isApproximative = mode.isApproximative(); if (!isApproximative && getClass() == object.getClass()) { if (!equalsSameClass(object)) {
/** * Compares the given objects for equality, ignoring parameter order in "ignore metadata" mode. */ static boolean equals(final Parameters expected, final ParameterValueGroup actual, final ComparisonMode mode) { if (!Utilities.deepEquals(expected.getDescriptor(), actual.getDescriptor(), mode)) { return false; } if (!mode.isIgnoringMetadata()) { return Utilities.deepEquals(expected.values(), actual.values(), mode); } final List<GeneralParameterValue> values = new LinkedList<>(expected.values()); scan: for (final GeneralParameterValue param : actual.values()) { final Iterator<GeneralParameterValue> it = values.iterator(); while (it.hasNext()) { if (Utilities.deepEquals(it.next(), param, mode)) { it.remove(); continue scan; } } return false; // A parameter from 'actual' has not been found in 'expected'. } return values.isEmpty(); }
return false; final boolean isApproximative = mode.isApproximative(); if (!isApproximative && getClass() == object.getClass()) { if (!equalsSameClass(object)) {
/** * Compares this object with the given one for equality. * * @param object the object to compare with this reference system. * @param mode the strictness level of the comparison. * @return {@code true} if both objects are equal. */ @Override public boolean equals(final Object object, final ComparisonMode mode) { if (super.equals(object, mode) && (object instanceof ReferenceSystem)) { final ReferenceSystem that = (ReferenceSystem) object; if (mode.isIgnoringMetadata()) { // Compare the name because it was ignored by super.equals(…) in "ignore metadata" mode. return Objects.equals(getName(), that.getName()); } return that.getDomainOfValidity() == null && that.getScope() == null; } return false; } }