Class 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 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()
      • 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 class java.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 class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object