Codota Logo
ComparisonMode
Code IndexAdd Codota 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)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
SimpleDateFormat s =
  • Codota IconString pattern;new SimpleDateFormat(pattern)
  • Codota IconString template;Locale locale;new SimpleDateFormat(template, locale)
  • Codota Iconnew SimpleDateFormat()
  • Smart code suggestions by Codota
}
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

  • Parsing JSON documents to java classes using gson
  • findViewById (Activity)
  • addToBackStack (FragmentTransaction)
  • startActivity (Activity)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • TreeSet (java.util)
    A NavigableSet implementation based on a TreeMap. The elements are ordered using their Comparable, o
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • Collectors (java.util.stream)
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now