Class QueryArr<E extends QueryFragment>

  • Type Parameters:
    E - The type of elements in the QueryArr, which must be a subtype of QueryFragment.

    public final class QueryArr<E extends QueryFragment>
    extends QueryFragment<java.util.List<E>>
    Represents a special type that allows Fauna to evaluate an array of individual queries, each of which will be processed, and its result will be an element in the returned array.

    Example usage:

       var listOfQueries = List.of(fql("1 + 1"), fql("2 + 2"), fql("3 + 3"));
     
    Directly providing this list to a query will fail because it would be treated as a QueryVal. By wrapping it in a QueryArr, each query within the list will be evaluated separately:
       client.query(fql("${queries}", Map.of("queries", listOfQueries)));
       // Error: the list is treated as a single value.
    
       client.query(fql("${queries}", Map.of("queries", QueryArr.of(listOfQueries)));
       // Returns: [2, 4, 6]
     
    • Constructor Summary

      Constructors 
      Constructor Description
      QueryArr​(java.util.List<E> value)
      Constructs a QueryArr with the specified list of query fragments.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)
      Checks if this QueryArr is equal to another object.
      java.util.List<E> get()
      Retrieves the encapsulated list of query fragments in this QueryArr.
      java.util.List<E> getValue()
      Retrieves the encapsulated list directly.
      int hashCode()
      Returns the hash code of this QueryArr, based on its encapsulated list of query fragments.
      static <E extends QueryFragment>
      QueryArr<E>
      of​(java.util.List<E> val)
      Static factory method to create a new QueryArr instance.
      • Methods inherited from class java.lang.Object

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

      • QueryArr

        public QueryArr​(java.util.List<E> value)
        Constructs a QueryArr with the specified list of query fragments.
        Parameters:
        value - the list of query fragments to encapsulate.
    • Method Detail

      • of

        public static <E extends QueryFragmentQueryArr<E> of​(java.util.List<E> val)
        Static factory method to create a new QueryArr instance.
        Type Parameters:
        E - the type of elements in the list, which must extend QueryFragment.
        Parameters:
        val - the list of QueryFragment elements to wrap.
        Returns:
        a new instance of QueryArr encapsulating the provided list.
      • get

        public java.util.List<E> get()
        Retrieves the encapsulated list of query fragments in this QueryArr.
        Specified by:
        get in class QueryFragment<java.util.List<E extends QueryFragment>>
        Returns:
        the list of query fragments.
      • equals

        public boolean equals​(java.lang.Object o)
        Checks if this QueryArr is equal to another object. Two QueryArr objects are equal if they contain the same list of query fragments.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        o - the object to compare with.
        Returns:
        true if the specified object is equal to this QueryArr; false otherwise.
      • hashCode

        public int hashCode()
        Returns the hash code of this QueryArr, based on its encapsulated list of query fragments.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hash code of this object.
      • getValue

        public java.util.List<E> getValue()
        Retrieves the encapsulated list directly.
        Returns:
        the encapsulated list of query fragments.