From 86dbed4bf923733e35ab67184d4a2ef883e0b270 Mon Sep 17 00:00:00 2001 From: Speiger Date: Sun, 19 Sep 2021 22:36:23 +0200 Subject: [PATCH] Added Essential Methods --- .../misc/pairs/impl/ImmutablePair.template | 19 +++++++++++++++++++ .../misc/pairs/impl/MutablePair.template | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/src/builder/resources/speiger/assets/collections/templates/misc/pairs/impl/ImmutablePair.template b/src/builder/resources/speiger/assets/collections/templates/misc/pairs/impl/ImmutablePair.template index 0f4a4fc..fb78982 100644 --- a/src/builder/resources/speiger/assets/collections/templates/misc/pairs/impl/ImmutablePair.template +++ b/src/builder/resources/speiger/assets/collections/templates/misc/pairs/impl/ImmutablePair.template @@ -58,4 +58,23 @@ public class IMMUTABLE_PAIR KEY_VALUE_GENERIC_TYPE implements PAIR KEY_VALUE_GEN public PAIR KEY_VALUE_GENERIC_TYPE shallowCopy() { return this; } + + @Override + public boolean equals(Object obj) { + if(obj instanceof PAIR) { + PAIR KEY_VALUE_GENERIC_TYPE entry = (PAIR KEY_VALUE_GENERIC_TYPE)obj; + return KEY_EQUALS(key, entry.ENTRY_KEY()) && VALUE_EQUALS(value, entry.ENTRY_VALUE()); + } + return false; + } + + @Override + public int hashCode() { + return KEY_TO_HASH(key) ^ VALUE_TO_HASH(value); + } + + @Override + public String toString() { + return KEY_TO_STRING(key) + "->" + VALUE_TO_STRING(value); + } } \ No newline at end of file diff --git a/src/builder/resources/speiger/assets/collections/templates/misc/pairs/impl/MutablePair.template b/src/builder/resources/speiger/assets/collections/templates/misc/pairs/impl/MutablePair.template index 2c48837..c8bbce2 100644 --- a/src/builder/resources/speiger/assets/collections/templates/misc/pairs/impl/MutablePair.template +++ b/src/builder/resources/speiger/assets/collections/templates/misc/pairs/impl/MutablePair.template @@ -60,4 +60,23 @@ public class MUTABLE_PAIR KEY_VALUE_GENERIC_TYPE implements PAIR KEY_VALUE_GENER public PAIR KEY_VALUE_GENERIC_TYPE shallowCopy() { return PAIR.mutable(key, value); } + + @Override + public boolean equals(Object obj) { + if(obj instanceof PAIR) { + PAIR KEY_VALUE_GENERIC_TYPE entry = (PAIR KEY_VALUE_GENERIC_TYPE)obj; + return KEY_EQUALS(key, entry.ENTRY_KEY()) && VALUE_EQUALS(value, entry.ENTRY_VALUE()); + } + return false; + } + + @Override + public int hashCode() { + return KEY_TO_HASH(key) ^ VALUE_TO_HASH(value); + } + + @Override + public String toString() { + return KEY_TO_STRING(key) + "->" + VALUE_TO_STRING(value); + } } \ No newline at end of file