Define FileGeneratorArg equality 12/104812/2
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 9 Mar 2023 18:07:42 +0000 (19:07 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 9 Mar 2023 18:54:25 +0000 (19:54 +0100)
We are relying on equality to detect changes. Make sure that equality is
not identity.

JIRA: YANGTOOLS-745
Change-Id: I13b62b12ed9af7e80c4c3e883730b7e5e39e0240
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
plugin/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/FileGeneratorArg.java

index ae056b4bbf5ded9f5d8cf6f4913109d39fdc0abc..0ca1dbea55150dfa7c4dee880a0da8d6241d47f8 100644 (file)
@@ -52,6 +52,17 @@ public final class FileGeneratorArg implements Identifiable<String>, WritableObj
         return Collections.unmodifiableMap(configuration);
     }
 
+    @Override
+    public int hashCode() {
+        return getIdentifier().hashCode() + configuration.hashCode();
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+        return this == obj || obj instanceof FileGeneratorArg other && getIdentifier().equals(other.getIdentifier())
+            && configuration.equals(other.getConfiguration());
+    }
+
     @Override
     public String toString() {
         return MoreObjects.toStringHelper(this).add("id", identifier).add("configuration", configuration).toString();