Class AbstractProxyHashObject

java.lang.Object
com.globalmentor.model.AbstractProxyHashObject

public abstract class AbstractProxyHashObject extends Object
An object that delegates generation of a hash code and determination of equality to other objects. This class is useful for creating keys used in hash tables, for example. This class keeps references to the proxy objects for its entire lifespan. Hash codes and equality are determined dynamically with each call. This class is abstract to increase type safety through subclassing.
Author:
Garret Wilson
  • Constructor Details

    • AbstractProxyHashObject

      public AbstractProxyHashObject(Object... proxiedObjects)
      Proxied object constructor. Any or all of the proxied objects may be null, but the array of objects may not.
      Parameters:
      proxiedObjects - The objects to be proxied for generation of hash code and equality determination.
      Throws:
      NullPointerException - if the array of proxied objects is null.
  • Method Details

    • hashCode

      public int hashCode()
      Returns a hash code value for the object. The hash code is determined dynamically from the proxied objects.
      Overrides:
      hashCode in class Object
      Returns:
      A hash code for this object calculated from the proxied objects.
    • equals

      public boolean equals(Object object)
      Indicates whether some other object is "equal to" this one. The other object must be a proxy hash object and one of the objects must be an instance of the other to be considered equal. Equality is determined by calling the Object.equals(Object) of the corresponding proxied objects, in order.
      Overrides:
      equals in class Object
      Parameters:
      object - The reference object with which to compare.
      Returns:
      true if this object's proxied objects and those of the reference object are equal.