]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.runtime/src/org/simantics/scl/runtime/function/UnsaturatedFunctionN.java
(refs #7090) Generated Function objects implement equals and hashCode
[simantics/platform.git] / bundles / org.simantics.scl.runtime / src / org / simantics / scl / runtime / function / UnsaturatedFunctionN.java
index c53b34735e4f1fdf4896227beb1b434148306f65..2ed78c5c4be38672dfd260dab473384f2668ff6f 100644 (file)
@@ -4,6 +4,8 @@
  */
 package org.simantics.scl.runtime.function;
 
+import java.util.Arrays;
+
 @SuppressWarnings("all")
 public class UnsaturatedFunctionN implements Function {
     private final Function f;
@@ -113,6 +115,7 @@ public class UnsaturatedFunctionN implements Function {
         System.arraycopy(ops, 0, nps, ps.length, ops.length);
         return f.applyArray(nps);
     }
+
     @Override
     public String toString() {
         StringBuilder sb = new StringBuilder();
@@ -122,4 +125,22 @@ public class UnsaturatedFunctionN implements Function {
         sb.append(")");
         return sb.toString();
     }
+
+    @Override
+    public int hashCode() {
+        return f.hashCode() + 31 * Arrays.hashCode(ps);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        UnsaturatedFunctionN other = (UnsaturatedFunctionN) obj;
+        return f.equals(other.f) && Arrays.equals(ps, other.ps);
+    }
+
 }