Class DataFetchingFieldSelectionSetImpl
- java.lang.Object
-
- graphql.schema.DataFetchingFieldSelectionSetImpl
-
- All Implemented Interfaces:
DataFetchingFieldSelectionSet
public class DataFetchingFieldSelectionSetImpl extends java.lang.Object implements DataFetchingFieldSelectionSet
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classDataFetchingFieldSelectionSetImpl.SelectedFieldImpl
-
Field Summary
Fields Modifier and Type Field Description private LockKit.ComputedOncecomputedOnceprivate java.util.Set<java.lang.String>flattenedFieldsForGlobSearchingprivate java.util.List<SelectedField>immediateFieldsprivate static DataFetchingFieldSelectionSetNOOPprivate java.util.Map<java.lang.String,java.util.List<SelectedField>>normalisedSelectionSetFieldsprivate java.util.function.Supplier<ExecutableNormalizedField>normalizedFieldSupplierprivate GraphQLSchemaschemaprivate static java.lang.StringSEPprivate static booleanUNIXY
-
Constructor Summary
Constructors Modifier Constructor Description privateDataFetchingFieldSelectionSetImpl(java.util.function.Supplier<ExecutableNormalizedField> normalizedFieldSupplier, GraphQLSchema schema)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcomputeValuesLazily()booleancontains(java.lang.String fieldGlobPattern)This will return true if the field selection set matches a specified "glob" pattern matching ie the glob pattern matching supported byFileSystem.getPathMatcher(java.lang.String).booleancontainsAllOf(java.lang.String fieldGlobPattern, java.lang.String... fieldGlobPatterns)This will return true if the field selection set matches all of the specified "glob" pattern matches ie the glob pattern matching supported byFileSystem.getPathMatcher(java.lang.String).booleancontainsAnyOf(java.lang.String fieldGlobPattern, java.lang.String... fieldGlobPatterns)This will return true if the field selection set matches any of the specified "glob" pattern matches ie the glob pattern matching supported byFileSystem.getPathMatcher(java.lang.String).java.util.List<SelectedField>getFields()This will return all selected fields.java.util.List<SelectedField>getFields(java.lang.String fieldGlobPattern, java.lang.String... fieldGlobPatterns)This will return a list of selected fields that match a specified "glob" pattern matching ie the glob pattern matching supported byFileSystem.getPathMatcher(java.lang.String).java.util.Map<java.lang.String,java.util.List<SelectedField>>getFieldsGroupedByResultKey()The result key of a selected field represents what the graphql return value will be.java.util.Map<java.lang.String,java.util.List<SelectedField>>getFieldsGroupedByResultKey(java.lang.String fieldGlobPattern, java.lang.String... fieldGlobPatterns)The result key of a selected field represents what the graphql return value will be.java.util.List<SelectedField>getImmediateFields()This will return all selected fields that are immediate child fields of the field being fetched.private static java.nio.file.PathMatcherglobMatcher(java.lang.String fieldGlobPattern)private static java.lang.StringmkFieldGlobName(java.lang.String fieldPrefix, java.lang.String fieldName)private java.util.List<java.lang.String>mkIterable(java.lang.String fieldGlobPattern, java.lang.String[] fieldGlobPatterns)private static java.lang.StringmkTypeQualifiedName(ExecutableNormalizedField executableNormalizedField)static DataFetchingFieldSelectionSetnewCollector(GraphQLSchema schema, GraphQLOutputType fieldType, java.util.function.Supplier<ExecutableNormalizedField> normalizedFieldSupplier)private java.lang.StringosAppropriate(java.lang.String flattenedField)private java.lang.StringremoveLeadingSlash(java.lang.String fieldGlobPattern)private java.util.List<SelectedField>toSetSemanticsList(java.util.stream.Stream<SelectedField> stream)java.lang.StringtoString()private voidtraverseSubSelectedFields(ExecutableNormalizedField currentNormalisedField, com.google.common.collect.ImmutableList.Builder<SelectedField> immediateFieldsBuilder, java.lang.String qualifiedFieldPrefix, java.lang.String simpleFieldPrefix, boolean firstLevel)
-
-
-
Field Detail
-
SEP
private static final java.lang.String SEP
- See Also:
- Constant Field Values
-
UNIXY
private static final boolean UNIXY
-
NOOP
private static final DataFetchingFieldSelectionSet NOOP
-
normalizedFieldSupplier
private final java.util.function.Supplier<ExecutableNormalizedField> normalizedFieldSupplier
-
computedOnce
private LockKit.ComputedOnce computedOnce
-
normalisedSelectionSetFields
private java.util.Map<java.lang.String,java.util.List<SelectedField>> normalisedSelectionSetFields
-
immediateFields
private java.util.List<SelectedField> immediateFields
-
flattenedFieldsForGlobSearching
private java.util.Set<java.lang.String> flattenedFieldsForGlobSearching
-
schema
private final GraphQLSchema schema
-
-
Constructor Detail
-
DataFetchingFieldSelectionSetImpl
private DataFetchingFieldSelectionSetImpl(java.util.function.Supplier<ExecutableNormalizedField> normalizedFieldSupplier, GraphQLSchema schema)
-
-
Method Detail
-
newCollector
public static DataFetchingFieldSelectionSet newCollector(GraphQLSchema schema, GraphQLOutputType fieldType, java.util.function.Supplier<ExecutableNormalizedField> normalizedFieldSupplier)
-
contains
public boolean contains(java.lang.String fieldGlobPattern)
Description copied from interface:DataFetchingFieldSelectionSetThis will return true if the field selection set matches a specified "glob" pattern matching ie the glob pattern matching supported byFileSystem.getPathMatcher(java.lang.String).This will allow you to use '*', '**' and '?' as special matching characters such that "invoice/customer*" would match an invoice field with child fields that start with 'customer'.
- Specified by:
containsin interfaceDataFetchingFieldSelectionSet- Parameters:
fieldGlobPattern- the glob pattern to match fields against- Returns:
- true if the selection set contains these fields
- See Also:
FileSystem.getPathMatcher(String)
-
osAppropriate
private java.lang.String osAppropriate(java.lang.String flattenedField)
-
containsAnyOf
public boolean containsAnyOf(java.lang.String fieldGlobPattern, java.lang.String... fieldGlobPatterns)Description copied from interface:DataFetchingFieldSelectionSetThis will return true if the field selection set matches any of the specified "glob" pattern matches ie the glob pattern matching supported byFileSystem.getPathMatcher(java.lang.String).This will allow you to use '*', '**' and '?' as special matching characters such that "invoice/customer*" would match an invoice field with child fields that start with 'customer'.
- Specified by:
containsAnyOfin interfaceDataFetchingFieldSelectionSet- Parameters:
fieldGlobPattern- the glob pattern to match fields againstfieldGlobPatterns- optionally more glob pattern to match fields against- Returns:
- true if the selection set contains any of these these fields
- See Also:
FileSystem.getPathMatcher(String)
-
containsAllOf
public boolean containsAllOf(java.lang.String fieldGlobPattern, java.lang.String... fieldGlobPatterns)Description copied from interface:DataFetchingFieldSelectionSetThis will return true if the field selection set matches all of the specified "glob" pattern matches ie the glob pattern matching supported byFileSystem.getPathMatcher(java.lang.String).This will allow you to use '*', '**' and '?' as special matching characters such that "invoice/customer*" would match an invoice field with child fields that start with 'customer'.
- Specified by:
containsAllOfin interfaceDataFetchingFieldSelectionSet- Parameters:
fieldGlobPattern- the glob pattern to match fields againstfieldGlobPatterns- optionally more glob pattern to match fields against- Returns:
- true if the selection set contains all of these these fields
- See Also:
FileSystem.getPathMatcher(String)
-
getFields
public java.util.List<SelectedField> getFields(java.lang.String fieldGlobPattern, java.lang.String... fieldGlobPatterns)
Description copied from interface:DataFetchingFieldSelectionSetThis will return a list of selected fields that match a specified "glob" pattern matching ie the glob pattern matching supported byFileSystem.getPathMatcher(java.lang.String).This will allow you to use '*', '**' and '?' as special matching characters such that "invoice/customer*" would match an invoice field with child fields that start with 'customer'.
The fields are guaranteed to be in pre-order as they appear in the query.
A selected field may have an alias - and hence is a unique field in the returned list. It may have the same field names as others in the list but when you also consider the alias then it is indeed unique because it would be another entry in the graphql result.
- Specified by:
getFieldsin interfaceDataFetchingFieldSelectionSet- Parameters:
fieldGlobPattern- the glob pattern to match fields againstfieldGlobPatterns- optionally more glob pattern to match fields against- Returns:
- a list of selected fields or empty list if none match
-
getFields
public java.util.List<SelectedField> getFields()
Description copied from interface:DataFetchingFieldSelectionSetThis will return all selected fields.The fields are guaranteed to be in pre-order as they appear in the query.
A selected field may have an alias - and hence is a unique field in the returned list. It may have the same field names as others in the list but when you also consider the alias then it is indeed unique because it would be another entry in the graphql result.
- Specified by:
getFieldsin interfaceDataFetchingFieldSelectionSet- Returns:
- a list of all selected fields or empty list if none match
-
toSetSemanticsList
private java.util.List<SelectedField> toSetSemanticsList(java.util.stream.Stream<SelectedField> stream)
-
getImmediateFields
public java.util.List<SelectedField> getImmediateFields()
Description copied from interface:DataFetchingFieldSelectionSetThis will return all selected fields that are immediate child fields of the field being fetched.The fields are guaranteed to be in pre-order as they appear in the query.
A selected field may have an alias - and hence is a unique field in the returned list. It may have the same field names as others in the list but when you also consider the alias then it is indeed unique because it would be another entry in the graphql result.
- Specified by:
getImmediateFieldsin interfaceDataFetchingFieldSelectionSet- Returns:
- a list of all selected immediate child fields or empty list if none match
-
getFieldsGroupedByResultKey
public java.util.Map<java.lang.String,java.util.List<SelectedField>> getFieldsGroupedByResultKey()
Description copied from interface:DataFetchingFieldSelectionSetThe result key of a selected field represents what the graphql return value will be. The sameGraphQLFieldDefinitionmay lead to a field being asked for multiple times (with differing arguments) if field aliases are used. This method helps you get all possible field invocations grouped by their result key. The arguments are guaranteed to be the same if the result key is the same, otherwise the query would not have validated correctly.- Specified by:
getFieldsGroupedByResultKeyin interfaceDataFetchingFieldSelectionSet- Returns:
- a map of selected fields grouped by result key or an empty map if none match
-
getFieldsGroupedByResultKey
public java.util.Map<java.lang.String,java.util.List<SelectedField>> getFieldsGroupedByResultKey(java.lang.String fieldGlobPattern, java.lang.String... fieldGlobPatterns)
Description copied from interface:DataFetchingFieldSelectionSetThe result key of a selected field represents what the graphql return value will be. The sameGraphQLFieldDefinitionmay lead to a field being asked for multiple times (with differing arguments) if field aliases are used. This method helps you get all possible field invocations grouped by their result key. The arguments are guaranteed to be the same if the result key is the same, otherwise the query would not have validated correctly.- Specified by:
getFieldsGroupedByResultKeyin interfaceDataFetchingFieldSelectionSet- Parameters:
fieldGlobPattern- the glob pattern to match fields againstfieldGlobPatterns- optionally more glob pattern to match fields against- Returns:
- a map of selected fields grouped by result key or an empty map if none match
-
computeValuesLazily
private void computeValuesLazily()
-
traverseSubSelectedFields
private void traverseSubSelectedFields(ExecutableNormalizedField currentNormalisedField, com.google.common.collect.ImmutableList.Builder<SelectedField> immediateFieldsBuilder, java.lang.String qualifiedFieldPrefix, java.lang.String simpleFieldPrefix, boolean firstLevel)
-
removeLeadingSlash
private java.lang.String removeLeadingSlash(java.lang.String fieldGlobPattern)
-
mkTypeQualifiedName
private static java.lang.String mkTypeQualifiedName(ExecutableNormalizedField executableNormalizedField)
-
mkFieldGlobName
private static java.lang.String mkFieldGlobName(java.lang.String fieldPrefix, java.lang.String fieldName)
-
globMatcher
private static java.nio.file.PathMatcher globMatcher(java.lang.String fieldGlobPattern)
-
mkIterable
private java.util.List<java.lang.String> mkIterable(java.lang.String fieldGlobPattern, java.lang.String[] fieldGlobPatterns)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-