Package graphql.schema
Class DefaultGraphqlTypeComparatorRegistry
- java.lang.Object
-
- graphql.schema.DefaultGraphqlTypeComparatorRegistry
-
- All Implemented Interfaces:
GraphqlTypeComparatorRegistry
@PublicApi public class DefaultGraphqlTypeComparatorRegistry extends java.lang.Object implements GraphqlTypeComparatorRegistry
Associates aComparatorwith aGraphqlTypeComparatorEnvironmentto control the scope in which theComparatorcan be applied.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDefaultGraphqlTypeComparatorRegistry.Builder
-
Field Summary
Fields Modifier and Type Field Description static java.util.Comparator<GraphQLSchemaElement>DEFAULT_COMPARATORprivate java.util.Map<GraphqlTypeComparatorEnvironment,java.util.Comparator<?>>registryprivate static com.google.common.collect.ImmutableMap<java.lang.Class<? extends GraphQLSchemaElement>,java.lang.Integer>SENSIBLE_ORDER-
Fields inherited from interface graphql.schema.GraphqlTypeComparatorRegistry
AS_IS_REGISTRY, BY_NAME_REGISTRY
-
-
Constructor Summary
Constructors Modifier Constructor Description privateDefaultGraphqlTypeComparatorRegistry()privateDefaultGraphqlTypeComparatorRegistry(java.util.Map<GraphqlTypeComparatorEnvironment,java.util.Comparator<?>> registry)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static intcompareByName(GraphQLSchemaElement o1, GraphQLSchemaElement o2)static GraphqlTypeComparatorRegistrydefaultComparators()<T extends GraphQLSchemaElement>
java.util.Comparator<? super T>getComparator(GraphqlTypeComparatorEnvironment environment)Search for the most to least specific registeredComparatorotherwise a default is returned.static DefaultGraphqlTypeComparatorRegistry.BuildernewComparators()static java.util.Comparator<GraphQLSchemaElement>sensibleGroupedOrder()This orders the schema into a sensible grouped orderprivate static GraphQLSchemaElementunwrapElement(GraphQLSchemaElement element)
-
-
-
Field Detail
-
SENSIBLE_ORDER
private static final com.google.common.collect.ImmutableMap<java.lang.Class<? extends GraphQLSchemaElement>,java.lang.Integer> SENSIBLE_ORDER
-
DEFAULT_COMPARATOR
public static final java.util.Comparator<GraphQLSchemaElement> DEFAULT_COMPARATOR
-
registry
private java.util.Map<GraphqlTypeComparatorEnvironment,java.util.Comparator<?>> registry
-
-
Constructor Detail
-
DefaultGraphqlTypeComparatorRegistry
private DefaultGraphqlTypeComparatorRegistry()
-
DefaultGraphqlTypeComparatorRegistry
private DefaultGraphqlTypeComparatorRegistry(java.util.Map<GraphqlTypeComparatorEnvironment,java.util.Comparator<?>> registry)
-
-
Method Detail
-
sensibleGroupedOrder
public static java.util.Comparator<GraphQLSchemaElement> sensibleGroupedOrder()
This orders the schema into a sensible grouped order- Returns:
- a comparator that allows for sensible grouped order
-
unwrapElement
private static GraphQLSchemaElement unwrapElement(GraphQLSchemaElement element)
-
compareByName
private static int compareByName(GraphQLSchemaElement o1, GraphQLSchemaElement o2)
-
getComparator
public <T extends GraphQLSchemaElement> java.util.Comparator<? super T> getComparator(GraphqlTypeComparatorEnvironment environment)
Search for the most to least specific registeredComparatorotherwise a default is returned.- Specified by:
getComparatorin interfaceGraphqlTypeComparatorRegistry- Type Parameters:
T- the type of the comparator- Parameters:
environment- Defines the scope to control where theComparatorcan be applied.- Returns:
- The registered
Comparatorornullif not found.
-
defaultComparators
public static GraphqlTypeComparatorRegistry defaultComparators()
- Returns:
- A registry where all
GraphQLTypes receive a defaultComparatorby comparingGraphQLType::getName.
-
newComparators
public static DefaultGraphqlTypeComparatorRegistry.Builder newComparators()
-
-