Tabnine Logo
ComparisonMode
Code IndexAdd Tabnine to your IDE (free)

How to use
ComparisonMode
in
org.apache.sis.util

Best Java code snippets using org.apache.sis.util.ComparisonMode (Showing top 20 results out of 315)

origin: apache/sis

/**
 * 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);
}
origin: org.apache.sis.core/sis-utility

/**
 * 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);
  }
}
origin: apache/sis

/**
 * 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();
}
origin: apache/sis

if (!mode.isApproximative()) {
  final int tc = hashCode;
  if (tc != 0) {
if (mode.isIgnoringMetadata()) {
  return true;
origin: apache/sis

try {
  final ReferenceSystem def = CRS.forCode(identifier);
  final ComparisonMode c = ComparisonMode.equalityLevel(def, rs);
  if (c == null) {
    state = State.MISMATCH;
origin: org.apache.sis.core/sis-referencing

if (!mode.isApproximative()) {
  final int tc = hashCode;
  if (tc != 0) {
if (mode.isIgnoringMetadata()) {
  return true;
origin: org.apache.sis.core/sis-utility

/**
 * 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);
}
origin: apache/sis

/**
 * 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);
  }
}
origin: org.apache.sis.core/sis-utility

/**
 * 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();
}
origin: apache/sis

if (other == null) return false;
if (proxy.getClass() == other.getClass()) {
  if (mode.isIgnoringMetadata()) {
    return true;
origin: org.apache.sis.core/sis-utility

/**
 * 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);
}
origin: org.apache.sis.core/sis-utility

/**
 * 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();
}
origin: org.apache.sis.core/sis-utility

if (other == null) return false;
if (proxy.getClass() == other.getClass()) {
  if (mode.isIgnoringMetadata()) {
    return true;
origin: apache/sis

/**
 * 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);
}
origin: apache/sis

/**
 * 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();
}
origin: org.apache.sis.core/sis-referencing

  /**
   * 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();
  }

origin: org.apache.sis.core/sis-referencing

  return false;
final boolean isApproximative = mode.isApproximative();
if (!isApproximative && getClass() == object.getClass()) {
  if (!equalsSameClass(object)) {
origin: apache/sis

  /**
   * 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();
  }

origin: apache/sis

  return false;
final boolean isApproximative = mode.isApproximative();
if (!isApproximative && getClass() == object.getClass()) {
  if (!equalsSameClass(object)) {
origin: apache/sis

  /**
   * 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;
  }
}
org.apache.sis.utilComparisonMode

Javadoc

Specifies the level of strictness when comparing two LenientComparable objects for equality. This enumeration allows users to specify which kind of differences can be tolerated between two objects: differences in implementation class, differences in some kinds of property, or slight difference in numerical values.

This enumeration is ordered from stricter to more lenient levels:

  1. #STRICT – All attributes of the compared objects shall be strictly equal.
  2. #BY_CONTRACT – Only the attributes published in the interface contract need to be compared.
  3. #IGNORE_METADATA – Only the attributes relevant to the object functionality are compared.
  4. #APPROXIMATIVE – Only the attributes relevant to the object functionality are compared, with some tolerance threshold on numerical values.
  5. #ALLOW_VARIANT – For objects not really equal but related (e.g. CRS using different axis order).
  6. #DEBUG – Special mode for figuring out why two objects expected to be equal are not.
If two objects are equal at some level of strictness E, then they should also be equal at all levels listed below E in the above list. For example if two objects are equal at the #BY_CONTRACT level, then they should also be equal at the #IGNORE_METADATA level but not necessarily at the #STRICT level.

Most used methods

  • isIgnoringMetadata
    Returns true if this comparison ignores metadata. This method currently returns true for IGNORE_META
  • isApproximative
    Returns true if this comparison uses a tolerance threshold. This method currently returns true for A
  • equalityLevel
    If the two given objects are equal according one of the modes enumerated in this class, then returns
  • ordinal

Popular in Java

  • Updating database using SQL prepared statement
  • findViewById (Activity)
  • requestLocationUpdates (LocationManager)
  • startActivity (Activity)
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • 21 Best Atom Packages for 2021
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now