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

@Beta public abstract class AbstractOpaqueData<T> extends Object implements OpaqueData<T>
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 Details

    • AbstractOpaqueData

      public AbstractOpaqueData()
  • Method Details

    • hashCode

      public final int hashCode()
      Description copied from interface: OpaqueData
      The hash code of any OpaqueData 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. See hashCode() for canonical implementation.
      Specified by:
      hashCode in interface OpaqueData<T>
      Overrides:
      hashCode in class Object
      Returns:
      a hash code value for this object.
    • equals

      public final boolean equals(Object obj)
      Description copied from interface: OpaqueData
      Compare this object to another object. The comparison needs to take into account OpaqueData.getObjectModel() first and then follow comparison on OpaqueData.getData(). For canonical algorithm please refer to equals(Object).
      Specified by:
      equals in interface OpaqueData<T>
      Overrides:
      equals in class Object
      Parameters:
      obj - the reference object with which to compare.
      Returns:
      true if this object is the same as the obj argument; false otherwise.
    • toString

      public final String toString()
      Overrides:
      toString in class Object
    • addToStringAttributes

      protected MoreObjects.ToStringHelper addToStringAttributes(MoreObjects.ToStringHelper helper)
    • dataHashCode

      protected int dataHashCode()
      Determine hashCode of the data. The default implementation uses the data object's hashCode method.
      Returns:
      Hash code value of data
    • dataEquals

      protected boolean dataEquals(@NonNull Object otherData)