Package nz.org.riskscape.engine.function
Class JavaFunction
java.lang.Object
nz.org.riskscape.engine.function.JavaFunction
- All Implemented Interfaces:
AutoCloseable,IdentifiedFunction,RiskscapeFunction,UntypedFunction,Identified
Immutable prototype-builder implementation of IdentifiedFunction
TODO given the use of this an all sorts of other implementations, the name of this needs to change to be more like
'BaseFunction' or 'ImmutableFunction'
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface nz.org.riskscape.engine.function.IdentifiedFunction
IdentifiedFunction.Category, IdentifiedFunction.Wrapping -
Field Summary
FieldsFields inherited from interface nz.org.riskscape.engine.function.RiskscapeFunction
BUILT_IN, LOG -
Constructor Summary
ConstructorsConstructorDescriptionJavaFunction(String id, URI sourceURI, String description, List<Type> argumentTypes, Type returnType, JavaFunction.Delegate delegate, IdentifiedFunction.Category category) JavaFunction(FunctionMetadata metadata, JavaFunction.Delegate delegate) -
Method Summary
Modifier and TypeMethodDescriptionstatic JavaFunctionasBuiltin(String id, IdentifiedFunction.Category category) Execute the function with the given arguments.calling(JavaFunction.Delegate newDelegate) Returns the argument list fromJavaFunction.Delegate.getArguments()if this is not null else defers toRiskscapeFunction.getArguments().getId()voidsetSourceURI(URI sourceURI) toString()validate(RealizationContext context) Validate that the function can be run.withArgumentTypes(List<Type> newArgumentTypes) withArgumentTypes(Type... newArgumentTypes) static JavaFunctionstatic JavaFunctionwithIdAndSource(String id, String source) Deprecated.static JavaFunctionwithIdAndSource(String id, URI source) withReturnType(Type newReturnType) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface nz.org.riskscape.engine.Identified
getIdentifiedClassMethods inherited from interface nz.org.riskscape.engine.function.IdentifiedFunction
getSource, infoOutput, isBuiltin, toEntityMethods inherited from interface nz.org.riskscape.engine.function.RiskscapeFunction
builtin, close, getAggregationFunction, getOverloaded, getRealizable, getTypesFromArguments, identified, identified, isA, setProblemReporter
-
Field Details
-
ID_PATTERN
REGEX pattern for valid ID's.
ID's may only contain alpha numeric characters, ':', '_' and '-',
-
-
Constructor Details
-
JavaFunction
-
JavaFunction
public JavaFunction(String id, URI sourceURI, String description, List<Type> argumentTypes, Type returnType, JavaFunction.Delegate delegate, IdentifiedFunction.Category category)
-
-
Method Details
-
asBuiltin
-
withId
-
withIdAndSource
Deprecated. -
withIdAndSource
- Parameters:
id- of the functionsource- identifies where the function came from. Used when reportingProblems- Returns:
- the function
-
call
Description copied from interface:UntypedFunctionExecute the function with the given arguments.
- Specified by:
callin interfaceUntypedFunction- Parameters:
args- list of arguments to the function that should conform to the types inArgumentList.getArgumentTypes()
-
validate
Description copied from interface:RiskscapeFunctionValidate that the function can be run.
To be considered valid there should be no
Problems found that are at error or fatal. Finding problems of lower severity should not make a function invalid.- Specified by:
validatein interfaceRiskscapeFunction- Returns:
- ResultOrProblems indicating if function is valid
-
getArguments
Returns the argument list from
JavaFunction.Delegate.getArguments()if this is not null else defers toRiskscapeFunction.getArguments().- Specified by:
getArgumentsin interfaceRiskscapeFunction- Returns:
- argument list
-
withArgumentTypes
-
withArgumentTypes
-
withReturnType
-
calling
-
toString
-
getId
- Specified by:
getIdin interfaceIdentified- Returns:
- id
-
getSourceURI
- Specified by:
getSourceURIin interfaceIdentifiedFunction- Returns:
- a uri indicating the source of function. file/uri etc.
-
setSourceURI
-
getDescription
- Specified by:
getDescriptionin interfaceIdentifiedFunction- Returns:
- a human readable description of the function
-
getArgumentTypes
- Specified by:
getArgumentTypesin interfaceRiskscapeFunction- Returns:
- the types that this function expects
-
getReturnType
- Specified by:
getReturnTypein interfaceRiskscapeFunction- Returns:
- the type that this function should return
-
getDelegate
-
getCategory
- Specified by:
getCategoryin interfaceIdentifiedFunction- Returns:
- the category that this function belongs to
-