Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ public boolean equals(final Object obj) {
return this.optional == other.optional
&& this.name.equals(other.name)
&& this.path.equals(other.path)
&& this.fieldType.reference().equals(other.fieldType.reference());
&& this.fieldType.reference().equals(other.fieldType.reference())
&& this.fieldType.codec().equals(other.fieldType.codec());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

package de.splatgames.aether.datafixers.schematools.introspection;

import de.splatgames.aether.datafixers.api.codec.Codecs;
import de.splatgames.aether.datafixers.api.type.Type;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
Expand Down Expand Up @@ -183,6 +184,26 @@ void equalsReturnsTrueForSameInstance() {

assertThat(field).isEqualTo(field);
}

@Test
@DisplayName("equals returns false for different Type.codec")
void equalsReturnsFalseForDifferentTypeCodec() {
var falseCodecStringType = Type.primitive("string", Codecs.INT);
final FieldInfo field1 = FieldInfo.create("health", false, falseCodecStringType, "player.health");
final FieldInfo field2 = FieldInfo.create("health", false, Type.STRING, "player.health");

assertThat(field1).isNotEqualTo(field2);
}

@Test
@DisplayName("equals returns false for different Type.ref and Type.describe")
void equalsReturnsFalseForDifferentTypeDescribe() {
var falseNameStringType = Type.primitive("int", Codecs.STRING);
final FieldInfo field1 = FieldInfo.create("health", false, falseNameStringType, "player.health");
final FieldInfo field2 = FieldInfo.create("health", false, Type.STRING, "player.health");

assertThat(field1).isNotEqualTo(field2);
}
}

@Nested
Expand Down
Loading