-
public class CustomTemplate.Builder<P extends CustomTemplatePresenter<?>, T extends CustomTemplate.Builder<P, T>>Builder for CustomTemplates creation. Name and presenter must be set before calling build. Arguments can be specified by using one of the *argument methods. Argument names must be unique. "." characters in template arguments' names denote hierarchical structure. They are treated the same way as the keys within maps passed to mapArgument. If a higher-level name (to the left of a . symbol) matches a map argument's name it is treated the same as if the argument was part of the map itself.
For example, the following code snippets define identical arguments:
builder.mapArgument( name = "map", value = mapOf ( "a" to 5, "b" to 6 ) )and
builder.intArgument("map.a", 5) builder.intArgument("map.b", 6)Methods of this class throw CustomTemplateException for invalid states or parameters. Exceptions of this type are not meant to be caught since defined templates must be correct when the sdk is running. If such an exception is thrown the template definition should be changed instead of handling the error.
-
-
Method Summary
Modifier and Type Method Description final Tname(String name)The name for the template. final TstringArgument(String name, String defaultValue)final TbooleanArgument(String name, Boolean defaultValue)final TbyteArgument(String name, Byte defaultValue)final TshortArgument(String name, Short defaultValue)final TintArgument(String name, Integer defaultValue)final TlongArgument(String name, Long defaultValue)final TfloatArgument(String name, Float defaultValue)final TdoubleArgument(String name, Double defaultValue)final TfileArgument(String name)final TmapArgument(String name, Map<String, Object> value)Add a map structure to the arguments of the CustomTemplate. final Tpresenter(P presenter)The presenter for this template. final CustomTemplatebuild()Creates the CustomTemplate with the previously defined name, arguments and presenter. -
-
Method Detail
-
name
final T name(String name)
The name for the template. It should be provided exactly once. It must be unique across template definitions. Must be non-blank.
-
stringArgument
final T stringArgument(String name, String defaultValue)
-
booleanArgument
final T booleanArgument(String name, Boolean defaultValue)
-
byteArgument
final T byteArgument(String name, Byte defaultValue)
-
shortArgument
final T shortArgument(String name, Short defaultValue)
-
intArgument
final T intArgument(String name, Integer defaultValue)
-
longArgument
final T longArgument(String name, Long defaultValue)
-
floatArgument
final T floatArgument(String name, Float defaultValue)
-
doubleArgument
final T doubleArgument(String name, Double defaultValue)
-
fileArgument
final T fileArgument(String name)
-
mapArgument
final T mapArgument(String name, Map<String, Object> value)
Add a map structure to the arguments of the CustomTemplate. The name should be unique across all arguments and also all keys in value should form unique names across all arguments.
- Parameters:
value- The map must be non-empty.
-
build
final CustomTemplate build()
Creates the CustomTemplate with the previously defined name, arguments and presenter. Name and presenter must be set before calling this method.
-
-
-
-