Package com.fauna.query.builder
Class QueryObj<E extends QueryFragment>
- java.lang.Object
-
- com.fauna.query.builder.QueryFragment<java.util.Map<java.lang.String,E>>
-
- com.fauna.query.builder.QueryObj<E>
-
- Type Parameters:
E
- The type ofQueryObj
. Must be a subtype ofQueryFragment
.
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 aQueryObj
, 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 }
-
-
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>
QueryObjof(java.util.Map<java.lang.String,E> val)
Creates a newQueryObj
instance with the specified map of query fragments.
-
-
-
Constructor Detail
-
QueryObj
public QueryObj(java.util.Map<java.lang.String,E> value)
Constructs a newQueryObj
with the given map of query fragments.- Parameters:
value
- the map to encapsulate.
-
-
Method Detail
-
of
public static <E extends QueryFragment> QueryObj of(java.util.Map<java.lang.String,E> val)
Creates a newQueryObj
instance with the specified map of query fragments.- Type Parameters:
E
- The map value type, which must extendQueryFragment
.- 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 classQueryFragment<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 classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
getValue
public java.util.Map<java.lang.String,E> getValue()
Retrieves the wrapped map value.- Returns:
- the encapsulated map.
-
-