Package com.fauna.query.builder
Class QueryArr<E extends QueryFragment>
- java.lang.Object
-
- com.fauna.query.builder.QueryFragment<java.util.List<E>>
-
- com.fauna.query.builder.QueryArr<E>
-
- Type Parameters:
E
- The type of elements in the QueryArr, which must be a subtype ofQueryFragment
.
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 aQueryVal
. By wrapping it in aQueryArr
, 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]
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
Checks if thisQueryArr
is equal to another object.java.util.List<E>
get()
Retrieves the encapsulated list of query fragments in thisQueryArr
.java.util.List<E>
getValue()
Retrieves the encapsulated list directly.int
hashCode()
Returns the hash code of thisQueryArr
, 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 newQueryArr
instance.
-
-
-
Constructor Detail
-
QueryArr
public QueryArr(java.util.List<E> value)
Constructs aQueryArr
with the specified list of query fragments.- Parameters:
value
- the list of query fragments to encapsulate.
-
-
Method Detail
-
of
public static <E extends QueryFragment> QueryArr<E> of(java.util.List<E> val)
Static factory method to create a newQueryArr
instance.- Type Parameters:
E
- the type of elements in the list, which must extendQueryFragment
.- Parameters:
val
- the list ofQueryFragment
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 thisQueryArr
.- Specified by:
get
in classQueryFragment<java.util.List<E extends QueryFragment>>
- Returns:
- the list of query fragments.
-
equals
public boolean equals(java.lang.Object o)
Checks if thisQueryArr
is equal to another object. TwoQueryArr
objects are equal if they contain the same list of query fragments.- Overrides:
equals
in classjava.lang.Object
- Parameters:
o
- the object to compare with.- Returns:
true
if the specified object is equal to thisQueryArr
;false
otherwise.
-
hashCode
public int hashCode()
Returns the hash code of thisQueryArr
, based on its encapsulated list of query fragments.- Overrides:
hashCode
in classjava.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.
-
-