Class GPath<O>

  • Type Parameters:
    O - the selection result

    public class GPath<O>
    extends java.lang.Object
    Allows to select values from GSON documents The eval method returns the selection result given a root JsonElement. GPath instances can be built either
    1. by starting from the last select step and adding the preceding selection steps in a fluent interface like manner (e.g. the GPath string().field("name") accesses the "name" field of a GSON document) or
    2. by using nested methods calls (e.g. the nested method calls field("name", string()) construct the same GSON path).
    • Constructor Summary

      Constructors 
      Constructor Description
      GPath​(java.util.function.Function<com.google.gson.JsonElement,​O> eval)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static GPath<com.google.gson.JsonElement> any()  
      static GPath<com.google.gson.JsonArray> array()  
      GPath<java.util.List<O>> array​(java.lang.String name)  
      static <X> GPath<java.util.List<X>> array​(java.lang.String name, GPath<X> path)  
      static GPath<java.lang.Double> dbl()  
      O eval​(com.google.gson.JsonElement in)
      Returns the selection result given the root JsonElement.
      GPath<O> field​(java.lang.String name)  
      GPath<O> field​(java.lang.String name, java.lang.String altName)  
      static <X> GPath<X> field​(java.lang.String name, java.lang.String altName, GPath<X> path)  
      static <X> GPath<X> field​(java.lang.String name, GPath<X> path)  
      static GPath<java.lang.Integer> integer()  
      <X> GPath<X> map​(java.util.function.Function<O,​X> f)  
      static GPath<com.google.gson.JsonObject> object()  
      static GPath<java.lang.String> string()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GPath

        public GPath​(java.util.function.Function<com.google.gson.JsonElement,​O> eval)
    • Method Detail

      • string

        public static GPath<java.lang.String> string()
      • dbl

        public static GPath<java.lang.Double> dbl()
      • integer

        public static GPath<java.lang.Integer> integer()
      • any

        public static GPath<com.google.gson.JsonElement> any()
      • object

        public static GPath<com.google.gson.JsonObject> object()
      • array

        public static GPath<com.google.gson.JsonArray> array()
      • field

        public static <X> GPath<X> field​(java.lang.String name,
                                         GPath<X> path)
      • field

        public static <X> GPath<X> field​(java.lang.String name,
                                         java.lang.String altName,
                                         GPath<X> path)
      • array

        public static <X> GPath<java.util.List<X>> array​(java.lang.String name,
                                                         GPath<X> path)
      • field

        public GPath<O> field​(java.lang.String name)
      • field

        public GPath<O> field​(java.lang.String name,
                              java.lang.String altName)
      • array

        public GPath<java.util.List<O>> array​(java.lang.String name)
      • map

        public <X> GPath<X> map​(java.util.function.Function<O,​X> f)
      • eval

        public O eval​(com.google.gson.JsonElement in)
        Returns the selection result given the root JsonElement.
        Parameters:
        in - the root element the evaluation is base on.
        Returns:
        in case that the GPath selects non-existing fields null is returned.