瀏覽代碼

proper equal and hashcode for ShaderNodesVariables.

Rémy Bouquet 9 年之前
父節點
當前提交
334cad4657
共有 1 個文件被更改,包括 12 次插入1 次删除
  1. 12 1
      jme3-core/src/main/java/com/jme3/shader/ShaderNodeVariable.java

+ 12 - 1
jme3-core/src/main/java/com/jme3/shader/ShaderNodeVariable.java

@@ -150,7 +150,12 @@ public class ShaderNodeVariable implements Savable, Cloneable {
 
     @Override
     public int hashCode() {
-        int hash = 5;
+        int hash = 7;
+        hash = 29 * hash + (name != null?name.hashCode():0);
+        hash = 29 * hash + (type != null?type.hashCode():0);
+        hash = 29 * hash + (nameSpace != null?nameSpace.hashCode():0);
+        hash = 29 * hash + (condition != null?condition.hashCode():0);
+        hash = 29 * hash + (multiplicity != null?multiplicity.hashCode():0);
         return hash;
     }
 
@@ -172,6 +177,12 @@ public class ShaderNodeVariable implements Savable, Cloneable {
         if ((this.nameSpace == null) ? (other.nameSpace != null) : !this.nameSpace.equals(other.nameSpace)) {
             return false;
         }
+        if ((this.condition == null) ? (other.condition != null) : !this.condition.equals(other.condition)) {
+            return false;
+        }
+        if ((this.multiplicity == null) ? (other.multiplicity != null) : !this.multiplicity.equals(other.multiplicity)) {
+            return false;
+        }
         return true;
     }