Class AbstractObjectDecorator<T>

  • Type Parameters:
    T - The type of object being decorated.
    Direct Known Subclasses:
    ObjectDecorator, ObjectHolder

    public abstract class AbstractObjectDecorator<T>
    extends java.lang.Object
    An object that decorates another object, preserving the Object.hashCode() and Object.equals(Object) of the decorated object. Equality is only supported for exact top-level types.
    Author:
    Garret Wilson
    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractObjectDecorator​(T decoratedObject)
      Decorated object constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object object)
      protected T getObject()  
      int hashCode()
      protected void setObject​(T decoratedObject)
      Sets the decorated object.
      java.lang.String toString()
      • Methods inherited from class java.lang.Object

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

      • AbstractObjectDecorator

        public AbstractObjectDecorator​(T decoratedObject)
        Decorated object constructor.
        Parameters:
        decoratedObject - The object to decorate.
    • Method Detail

      • getObject

        protected T getObject()
        Returns:
        The decorated object.
      • setObject

        protected void setObject​(T decoratedObject)
        Sets the decorated object.
        Parameters:
        decoratedObject - The object to decorate.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
        Implementation Specification:
        This version returns the hash code of the decorated object if there is one; otherwise this method delegates to the parent class.
      • equals

        public boolean equals​(java.lang.Object object)
        Overrides:
        equals in class java.lang.Object
        Implementation Specification:
        This version considers the given object equal to this object if it is of the same type as this object, and this object's decorated object's Object.equals(Object) method also returns true for the objects's decorated object or both decorated objects are null.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        Implementation Specification:
        This version returns a string version of the decorated object if there is one; otherwise this method delegates to the parent class.