From eb9d913cb687f5b919571f85eea9503843a2e110 Mon Sep 17 00:00:00 2001 From: KennyTV Date: Wed, 3 Jun 2020 11:19:54 +0200 Subject: [PATCH] Add toString, equals, and hashCode to Metadata --- .../api/minecraft/metadata/Metadata.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/common/src/main/java/us/myles/ViaVersion/api/minecraft/metadata/Metadata.java b/common/src/main/java/us/myles/ViaVersion/api/minecraft/metadata/Metadata.java index 244ea8423..f9c67ce35 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/minecraft/metadata/Metadata.java +++ b/common/src/main/java/us/myles/ViaVersion/api/minecraft/metadata/Metadata.java @@ -1,5 +1,7 @@ package us.myles.ViaVersion.api.minecraft.metadata; +import java.util.Objects; + public class Metadata { private int id; private MetaType metaType; @@ -38,4 +40,32 @@ public class Metadata { public void setValue(Object value) { this.value = value; } + + @Override + public boolean equals(final Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Metadata metadata = (Metadata) o; + if (id != metadata.id) return false; + if (!Objects.equals(metaType, metadata.metaType)) return false; + return Objects.equals(value, metadata.value); + } + + @Override + public int hashCode() { + int result = id; + result = 31 * result + (metaType != null ? metaType.hashCode() : 0); + result = 31 * result + (value != null ? value.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "Metadata{" + + "id=" + id + + ", metaType=" + metaType + + ", value=" + value + + '}'; + } }