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.ObjectRepresents 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 newTemplatePartwith the specified text and type.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetPart()Retrieves the text of this part of the template.TemplatePartTypegetType()Retrieves the type of this part of the template.QueryFragmenttoFragment(java.util.Map<java.lang.String,java.lang.Object> args)Converts this template part to aQueryFragmentusing the given arguments.
-
-
-
Constructor Detail
-
TemplatePart
public TemplatePart(java.lang.String part, TemplatePartType type)Constructs a newTemplatePartwith 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.LITERALorTemplatePartType.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 aQueryFragmentusing 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
QueryFragmentrepresenting this template part. - Throws:
java.lang.IllegalArgumentException- if required arguments are missing.
-
-