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,AssertNotNull,Bounds,Buffer,Call,CentroidFunction,ConcatList,FilterList,GeometryPredicateFunction,GeomFromWKT,GetAttribute,IfNull,ListLength,MapList,MergeStruct,NullOf,RandomChoice,RandomNorm,RandomUniform,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 RealizableFunctions
-
Nested Class Summary
Nested classes/interfaces inherited from interface nz.org.riskscape.engine.rl.RealizableFunction
nz.org.riskscape.engine.rl.RealizableFunction.MetadataIdentifiedRealizableFunction -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final nz.org.riskscape.engine.function.ArgumentListprotected final nz.org.riskscape.engine.types.Type -
Constructor Summary
ConstructorsConstructorDescriptionBaseRealizableFunction(nz.org.riskscape.engine.function.ArgumentList arguments, nz.org.riskscape.engine.types.Type returnType) -
Method Summary
Modifier and TypeMethodDescriptionnz.org.riskscape.engine.function.RiskscapeFunctionprotected nz.org.riskscape.engine.function.RiskscapeFunctionbuild(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.IdentifiedFunctionShortcut for asFunction().builtin(id, category)nz.org.riskscape.engine.function.ArgumentListnz.org.riskscape.engine.types.Typenz.org.riskscape.engine.function.IdentifiedFunctionidentified(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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface nz.org.riskscape.engine.rl.RealizableFunction
isDoTypeAdaptation
-
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
RiskscapeFunctionthat wraps thisRealizableFunction. Note that I haven't made this class implementsRiskscapeFunctiondirectly 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:
realizein 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()
-