Define OpaqueData/OpaqueObject hashCode/equals
[mdsal.git] / binding / yang-binding / src / main / java / org / opendaylight / yangtools / yang / binding / OpaqueObject.java
index 1bedda44adceb7b3f51a350b38b2d7900c2c4b54..669cb0dc1d48f351bdb871fff353efaabc94dc8f 100644 (file)
@@ -20,6 +20,9 @@ import com.google.common.annotations.Beta;
  * of {@link #getImplementedInterface()} bound to itself. The value is communicated through {@link #getValue()}, which
  * is only an encapsulation holding information about the object model and the data in that object model.
  *
+ * <p>
+ * Implementations are strongly encouraged to use {@link AbstractOpaqueObject} as their base implementation class.
+ *
  * @param <T> Generated interface
  */
 @Beta
@@ -27,4 +30,24 @@ public interface OpaqueObject<T extends OpaqueObject<T>> extends BindingObject,
         ValueAware<OpaqueData<?>> {
     @Override
     Class<T> getImplementedInterface();
+
+    /**
+     * Hash code value of this object. This is a combination of {@link #getImplementedInterface()} and the value being
+     * held. The canonical computation algorithm is defined in {@link AbstractOpaqueObject#hashCode()}.
+     *
+     * @return a hash code value for this object.
+     */
+    @Override
+    int hashCode();
+
+    /**
+     * Compare this object to another object. The comparison needs to take into account
+     * {@link #getImplementedInterface()} first and then follow comparison on {@link #getValue()}. For canonical
+     * algorithm please refer to {@link AbstractOpaqueObject#equals(Object)}.
+     *
+     * @param obj the reference object with which to compare.
+     * @return {@code true} if this object is the same as the obj argument; {@code false} otherwise.
+     */
+    @Override
+    boolean equals(Object obj);
 }