adds equals/hashCode to ResourceKey class

Wed, 13 May 2020 18:55:05 +0200

author
Mike Becker <universe@uap-core.de>
date
Wed, 13 May 2020 18:55:05 +0200
changeset 44
835dd169642a
parent 43
9abf0bf44c7b
child 45
cc7f082c5ef3

adds equals/hashCode to ResourceKey class

src/main/java/de/uapcore/lightpit/ResourceKey.java file | annotate | diff | comparison | revisions
--- a/src/main/java/de/uapcore/lightpit/ResourceKey.java	Wed May 13 18:45:28 2020 +0200
+++ b/src/main/java/de/uapcore/lightpit/ResourceKey.java	Wed May 13 18:55:05 2020 +0200
@@ -28,6 +28,8 @@
  */
 package de.uapcore.lightpit;
 
+import java.util.Objects;
+
 /**
  * Fully specifies a resource key by the bundle and the key name.
  */
@@ -35,10 +37,6 @@
     private String bundle;
     private String key;
 
-    public ResourceKey() {
-
-    }
-
     public ResourceKey(String bundle, String key) {
         this.bundle = bundle;
         this.key = key;
@@ -59,4 +57,18 @@
     public String getKey() {
         return key;
     }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+        ResourceKey that = (ResourceKey) o;
+        return bundle.equals(that.bundle) &&
+                key.equals(that.key);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(bundle, key);
+    }
 }

mercurial