Class ForwardingObject
- java.lang.Object
 - 
- com.google.common.collect.ForwardingObject
 
 
- 
- Direct Known Subclasses:
 ForwardingCache,ForwardingCollection,ForwardingExecutorService,ForwardingFuture,ForwardingIterator,ForwardingMap,ForwardingMapEntry,ForwardingMultimap,ForwardingService,ForwardingTable
@GwtCompatible public abstract class ForwardingObject extends java.lang.Object
An abstract base class for implementing the decorator pattern. Thedelegate()method must be overridden to return the instance being decorated.This class does not forward the
hashCodeandequalsmethods through to the backing object, but relies onObject's implementation. This is necessary to preserve the symmetry ofequals. Custom definitions of equality are usually based on an interface, such asSetorList, so that the implementation ofequalscan cast the object being tested for equality to the custom interface.ForwardingObjectimplements no such custom interfaces directly; they are implemented only in subclasses. Therefore, forwardingequalswould 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 asCollections.unmodifiableCollection(java.util.Collection<? extends T>). Use an interface-specific subclass ofForwardingObject, such asForwardingList, to preserve equality behavior, or overrideequalsdirectly.The
toStringmethod is forwarded to the delegate. Although this class does not implementSerializable, a serializable subclass may be created since this class has a parameter-less constructor.- Since:
 - 2.0 (imported from Google Collections Library)
 
 
- 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringtoString()Returns the string representation generated by the delegate'stoStringmethod. 
 -