Class GQLOperation
- java.lang.Object
-
- net.morimekta.providence.graphql.gql.GQLOperation
-
- All Implemented Interfaces:
GQLSelection
@Immutable public class GQLOperation extends java.lang.Object implements GQLSelection
Representing a single GQL operation, which is either a query or a mutation.
-
-
Constructor Summary
Constructors Constructor Description GQLOperation(net.morimekta.providence.descriptor.PService service, boolean mutation, java.lang.String name, java.util.List<GQLSelection> selectionSet)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetName()java.util.List<GQLSelection>getSelection(net.morimekta.providence.descriptor.PField field)Get all selection entries related to the given field.java.util.List<GQLSelection>getSelectionSet()net.morimekta.providence.descriptor.PServicegetService()inthashCode()booleanhasMethodCall(net.morimekta.providence.descriptor.PServiceMethod method)booleanhasSelection(net.morimekta.providence.descriptor.PField... fields)Check if any of the given fields are in the selection.booleanhasSelectionPath(net.morimekta.providence.descriptor.PField... fields)Browse downward fields so that we figure out if the selection (based on a field path based on the returning structure) if selected.booleanisMutation()java.lang.StringtoString()
-
-
-
Constructor Detail
-
GQLOperation
public GQLOperation(@Nonnull net.morimekta.providence.descriptor.PService service, boolean mutation, @Nullable java.lang.String name, @Nonnull java.util.List<GQLSelection> selectionSet)
-
-
Method Detail
-
isMutation
public boolean isMutation()
-
hasMethodCall
public boolean hasMethodCall(net.morimekta.providence.descriptor.PServiceMethod method)
-
hasSelection
public boolean hasSelection(@Nonnull net.morimekta.providence.descriptor.PField... fields)Description copied from interface:GQLSelectionCheck if any of the given fields are in the selection. It will only look the the current struct, but check in all contained and referenced fragments. If only one field is given, this method will return true if and only ifGQLSelection.getSelection(PField)returns a non-empty list.- Specified by:
hasSelectionin interfaceGQLSelection- Parameters:
fields- Fields to check selection for.- Returns:
- True only if the current selection set contains ony of the provided fields.
-
hasSelectionPath
public boolean hasSelectionPath(@Nonnull net.morimekta.providence.descriptor.PField... fields)Description copied from interface:GQLSelectionBrowse downward fields so that we figure out if the selection (based on a field path based on the returning structure) if selected. E.g.hasSelectionPath("a", "b")will first look for the selection of "a", then for selection of "b" within a. Will treat a non-selection as the selection being there.- Specified by:
hasSelectionPathin interfaceGQLSelection- Parameters:
fields- Fields as in a field path to check from the current selection.- Returns:
- If the selection path is selected or on per default.
-
getSelection
@Nonnull public java.util.List<GQLSelection> getSelection(@Nonnull net.morimekta.providence.descriptor.PField field)
Description copied from interface:GQLSelectionGet all selection entries related to the given field. It will only look at the current struct, but look at all levels of fragments. The result will contain one entry for each time the field is requested, so if multiple fragments requests the same field, this will return one entry per reference. If it contains more than one, the query should only have one such without alias, and all others should use unique aliases, but is not required. This method will return a non-empty list if and only ifGQLSelection.hasSelection(PField[])called with the same field returns true.- Specified by:
getSelectionin interfaceGQLSelection- Parameters:
field- The field to get selection for.- Returns:
- List of selection related to the field.
-
getName
@Nullable public java.lang.String getName()
-
getService
@Nonnull public net.morimekta.providence.descriptor.PService getService()
-
getSelectionSet
@Nonnull public java.util.List<GQLSelection> getSelectionSet()
- Specified by:
getSelectionSetin interfaceGQLSelection- Returns:
- List if selections contained within this selection.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-