Class AbstractOpaqueData<T>
java.lang.Object
org.opendaylight.yangtools.binding.lib.AbstractOpaqueData<T>
- Type Parameters:
T
- Data object model type
- All Implemented Interfaces:
OpaqueData<T>
,Immutable
Utility class for
OpaqueData
implementations. This class provides baseline implementation of
hashCode()
and equals(Object)
as specified by OpaqueData
. For cases where the object
model's objects do not provide a usable implementation of hashCode/equals, this class is expected to be subclassed
to provide alternative implementation of dataHashCode()
and dataEquals(Object)
methods. Such
class should be made public in a convenient place. Note such customized methods are required to maintain consistency
between hashCode and equals, as well as the reflexive, symmetric, transitive and
consistent properties as detailed in Object.equals(Object)
.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected MoreObjects.ToStringHelper
protected boolean
dataEquals
(@NonNull Object otherData) protected int
Determine hashCode of the data.final boolean
Compare this object to another object.final int
hashCode()
The hash code of anyOpaqueData
instance is defined by the combination of its object model and the data it holds.final String
toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.opendaylight.yangtools.binding.OpaqueData
getData, getObjectModel
-
Constructor Details
-
AbstractOpaqueData
public AbstractOpaqueData()
-
-
Method Details
-
hashCode
public final int hashCode()Description copied from interface:OpaqueData
The hash code of anyOpaqueData
instance is defined by the combination of its object model and the data it holds. This is inherently object-model-specific hence different OpaqueData defined by distinct object models will result in differing hash codes. This implies that node with differing object models cannot compare as equal. SeehashCode()
for canonical implementation.- Specified by:
hashCode
in interfaceOpaqueData<T>
- Overrides:
hashCode
in classObject
- Returns:
- a hash code value for this object.
-
equals
Description copied from interface:OpaqueData
Compare this object to another object. The comparison needs to take into accountOpaqueData.getObjectModel()
first and then follow comparison onOpaqueData.getData()
. For canonical algorithm please refer toequals(Object)
.- Specified by:
equals
in interfaceOpaqueData<T>
- Overrides:
equals
in classObject
- Parameters:
obj
- the reference object with which to compare.- Returns:
true
if this object is the same as the obj argument;false
otherwise.
-
toString
-
addToStringAttributes
-
dataHashCode
protected int dataHashCode()Determine hashCode of the data. The default implementation uses the data object'shashCode
method.- Returns:
- Hash code value of data
-
dataEquals
-