Package com.fauna.query.template
Class FaunaTemplate.TemplatePart
- java.lang.Object
-
- com.fauna.query.template.FaunaTemplate.TemplatePart
-
- Enclosing class:
- FaunaTemplate
public static final class FaunaTemplate.TemplatePart extends java.lang.Object
Represents a part of the template, which can either be a literal string or a variable placeholder.
-
-
Constructor Summary
Constructors Constructor Description TemplatePart(java.lang.String part, TemplatePartType type)
Constructs a newTemplatePart
with the specified text and type.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getPart()
Retrieves the text of this part of the template.TemplatePartType
getType()
Retrieves the type of this part of the template.QueryFragment
toFragment(java.util.Map<java.lang.String,java.lang.Object> args)
Converts this template part to aQueryFragment
using the given arguments.
-
-
-
Constructor Detail
-
TemplatePart
public TemplatePart(java.lang.String part, TemplatePartType type)
Constructs a newTemplatePart
with the specified text and type.- Parameters:
part
- the text for this part of the template, either literal text or a variable.type
- the type of this part of the template, eitherTemplatePartType.LITERAL
orTemplatePartType.VARIABLE
.
-
-
Method Detail
-
getPart
public java.lang.String getPart()
Retrieves the text of this part of the template.- Returns:
- the text for this template part.
-
getType
public TemplatePartType getType()
Retrieves the type of this part of the template.- Returns:
- the type of this template part, either literal or variable.
-
toFragment
public QueryFragment toFragment(java.util.Map<java.lang.String,java.lang.Object> args)
Converts this template part to aQueryFragment
using the given arguments. If this part is a variable, the argument map is checked for a corresponding key, returning an appropriateQueryFragment
. If no matching argument is found, an exception is thrown.- Parameters:
args
- the map of arguments for template substitution.- Returns:
- a
QueryFragment
representing this template part. - Throws:
java.lang.IllegalArgumentException
- if required arguments are missing.
-
-