CompilerBuilder
public class CompilerBuilderImpl extends Object implements CompilerBuilder
CompilerBuilder
.Constructor | Description |
---|---|
CompilerBuilderImpl(String source) |
Modifier and Type | Method | Description |
---|---|---|
Expression<?> |
compile() |
Compile the expression.
|
<T> Expression<T> |
compile(Type<T> expected) |
Compile the expression with an expected result type.
|
CompilerBuilder |
withFunction(Function<?> function) |
Declare a
Function so that it's accessible from the expression. |
CompilerBuilder |
withOption(String key,
Object value) |
Enable a compiler option with the given value.
|
CompilerBuilder |
withVariable(String id,
Type type,
Variable<?> variable) |
Declare a
Variable so that it's accessible from the expression. |
CompilerBuilder |
withVariableFactory(VariableFactory variableFactory) |
Adds a
VariableFactory so that the compiler can instance new variables when needed. |
public CompilerBuilderImpl(String source)
public CompilerBuilder withOption(String key, Object value)
CompilerBuilder
withOption
in interface CompilerBuilder
key
- Option namevalue
- Option valuepublic CompilerBuilder withFunction(Function<?> function)
CompilerBuilder
Function
so that it's accessible from the expression.withFunction
in interface CompilerBuilder
function
- Function instance.public CompilerBuilder withVariableFactory(VariableFactory variableFactory)
CompilerBuilder
VariableFactory
so that the compiler can instance new variables when needed.withVariableFactory
in interface CompilerBuilder
variableFactory
- Variable factorypublic CompilerBuilder withVariable(String id, Type type, Variable<?> variable)
CompilerBuilder
Variable
so that it's accessible from the expression.withVariable
in interface CompilerBuilder
id
- Variable idtype
- Variable intermediatevariable
- Variable implementationpublic <T> Expression<T> compile(Type<T> expected) throws ParseException
CompilerBuilder
compile
in interface CompilerBuilder
T
- Value Java typeexpected
- Expected return typeParseException
- When the parsing fails or the expression cannot be converted to type.public Expression<?> compile() throws ParseException
CompilerBuilder
compile
in interface CompilerBuilder
ParseException
- When the parsing fails or the expression cannot be converted to type.Copyright © 2019. All rights reserved.