3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-28 09:00:09 +01:00

Add toString, equals, and hashCode to Metadata

Dieser Commit ist enthalten in:
KennyTV 2020-06-03 11:19:54 +02:00
Ursprung a60340f330
Commit eb9d913cb6
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B

Datei anzeigen

@ -1,5 +1,7 @@
package us.myles.ViaVersion.api.minecraft.metadata; package us.myles.ViaVersion.api.minecraft.metadata;
import java.util.Objects;
public class Metadata { public class Metadata {
private int id; private int id;
private MetaType metaType; private MetaType metaType;
@ -38,4 +40,32 @@ public class Metadata {
public void setValue(Object value) { public void setValue(Object value) {
this.value = 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 +
'}';
}
} }