Package org.apache.commons.collections4.functors

# Class DefaultEquator<T>

java.lang.Object
org.apache.commons.collections4.functors.DefaultEquator<T>

Type Parameters:
  `T` - the types of object this `Equator` can evaluate.

All Implemented Interfaces:
  `Serializable`, `Equator<T>`

public class DefaultEquator<T> extends Object implements Equator<T>, Serializable
Default `Equator` implementation.

Since:
  4.0
See Also:
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `HASHCODE_NULL`
  Hashcode used for `null` objects.
  `static final DefaultEquator`
  `INSTANCE`
  Static instance

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static <T> DefaultEquator<T>`
  `defaultEquator()`
  Factory returning the typed singleton instance.
  `boolean`
  `equate(T o1, T o2)`
  Evaluates the two arguments for their equality.
  `int`
  `hash(T o)`
  Calculates the hash for the object, based on the method of equality used in the equate method.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### INSTANCE

    public static final DefaultEquator INSTANCE
    Static instance

  - ### HASHCODE_NULL

    public static final int HASHCODE_NULL
    Hashcode used for `null` objects.
    See Also:
      - Constant Field Values

- ## Method Details

  - ### defaultEquator

    public static <T> DefaultEquator<T> defaultEquator()
    Factory returning the typed singleton instance.
    Type Parameters:
      `T` - the object type
    Returns:
      The singleton instance

  - ### equate

    public boolean equate(T o1, T o2)
    Evaluates the two arguments for their equality. Delegates to `Objects.equals(Object, Object)`.
    Specified by:
      `equate` in interface `Equator<T>`
    Parameters:
      `o1` - The first object to be equated.
      `o2` - The second object to be equated.
    Returns:
      whether the two objects are equal.

  - ### hash

    public int hash(T o)
    Calculates the hash for the object, based on the method of equality used in the equate method. This is used for classes that delegate their `equals(Object)` method to an Equator (and so must also delegate their `hashCode()` method), or for implementations of `HashedMap` that use an Equator for the key objects.
    Specified by:
      `hash` in interface `Equator<T>`
    Parameters:
      `o` - The object to calculate the hash for.
    Returns:
      `o.hashCode()` if `o` is non- `null`, else `HASHCODE_NULL`.