diff --git a/src/main/java/graphql/schema/GraphQLEnumType.java b/src/main/java/graphql/schema/GraphQLEnumType.java index b7a87198fd..9a1cb8abdc 100644 --- a/src/main/java/graphql/schema/GraphQLEnumType.java +++ b/src/main/java/graphql/schema/GraphQLEnumType.java @@ -46,7 +46,7 @@ public List getValues() { public GraphQLEnumType(String name, String description, List values) { - assertNotNull(name, "name can't be null"); + assertNotNull(name, "name can't null"); this.name = name; this.description = description; buildMap(values); @@ -58,10 +58,6 @@ private void buildMap(List values) { } } - public String getName() { - return name; - } - public String getDescription() { return description; } @@ -75,6 +71,26 @@ public static Builder newEnum() { return new Builder(); } + public String getName() { + return name; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + GraphQLType that = (GraphQLType) o; + + return getName().equals(that.getName()); + + } + + @Override + public int hashCode() { + return name.hashCode(); + } + public static class Builder { private String name; diff --git a/src/main/java/graphql/schema/GraphQLInputObjectType.java b/src/main/java/graphql/schema/GraphQLInputObjectType.java index ffb906ca36..9f35b3342b 100644 --- a/src/main/java/graphql/schema/GraphQLInputObjectType.java +++ b/src/main/java/graphql/schema/GraphQLInputObjectType.java @@ -8,16 +8,14 @@ import static graphql.Assert.assertNotNull; -public class GraphQLInputObjectType implements GraphQLType, GraphQLInputType, GraphQLUnmodifiedType, GraphQLNullableType { +public class GraphQLInputObjectType implements GraphQLInputType, GraphQLUnmodifiedType, GraphQLNullableType { private final String name; private final String description; - - private final Map fieldMap = new LinkedHashMap<>(); public GraphQLInputObjectType(String name, String description, List fields) { - assertNotNull(name, "name can't be null"); + assertNotNull(name, "name can't null"); assertNotNull(fields, "fields can't be null"); this.name = name; this.description = description; @@ -30,10 +28,6 @@ private void buildMap(List fields) { } } - public String getName() { - return name; - } - public String getDescription() { return description; } @@ -50,6 +44,26 @@ public static Builder newInputObject() { return new Builder(); } + public String getName() { + return name; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + GraphQLType that = (GraphQLType) o; + + return getName().equals(that.getName()); + + } + + @Override + public int hashCode() { + return name.hashCode(); + } + public static class Builder { private String name; private String description; diff --git a/src/main/java/graphql/schema/GraphQLInterfaceType.java b/src/main/java/graphql/schema/GraphQLInterfaceType.java index 07c5bd276c..1119da467b 100644 --- a/src/main/java/graphql/schema/GraphQLInterfaceType.java +++ b/src/main/java/graphql/schema/GraphQLInterfaceType.java @@ -8,7 +8,7 @@ import static graphql.Assert.assertNotNull; -public class GraphQLInterfaceType implements GraphQLType, GraphQLOutputType, GraphQLFieldsContainer, GraphQLCompositeType, GraphQLUnmodifiedType, GraphQLNullableType { +public class GraphQLInterfaceType implements GraphQLOutputType, GraphQLFieldsContainer, GraphQLCompositeType, GraphQLUnmodifiedType, GraphQLNullableType { private final String name; private final String description; @@ -40,10 +40,6 @@ public List getFieldDefinitions() { return new ArrayList<>(fieldDefinitionsByName.values()); } - public String getName() { - return name; - } - public String getDescription() { return description; } @@ -55,7 +51,7 @@ public TypeResolver getTypeResolver() { @Override public String toString() { return "GraphQLInterfaceType{" + - "name='" + name + '\'' + + "name='" + getName() + '\'' + ", description='" + description + '\'' + ", fieldDefinitionsByName=" + fieldDefinitionsByName + ", typeResolver=" + typeResolver + @@ -66,6 +62,26 @@ public static Builder newInterface() { return new Builder(); } + public String getName() { + return name; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + GraphQLType that = (GraphQLType) o; + + return getName().equals(that.getName()); + + } + + @Override + public int hashCode() { + return name.hashCode(); + } + public static class Builder { private String name; diff --git a/src/main/java/graphql/schema/GraphQLList.java b/src/main/java/graphql/schema/GraphQLList.java index 3368b5f3dc..8e8b185c88 100644 --- a/src/main/java/graphql/schema/GraphQLList.java +++ b/src/main/java/graphql/schema/GraphQLList.java @@ -5,7 +5,7 @@ import static graphql.Assert.assertNotNull; -public class GraphQLList implements GraphQLType, GraphQLInputType, GraphQLOutputType, GraphQLModifiedType, GraphQLNullableType { +public class GraphQLList implements GraphQLInputType, GraphQLOutputType, GraphQLModifiedType, GraphQLNullableType { private GraphQLType wrappedType; @@ -39,7 +39,6 @@ public int hashCode() { return wrappedType != null ? wrappedType.hashCode() : 0; } - @Override public String getName() { return null; } diff --git a/src/main/java/graphql/schema/GraphQLNonNull.java b/src/main/java/graphql/schema/GraphQLNonNull.java index 141e24d29f..fc3fe7cf78 100644 --- a/src/main/java/graphql/schema/GraphQLNonNull.java +++ b/src/main/java/graphql/schema/GraphQLNonNull.java @@ -5,7 +5,7 @@ import static graphql.Assert.assertNotNull; -public class GraphQLNonNull implements GraphQLType, GraphQLInputType, GraphQLOutputType, GraphQLModifiedType { +public class GraphQLNonNull implements GraphQLInputType, GraphQLOutputType, GraphQLModifiedType { private GraphQLType wrappedType; diff --git a/src/main/java/graphql/schema/GraphQLObjectType.java b/src/main/java/graphql/schema/GraphQLObjectType.java index a7890af6cc..00a4ae16d0 100644 --- a/src/main/java/graphql/schema/GraphQLObjectType.java +++ b/src/main/java/graphql/schema/GraphQLObjectType.java @@ -8,7 +8,7 @@ import static graphql.Assert.assertNotNull; -public class GraphQLObjectType implements GraphQLType, GraphQLOutputType, GraphQLFieldsContainer, GraphQLCompositeType, GraphQLUnmodifiedType, GraphQLNullableType { +public class GraphQLObjectType implements GraphQLOutputType, GraphQLFieldsContainer, GraphQLCompositeType, GraphQLUnmodifiedType, GraphQLNullableType { private final String name; private final String description; @@ -50,16 +50,10 @@ public String getDescription() { return description; } - - public String getName() { - return name; - } - - @Override public String toString() { return "GraphQLObjectType{" + - "name='" + name + '\'' + + "name='" + getName() + '\'' + ", description='" + description + '\'' + ", fieldDefinitionsByName=" + fieldDefinitionsByName + ", interfaces=" + interfaces + @@ -70,6 +64,26 @@ public static Builder newObject() { return new Builder(); } + public String getName() { + return name; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + GraphQLType that = (GraphQLType) o; + + return getName().equals(that.getName()); + + } + + @Override + public int hashCode() { + return name.hashCode(); + } + public static class Builder { private String name; diff --git a/src/main/java/graphql/schema/GraphQLScalarType.java b/src/main/java/graphql/schema/GraphQLScalarType.java index 0e2ccead8d..5eacf59536 100644 --- a/src/main/java/graphql/schema/GraphQLScalarType.java +++ b/src/main/java/graphql/schema/GraphQLScalarType.java @@ -3,25 +3,20 @@ import static graphql.Assert.assertNotNull; -public class GraphQLScalarType implements GraphQLType, GraphQLInputType, GraphQLOutputType, GraphQLUnmodifiedType,GraphQLNullableType { +public class GraphQLScalarType implements GraphQLInputType, GraphQLOutputType, GraphQLUnmodifiedType,GraphQLNullableType { private final String name; private final String description; private final Coercing coercing; - public GraphQLScalarType(String name, String description, Coercing coercing) { - assertNotNull(name, "name can't be null"); + assertNotNull(name, "name can't null"); assertNotNull(coercing, "coercing can't be null"); this.name = name; this.description = description; this.coercing = coercing; } - public String getName() { - return name; - } - public String getDescription() { return description; @@ -35,9 +30,29 @@ public Coercing getCoercing() { @Override public String toString() { return "GraphQLScalarType{" + - "name='" + name + '\'' + + "name='" + getName() + '\'' + ", description='" + description + '\'' + ", coercing=" + coercing + '}'; } + + public String getName() { + return name; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + GraphQLType that = (GraphQLType) o; + + return getName().equals(that.getName()); + + } + + @Override + public int hashCode() { + return name.hashCode(); + } } diff --git a/src/main/java/graphql/schema/GraphQLTypeReference.java b/src/main/java/graphql/schema/GraphQLTypeReference.java index 103e326f26..0b2c01d1b6 100644 --- a/src/main/java/graphql/schema/GraphQLTypeReference.java +++ b/src/main/java/graphql/schema/GraphQLTypeReference.java @@ -7,16 +7,32 @@ * A special type to allow a object/interface types to reference itself. It's replaced with the real type * object when the schema is build. */ -public class GraphQLTypeReference implements GraphQLType, GraphQLOutputType { +public class GraphQLTypeReference implements GraphQLOutputType { private final String name; public GraphQLTypeReference(String name) { - assertNotNull(name, "name can't be null"); + assertNotNull(name, "name can't null"); this.name = name; } public String getName() { return name; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + GraphQLType that = (GraphQLType) o; + + return getName().equals(that.getName()); + + } + + @Override + public int hashCode() { + return name.hashCode(); + } } diff --git a/src/main/java/graphql/schema/GraphQLUnionType.java b/src/main/java/graphql/schema/GraphQLUnionType.java index 710041e600..ac67098e7b 100644 --- a/src/main/java/graphql/schema/GraphQLUnionType.java +++ b/src/main/java/graphql/schema/GraphQLUnionType.java @@ -6,7 +6,7 @@ import static graphql.Assert.assertNotNull; -public class GraphQLUnionType implements GraphQLType, GraphQLOutputType, GraphQLCompositeType, GraphQLUnmodifiedType, GraphQLNullableType { +public class GraphQLUnionType implements GraphQLOutputType, GraphQLCompositeType, GraphQLUnmodifiedType, GraphQLNullableType { private final String name; private final String description; @@ -15,7 +15,7 @@ public class GraphQLUnionType implements GraphQLType, GraphQLOutputType, GraphQL public GraphQLUnionType(String name, String description, List types, TypeResolver typeResolver) { - assertNotNull(name, "name can't be null"); + assertNotNull(name, "name can't null"); assertNotNull(types, "types can't be null"); assertNotNull(typeResolver, "typeResolver can't be null"); this.name = name; @@ -33,11 +33,6 @@ public TypeResolver getTypeResolver() { return typeResolver; } - @Override - public String getName() { - return name; - } - public String getDescription() { return description; } @@ -46,6 +41,26 @@ public static Builder newUnionType() { return new Builder(); } + public String getName() { + return name; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + GraphQLType that = (GraphQLType) o; + + return getName().equals(that.getName()); + + } + + @Override + public int hashCode() { + return name.hashCode(); + } + public static class Builder { private String name; private String description;