Wed, 13 May 2020 18:55:05 +0200
adds equals/hashCode to ResourceKey class
src/main/java/de/uapcore/lightpit/ResourceKey.java | file | annotate | diff | comparison | revisions |
1.1 --- a/src/main/java/de/uapcore/lightpit/ResourceKey.java Wed May 13 18:45:28 2020 +0200 1.2 +++ b/src/main/java/de/uapcore/lightpit/ResourceKey.java Wed May 13 18:55:05 2020 +0200 1.3 @@ -28,6 +28,8 @@ 1.4 */ 1.5 package de.uapcore.lightpit; 1.6 1.7 +import java.util.Objects; 1.8 + 1.9 /** 1.10 * Fully specifies a resource key by the bundle and the key name. 1.11 */ 1.12 @@ -35,10 +37,6 @@ 1.13 private String bundle; 1.14 private String key; 1.15 1.16 - public ResourceKey() { 1.17 - 1.18 - } 1.19 - 1.20 public ResourceKey(String bundle, String key) { 1.21 this.bundle = bundle; 1.22 this.key = key; 1.23 @@ -59,4 +57,18 @@ 1.24 public String getKey() { 1.25 return key; 1.26 } 1.27 + 1.28 + @Override 1.29 + public boolean equals(Object o) { 1.30 + if (this == o) return true; 1.31 + if (o == null || getClass() != o.getClass()) return false; 1.32 + ResourceKey that = (ResourceKey) o; 1.33 + return bundle.equals(that.bundle) && 1.34 + key.equals(that.key); 1.35 + } 1.36 + 1.37 + @Override 1.38 + public int hashCode() { 1.39 + return Objects.hash(bundle, key); 1.40 + } 1.41 }