Class QueryObj<E extends QueryFragment>

  • Type Parameters:
    E - The type of QueryObj. Must be a subtype of QueryFragment.

    public final class QueryObj<E extends QueryFragment>
    extends QueryFragment<java.util.Map<java.lang.String,​E>>
    This class represents a special type of query fragment that allows users to provide Fauna with an object whose values are individual queries. Each of these queries will be evaluated, and the result of each query will be a value in the returned object.

    Example usage: Given a map of queries:

       var o = Map.of("key1", fql("1 + 1"));
     
    If this map is passed directly to a query, it will fail because the entire object will be treated as a value. However, if you wrap the map in a QueryObj, Fauna will evaluate each query.
       client.query(fql("${obj}", Map.of("obj", o));
       // Error: the map is treated as a value.
    
       client.query(fql("${obj}", Map.of("obj", QueryObj.of(o)))
       // Result: { "key1": 2 }
     
    • Constructor Summary

      Constructors 
      Constructor Description
      QueryObj​(java.util.Map<java.lang.String,​E> value)
      Constructs a new QueryObj with the given map of query fragments.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)  
      java.util.Map<java.lang.String,​E> get()
      Retrieves the encapsulated map of query fragments that make up this query object.
      java.util.Map<java.lang.String,​E> getValue()
      Retrieves the wrapped map value.
      int hashCode()  
      static <E extends QueryFragment>
      QueryObj
      of​(java.util.Map<java.lang.String,​E> val)
      Creates a new QueryObj instance with the specified map of query fragments.
      • Methods inherited from class java.lang.Object

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

      • QueryObj

        public QueryObj​(java.util.Map<java.lang.String,​E> value)
        Constructs a new QueryObj with the given map of query fragments.
        Parameters:
        value - the map to encapsulate.
    • Method Detail

      • of

        public static <E extends QueryFragmentQueryObj of​(java.util.Map<java.lang.String,​E> val)
        Creates a new QueryObj instance with the specified map of query fragments.
        Type Parameters:
        E - The map value type, which must extend QueryFragment.
        Parameters:
        val - the map of query fragments to wrap.
        Returns:
        a new QueryObj instance wrapping the provided map.
      • get

        public java.util.Map<java.lang.String,​E> get()
        Retrieves the encapsulated map of query fragments that make up this query object.
        Specified by:
        get in class QueryFragment<java.util.Map<java.lang.String,​E extends QueryFragment>>
        Returns:
        the map of query fragments.
      • 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
      • getValue

        public java.util.Map<java.lang.String,​E> getValue()
        Retrieves the wrapped map value.
        Returns:
        the encapsulated map.