Class AbstractProxyHashObject


  • public abstract class AbstractProxyHashObject
    extends java.lang.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 Summary

      Constructors 
      Constructor Description
      AbstractProxyHashObject​(java.lang.Object... proxiedObjects)
      Proxied object constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object object)
      Indicates whether some other object is "equal to" this one.
      int hashCode()
      Returns a hash code value for the object.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractProxyHashObject

        public AbstractProxyHashObject​(java.lang.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:
        java.lang.NullPointerException - if the array of proxied objects is null.
    • Method Detail

      • 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 java.lang.Object
        Returns:
        A hash code for this object calculated from the proxied objects.
      • equals

        public boolean equals​(java.lang.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 java.lang.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.