Class AbstractObjectDecorator<T>

java.lang.Object
com.globalmentor.model.AbstractObjectDecorator<T>
Type Parameters:
T - The type of object being decorated.
Direct Known Subclasses:
ObjectDecorator, ObjectHolder

public abstract class AbstractObjectDecorator<T> extends 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 Details

    • AbstractObjectDecorator

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

    • 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 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(Object object)
      Overrides:
      equals in class 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 String toString()
      Overrides:
      toString in class 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.