T
- Type of wrapped object@Beta @NonNullByDefault public abstract class ForwardingIdentityObject<T> extends ForwardingObject implements Delegator<T>
ForwardingObject
which additionally masks hashCode()
/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 example ConcurrentHashMap
. 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 a Map.toString()
may end up emitting two keys which have the
same String representation.
Modifier | Constructor and Description |
---|---|
protected |
ForwardingIdentityObject() |
Modifier and Type | Method and Description |
---|---|
protected abstract T |
delegate() |
boolean |
equals(@Nullable Object obj) |
T |
getDelegate()
Return underlying delegate.
|
int |
hashCode() |
static <T> ForwardingIdentityObject<T> |
of(T obj) |
toString
public static <T> ForwardingIdentityObject<T> of(T obj)
public final T getDelegate()
Delegator
getDelegate
in interface Delegator<T>
protected abstract T delegate()
delegate
in class ForwardingObject
Copyright © 2020 OpenDaylight. All rights reserved.