Package nz.org.riskscape.engine.function
Class BaseRealizableFunction
java.lang.Object
nz.org.riskscape.engine.function.BaseRealizableFunction
- All Implemented Interfaces:
nz.org.riskscape.engine.rl.RealizableFunction
- Direct Known Subclasses:
AppendList
,Bounds
,Buffer
,Call
,ConcatList
,GeometryPredicateFunction
,GeomFromWKT
,IfNull
,ListLength
,MapList
,MergeStruct
,NullOf
,RandomChoice
,RemoveAttr
,Reproject
,Round
,ToTypedCoverage
,ZipLists
public abstract class BaseRealizableFunction
extends Object
implements nz.org.riskscape.engine.rl.RealizableFunction
Base class for DRYing up all the code common to most RealizableFunction
s
-
Nested Class Summary
Nested classes/interfaces inherited from interface nz.org.riskscape.engine.rl.RealizableFunction
nz.org.riskscape.engine.rl.RealizableFunction.MetadataIdentifiedRealizableFunction
-
Field Summary
Modifier and TypeFieldDescriptionprotected final nz.org.riskscape.engine.function.ArgumentList
protected final nz.org.riskscape.engine.types.Type
-
Constructor Summary
ConstructorDescriptionBaseRealizableFunction
(nz.org.riskscape.engine.function.ArgumentList arguments, nz.org.riskscape.engine.types.Type returnType) -
Method Summary
Modifier and TypeMethodDescriptionnz.org.riskscape.engine.function.RiskscapeFunction
protected nz.org.riskscape.engine.function.RiskscapeFunction
build
(nz.org.riskscape.engine.rl.RealizationContext context, nz.org.riskscape.rl.ast.FunctionCall functionCall, List<nz.org.riskscape.engine.types.Type> givenTypes) This method is internal to the sub-class.nz.org.riskscape.engine.function.IdentifiedFunction
Shortcut for asFunction().builtin(id, category)nz.org.riskscape.engine.function.ArgumentList
nz.org.riskscape.engine.types.Type
nz.org.riskscape.engine.function.IdentifiedFunction
identified
(String id) Shortcut for asFunction().identified(id)nz.org.riskscape.problem.ResultOrProblems<nz.org.riskscape.engine.function.RiskscapeFunction>
realize
(nz.org.riskscape.engine.rl.RealizationContext context, nz.org.riskscape.rl.ast.FunctionCall functionCall, List<nz.org.riskscape.engine.types.Type> givenTypes) Implements some basic boilerplate error checks by default.
-
Field Details
-
arguments
protected final nz.org.riskscape.engine.function.ArgumentList arguments -
returnType
protected final nz.org.riskscape.engine.types.Type returnType
-
-
Constructor Details
-
BaseRealizableFunction
public BaseRealizableFunction(nz.org.riskscape.engine.function.ArgumentList arguments, nz.org.riskscape.engine.types.Type returnType)
-
-
Method Details
-
asFunction
public nz.org.riskscape.engine.function.RiskscapeFunction asFunction()- Returns:
- a
RiskscapeFunction
that wraps thisRealizableFunction
. Note that I haven't made this class implementsRiskscapeFunction
directly as the plan is to re-arrange these classes so that all functions become realizable but are not riskscape functions themselves (until they are realized).
-
identified
Shortcut for asFunction().identified(id)
-
builtin
public nz.org.riskscape.engine.function.IdentifiedFunction builtin(String id, nz.org.riskscape.engine.function.IdentifiedFunction.Category category) Shortcut for asFunction().builtin(id, category)
-
realize
public nz.org.riskscape.problem.ResultOrProblems<nz.org.riskscape.engine.function.RiskscapeFunction> realize(nz.org.riskscape.engine.rl.RealizationContext context, nz.org.riskscape.rl.ast.FunctionCall functionCall, List<nz.org.riskscape.engine.types.Type> givenTypes) Implements some basic boilerplate error checks by default. This allows simple realizable functions to just define the
build(RealizationContext, FunctionCall, List)
guts of the function. More complicated realizable functions (i.e. with non-trivial type handling) may want to override this completely.- Specified by:
realize
in interfacenz.org.riskscape.engine.rl.RealizableFunction
-
build
protected nz.org.riskscape.engine.function.RiskscapeFunction build(nz.org.riskscape.engine.rl.RealizationContext context, nz.org.riskscape.rl.ast.FunctionCall functionCall, List<nz.org.riskscape.engine.types.Type> givenTypes) throws nz.org.riskscape.problem.ProblemException This method is internal to the sub-class. Simple realizable functions can just implement this, to jump straight to the meat of building the realized function. You should throw a ProblemException for any errors encountered.
- Throws:
nz.org.riskscape.problem.ProblemException
-
getArguments
public nz.org.riskscape.engine.function.ArgumentList getArguments() -
getReturnType
public nz.org.riskscape.engine.types.Type getReturnType()
-