Package org.opendaylight.yangtools.util
Class ForwardingIdentityObject<T>
- java.lang.Object
-
- com.google.common.collect.ForwardingObject
-
- org.opendaylight.yangtools.util.ForwardingIdentityObject<T>
-
- Type Parameters:
T
- Type of wrapped object
- All Implemented Interfaces:
Delegator<T>
@Beta @NonNullByDefault public abstract class ForwardingIdentityObject<T> extends ForwardingObject implements Delegator<T>
AForwardingObject
which additionally maskshashCode()
/equals(Object)
of a delegate object, so that it can be a data transfer object with data-dependent implementations of those contracts can be use in collections and maps which need to work on identity. This is useful in situations where identity equality needs to be used with the conjunction with the collections library, for exampleConcurrentHashMap
. All instances are considered equal if they refer to the same delegate object.Note this class forms its own equality domain, and its use may lead to surprising results, especially where
ForwardingObject.toString()
is involved. For example aMap.toString()
may end up emitting two keys which have the same String representation.- Author:
- Robert Varga
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ForwardingIdentityObject()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract @NonNull T
delegate()
boolean
equals(@Nullable Object obj)
@NonNull T
getDelegate()
Return underlying delegate.int
hashCode()
static <T> ForwardingIdentityObject<T>
of(T obj)
-
Methods inherited from class com.google.common.collect.ForwardingObject
toString
-
-
-
-
Method Detail
-
of
public static <T> ForwardingIdentityObject<T> of(T obj)
-
getDelegate
public final @NonNull T getDelegate()
Description copied from interface:Delegator
Return underlying delegate.- Specified by:
getDelegate
in interfaceDelegator<T>
- Returns:
- underlying delegate.
-
delegate
protected abstract @NonNull T delegate()
- Specified by:
delegate
in classForwardingObject
-
-