commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1580660 - /commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/TransitionTarget.java
Date Sun, 23 Mar 2014 23:31:55 GMT
Author: ate
Date: Sun Mar 23 23:31:54 2014
New Revision: 1580660

URL: http://svn.apache.org/r1580660
Log:
SCXML-196: The Algorithm for SCXML interpretation requires sets of TransitionTarget instances
to be processed.
To conform to the Set equality contract TransitionTarget must implement the equals and hashcode
methods.
But in the context of SCXML and the purpose of the algorithm, really only identity based equality
should be considered.
The TransitionTarget#id property also could be used, but that would make the API much more
awkward to ensure only unique IDs are used, that is: within the context of a single SCXML
instance.
Much easier therefore is to just enforce and only support identity based equality.

Modified:
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/TransitionTarget.java

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/TransitionTarget.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/TransitionTarget.java?rev=1580660&r1=1580659&r2=1580660&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/TransitionTarget.java
(original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/TransitionTarget.java
Sun Mar 23 23:31:54 2014
@@ -118,5 +118,24 @@ public abstract class TransitionTarget i
         System.arraycopy(parent.ancestors, 0, ancestors, 0, parent.ancestors.length);
         ancestors[parent.ancestors.length] = parent;
     }
+
+    /**
+     * Enforce identity equality only
+     * @param other other object to compare with
+     * @return this == other
+     */
+    @Override
+    public final boolean equals(final Object other) {
+        return this == other;
+    }
+
+    /**
+     * Enforce returning identity based hascode
+     * @return {@link System#identityHashCode(Object) System.identityHashCode(this)}
+     */
+    @Override
+    public final int hashCode() {
+        return System.identityHashCode(this);
+    }
 }
 



Mime
View raw message