@GwtCompatible public abstract class ForwardingObject extends Object
delegate()method must be overridden to return the instance being decorated.
This class does not forward the
equals methods through to
the backing object, but relies on
Object's implementation. This is necessary to preserve
the symmetry of
equals. Custom definitions of equality are usually based on an interface,
List, so that the implementation of
equals can cast the
object being tested for equality to the custom interface.
ForwardingObject implements no
such custom interfaces directly; they are implemented only in subclasses. Therefore, forwarding
equals would break symmetry, as the forwarding object might consider itself equal to the
object being tested, but the reverse could not be true. This behavior is consistent with the
JDK's collection wrappers, such as
Collections.unmodifiableCollection(java.util.Collection<? extends T>). Use an
interface-specific subclass of
ForwardingObject, such as
preserve equality behavior, or override
toString method is forwarded to the delegate. Although this class does not
Serializable, a serializable subclass may be created since this class has a
|Modifier||Constructor and Description|
Constructor for use by subclasses.
|Modifier and Type||Method and Description|
Returns the backing delegate instance that methods are forwarded to.
Returns the string representation generated by the delegate's
protected abstract Object delegate()
ForwardingSet.delegate(). Concrete subclasses override this method to supply the instance being decorated.
Copyright © 2010–2018. All rights reserved.