Interface LenientComparable

    • Method Detail

      • equals

        boolean equals​(Object other,
                       ComparisonMode mode)
        Compares this object with the given object for equality. The strictness level is controlled by the second argument, from stricter to more permissive values:
        Description of comparison modes
        STRICT: All attributes of the compared objects shall be strictly equal.
        BY_CONTRACT: Only the attributes published in the interface contract need to be compared.
        IGNORE_METADATA: Only the attributes relevant to the object functionality are compared.
        APPROXIMATE: Only the attributes relevant to the object functionality are compared, with some tolerance threshold on numerical values.
        DEBUG: Special mode for figuring out why two objects expected to be equal are not.
        Conformance to the equals(Object) method contract
        Comparison­Mode​.STRICT is the only mode compliant with the Object​.equals(Object) contract. For all other modes m, the comparison is not guaranteed to be symmetric neither transitive:
        • x​.equals(y,m) is not guaranteed to be equal to y​.equals(x,m). In particular, the BY_CONTRACT mode and all modes below it will typically compare only the properties known to this instance, ignoring any properties that may be known only by the other instance.
        • x​.equals(y,m) and y​.equals(z,m) does not implies x​.equals(z,m). In particular, the use of a comparison threshold for the APPROXIMATE mode is incompatible with the transitivity contract.
        Parameters:
        other - the object to compare to this.
        mode - the strictness level of the comparison.
        Returns:
        true if both objects are equal according the given comparison mode.
        See Also:
        Utilities​.deep­Equals(Object, Object, Comparison­Mode)
      • equals

        boolean equals​(Object other)
        Returns true if this object is strictly equals to the given object. This method is usually implemented as below:
        public boolean equals(Object other) {
            return equals(other, ComparisonMode.STRICT);
        }
        Implementers shall ensure that the following conditions hold. Unless the equals behavior is clearly documented in the interface javadoc (as for example in the Java collection framework), Comparison­Mode​.STRICT is the only reliable mode for this method implementation.
        • A​.equals(B) implies B​.equals(A);
        • A​.equals(B) and B​.equals(C) implies A​.equals(C);
        • A​.equals(B) implies A​.hash­Code() == B​.hash­Code();
        This method is declared final in most SIS implementations for ensuring that subclasses override the above equals(Object, Comparison­Mode) method instead than this one.
        Overrides:
        equals in class Object
        Parameters:
        other - the object to compare to this.
        Returns:
        true if both objects are strictly equal.
        See Also:
        Comparison­Mode​.STRICT