Package com.globalmentor.model
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 java.lang.Object
An object that decorates another object, preserving theObject.hashCode()
andObject.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()
-
-
-
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 classjava.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 classjava.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 returnstrue
for the objects's decorated object or both decorated objects arenull
.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.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.
-
-