diff --git a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/GenericTypesTest.java b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/GenericTypesTest.java index 822567528..554c4ab08 100644 --- a/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/GenericTypesTest.java +++ b/equalsverifier-core/src/test/java/nl/jqno/equalsverifier/integration/extended_contract/GenericTypesTest.java @@ -15,6 +15,11 @@ public class GenericTypesTest { + @Test + public void succeed_whenClassHasGenericFieldThatsSpecifiedToABuiltinGeneric() { + EqualsVerifier.forClass(GenericContainerWithBuiltin.class).verify(); + } + @Test public void succeed_whenEqualsLooksAtJava8TypesGenericContent() { EqualsVerifier.forClass(JavaGenericTypeContainer.class).verify(); @@ -121,6 +126,29 @@ public void succeed_whenClassHasASelfReferenceGenericParameter_givenPrefabValues .verify(); } + static final class GenericContainerWithBuiltin { + + private final Generic> b; + + public GenericContainerWithBuiltin(Generic> b) { + this.b = b; + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof GenericContainerWithBuiltin)) { + return false; + } + GenericContainerWithBuiltin other = (GenericContainerWithBuiltin) obj; + return Objects.equals(b, other.b); + } + + @Override + public int hashCode() { + return Objects.hash(b); + } + } + static final class JavaGenericTypeContainer { private final Optional optional; @@ -172,6 +200,30 @@ public String toString() { } } + static final class Generic { + + private final T t; + + public Generic(T t) { + this.t = t; + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof Generic)) { + return false; + } + @SuppressWarnings("unchecked") + Generic other = (Generic) obj; + return Objects.equals(t, other.t); + } + + @Override + public int hashCode() { + return Objects.hash(t); + } + } + static final class ListContainer { private final List list;