Package graphql.execution
Class ResultPath
- java.lang.Object
-
- graphql.execution.ResultPath
-
@PublicApi public class ResultPath extends java.lang.Object
As a graphql query is executed, each field forms a hierarchical path from parent field to child field and this class represents that path as a series of segments.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ResultPath
append(ResultPath path)
Appends the provided path to the current oneResultPath
dropSegment()
Drops the last segment off the pathboolean
equals(java.lang.Object o)
static ResultPath
fromList(java.util.List<?> objects)
This will create an execution path from the list of objectsjava.util.List<java.lang.String>
getKeysOnly()
int
getLevel()
ResultPath
getParent()
ResultPath
getPathWithoutListEnd()
int
getSegmentIndex()
java.lang.String
getSegmentName()
java.lang.Object
getSegmentValue()
int
hashCode()
boolean
isListSegment()
boolean
isNamedSegment()
boolean
isRootPath()
static ResultPath
parse(java.lang.String pathString)
Parses an execution path from the provided path string in the format /segment1/segment2[index]/segmentNResultPath
replaceSegment(int segment)
Replaces the last segment on the path eg ResultPath.parse("/a/b[1]").replaceSegment(9) equals "/a/b[9]"ResultPath
replaceSegment(java.lang.String segment)
Replaces the last segment on the path eg ResultPath.parse("/a/b[1]").replaceSegment("x") equals "/a/b/x"static ResultPath
rootPath()
All paths start from hereResultPath
segment(int segment)
Takes the current path and adds a new segment to it, returning a new pathResultPath
segment(java.lang.String segment)
Takes the current path and adds a new segment to it, returning a new pathjava.lang.String
segmentToString()
ResultPath
sibling(int siblingField)
ResultPath
sibling(java.lang.String siblingField)
java.util.List<java.lang.Object>
toList()
java.lang.String
toString()
-
-
-
Method Detail
-
rootPath
public static ResultPath rootPath()
All paths start from here- Returns:
- the root path
-
getLevel
public int getLevel()
-
getPathWithoutListEnd
public ResultPath getPathWithoutListEnd()
-
isListSegment
public boolean isListSegment()
- Returns:
- true if the end of the path has a list style segment eg 'a/b[2]'
-
isNamedSegment
public boolean isNamedSegment()
- Returns:
- true if the end of the path has a named style segment eg 'a/b[2]/c'
-
getSegmentName
public java.lang.String getSegmentName()
-
getSegmentIndex
public int getSegmentIndex()
-
getSegmentValue
public java.lang.Object getSegmentValue()
-
getParent
public ResultPath getParent()
-
parse
public static ResultPath parse(java.lang.String pathString)
Parses an execution path from the provided path string in the format /segment1/segment2[index]/segmentN- Parameters:
pathString
- the path string- Returns:
- a parsed execution path
-
fromList
public static ResultPath fromList(java.util.List<?> objects)
This will create an execution path from the list of objects- Parameters:
objects
- the path objects- Returns:
- a new execution path
-
segment
public ResultPath segment(java.lang.String segment)
Takes the current path and adds a new segment to it, returning a new path- Parameters:
segment
- the string path segment to add- Returns:
- a new path containing that segment
-
segment
public ResultPath segment(int segment)
Takes the current path and adds a new segment to it, returning a new path- Parameters:
segment
- the int path segment to add- Returns:
- a new path containing that segment
-
dropSegment
public ResultPath dropSegment()
Drops the last segment off the path- Returns:
- a new path with the last segment dropped off
-
replaceSegment
public ResultPath replaceSegment(int segment)
Replaces the last segment on the path eg ResultPath.parse("/a/b[1]").replaceSegment(9) equals "/a/b[9]"- Parameters:
segment
- the integer segment to use- Returns:
- a new path with the last segment replaced
-
replaceSegment
public ResultPath replaceSegment(java.lang.String segment)
Replaces the last segment on the path eg ResultPath.parse("/a/b[1]").replaceSegment("x") equals "/a/b/x"- Parameters:
segment
- the string segment to use- Returns:
- a new path with the last segment replaced
-
isRootPath
public boolean isRootPath()
- Returns:
- true if the path is the
rootPath()
-
append
public ResultPath append(ResultPath path)
Appends the provided path to the current one- Parameters:
path
- the path to append- Returns:
- a new path
-
sibling
public ResultPath sibling(java.lang.String siblingField)
-
sibling
public ResultPath sibling(int siblingField)
-
toList
public java.util.List<java.lang.Object> toList()
- Returns:
- converts the path into a list of segments
-
getKeysOnly
public java.util.List<java.lang.String> getKeysOnly()
- Returns:
- this path as a list of result keys, without any indices
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- Returns:
- the path as a string which represents the call hierarchy
-
segmentToString
public java.lang.String segmentToString()
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-