Class PathFinder

java.lang.Object
sk.antons.json.find.PathFinder

public class PathFinder extends Object
Helper class for find by path functionality
Author:
antons
  • Constructor Details

    • PathFinder

      public PathFinder(JsonValue root, PathMatcher matcher)
      New instance or finder
      Parameters:
      root - root json node
      matcher - path matcher for find functionality
  • Method Details

    • of

      public static PathFinder of(JsonValue root, PathMatcher matcher)
      New instance of PathFinder
      Parameters:
      root - root json node.
      matcher - path matcher for find
      Returns:
      new instance
    • of

      public static PathFinder of(JsonValue root, String... path)
      New instance of PathFinder
      Parameters:
      root - root json node.
      path - path for simple path matcher
      Returns:
      new instance
    • all

      public List<JsonValue> all()
      Find all json values with defined path
      Returns:
      all json values defined by path matcher
    • stream

      public Stream<JsonValue> stream()
      Juste helper methods which converts all() to stream.
      Returns:
      stream from all() list
    • first

      public JsonValue first()
      Find first json value with defined path
      Returns:
      first json value defined by path matcher
    • optional

      public Optional<JsonValue> optional()
      Just helper class for creating Optional from first()
      Returns:
      optional from first()
    • allLiterals

      public List<String> allLiterals()
      Find all json values with defined path and converts them to string value
      Returns:
      all json value defined by path matcher converted to string
    • streamLiterals

      public Stream<String> streamLiterals()
      Just helper method, which converts allLiterals() to strem.
      Returns:
      stream from allLiterals() list
    • firstLiteral

      public String firstLiteral()
      Find first json value with defined path and converts it to string value
      Returns:
      first json value defined by path matcher converted to string
    • optionalLiteral

      public Optional<String> optionalLiteral()
      Juste helper method for converting firstLiteral() to Optional.
      Returns:
      optional from firstLiteral()