Package com.fauna.query.builder
Class Query
- java.lang.Object
-
- com.fauna.query.builder.QueryFragment<QueryFragment[]>
-
- com.fauna.query.builder.Query
-
public class Query extends QueryFragment<QueryFragment[]>
Represents a Fauna query that is constructed from multiple query fragments. This class enables the creation of queries from both literal strings and variable placeholders.
-
-
Constructor Summary
Constructors Constructor Description Query(java.lang.String query, java.util.Map<java.lang.String,java.lang.Object> args)
Constructs a Query instance based on the given template string and variable arguments.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Query
fql(java.lang.String query)
Creates a Query instance based solely on a template string without any arguments.static Query
fql(java.lang.String query, java.util.Map<java.lang.String,java.lang.Object> args)
Creates a Query instance based on a template string and a set of arguments.QueryFragment[]
get()
Retrieves the list of fragments that compose this query, where each fragment is either a literal or a variable.
-
-
-
Constructor Detail
-
Query
public Query(java.lang.String query, java.util.Map<java.lang.String,java.lang.Object> args) throws java.lang.IllegalArgumentException
Constructs a Query instance based on the given template string and variable arguments.- Parameters:
query
- A Fauna Query Language (FQL) v10 template string containing both literals and variable placeholders. Placeholders should follow the syntax defined byFaunaTemplate
.args
- A map of variable names to their corresponding values. This map provides the values that are substituted for placeholders in the template string.- Throws:
java.lang.IllegalArgumentException
- if any placeholder in the template string lacks a matching entry inargs
.
-
-
Method Detail
-
fql
public static Query fql(java.lang.String query, java.util.Map<java.lang.String,java.lang.Object> args) throws java.lang.IllegalArgumentException
Creates a Query instance based on a template string and a set of arguments. The template string can contain both literals and variable placeholders, allowing for dynamic query construction.- Parameters:
query
- A Fauna Query Language (FQL) v10 template string. It may contain variables designated by placeholders.args
- A map associating variable names with their values for substitution within the query. Ifnull
, no variables will be substituted.- Returns:
- a Query instance representing the constructed query.
- Throws:
java.lang.IllegalArgumentException
- if any placeholder in the template string lacks a corresponding entry inargs
.
-
fql
public static Query fql(java.lang.String query) throws java.lang.IllegalArgumentException
Creates a Query instance based solely on a template string without any arguments. The template string should contain only literals since no variable values are provided.- Parameters:
query
- A Fauna Query Language (FQL) v10 template string. This version of the template should contain no placeholders, as there are no arguments for substitution.- Returns:
- a Query instance representing the constructed query.
- Throws:
java.lang.IllegalArgumentException
- if the template contains placeholders without a matching entry in the provided arguments.
-
get
public QueryFragment[] get()
Retrieves the list of fragments that compose this query, where each fragment is either a literal or a variable.- Specified by:
get
in classQueryFragment<QueryFragment[]>
- Returns:
- an array of QueryFragment instances representing the parts of the query.
-
-