public abstract class Function extends java.lang.Object implements FunctionDef
FunctionSingle
if it evaluates a single dataset, or FunctionMetric
if it compares two datasets. If the function instance
does not extend either of these it may not be recognised.Modifier and Type | Field and Description |
---|---|
protected java.util.HashMap<java.lang.String,?> |
config
A list of configuration parameters, as key-value pairs.
|
protected EvaluateMathDef |
mathCompare
The evaluation service
|
protected java.lang.String |
valueType
Type of object being evaluated
|
Constructor and Description |
---|
Function()
Create a new instance of Function.
|
Function(java.lang.String thisValueType)
Create a new instance of Function.
|
Function(java.lang.String thisValueType,
java.util.HashMap<java.lang.String,?> thisConfig)
Create a new instance of Function.
|
Modifier and Type | Method and Description |
---|---|
protected void |
checkValueType(MetricDataset md)
If the value type is null, then set it to the data object type in the dataset.
|
static Function |
createFunction(java.lang.String functionType)
Create a new instance of Function.
|
static Function |
createFunction(java.lang.String functionType,
java.lang.String thisValueType)
Create a new instance of Function.
|
static Function |
createFunction(java.lang.String functionType,
java.lang.String thisValueType,
java.util.HashMap<java.lang.String,?> thisConfig)
Create a new instance of Function.
|
ReplySet |
evaluate(MetricDataset dataset)
Return a value based on the function evaluation.
|
java.util.HashMap<java.lang.String,?> |
getConfigParams()
Get the additional config parameters list.
|
protected abstract void |
initialise()
Initialise the function values, setting the config parameters or other.
|
protected java.lang.Object |
innerObject(java.lang.Object metricValue)
Convert the data object to return the nested value if of type
MetricValue . |
static boolean |
isLegalNumber(java.lang.Object number)
Return true if the value is a legal number, for instance, not infinite or NaN.
|
void |
setConfigParams(java.util.HashMap<java.lang.String,?> configParams)
Set the additional config parameters list.
|
void |
setEvaluator(EvaluateMathDef thisEval)
Set the evaluator used to make the mathematical comparisons.
|
void |
setValueType(java.lang.String thisValueType)
Set the value type for the object to be evaluated.
|
protected java.lang.String valueType
protected EvaluateMathDef mathCompare
protected java.util.HashMap<java.lang.String,?> config
public Function() throws java.lang.Exception
valueType
is set to null
and the mathCompare
evaluator is set to SimpleMathCompare
. To change this,
use the setEvaluator
method.java.lang.Exception
- any error.public Function(java.lang.String thisValueType) throws java.lang.Exception
mathCompare
evaluator is set to SimpleMathCompare
.
To change this, use the setEvaluator
method.thisValueType
- the type of object being evaluated. Can be null if set later or not used.java.lang.Exception
- any error.public Function(java.lang.String thisValueType, java.util.HashMap<java.lang.String,?> thisConfig) throws java.lang.Exception
mathCompare
evaluator is set to SimpleMathCompare
.
To change this, use the setEvaluator
method.thisValueType
- the type of object being evaluated. Can be null if set later or not used.thisConfig
- list of initialisation function-specific parameters.java.lang.Exception
- any error.protected abstract void initialise() throws java.lang.Exception
java.lang.Exception
- any error.public ReplySet evaluate(MetricDataset dataset) throws java.lang.Exception
FunctionSingle
,
then the dataset must be of type MetricDataset
. If the function instance is a FunctionMetric
,
then the dataset must be of type MetricCompare
.evaluate
in interface FunctionDef
dataset
- a dataset with the value to evaluate.java.lang.Exception
- any error.protected java.lang.Object innerObject(java.lang.Object metricValue)
MetricValue
.metricValue
- the metric value. could be a raw value or a MetricValue
object, for example.protected void checkValueType(MetricDataset md)
md
- the metric dataset to use.public void setValueType(java.lang.String thisValueType)
thisValueType
- the value of valueType.public void setEvaluator(EvaluateMathDef thisEval)
thisEval
- the value of mathCompare.public void setConfigParams(java.util.HashMap<java.lang.String,?> configParams) throws java.lang.Exception
initialise
from here.configParams
- a copy of this is assigned to config.java.lang.Exception
- any error.public java.util.HashMap<java.lang.String,?> getConfigParams()
public static boolean isLegalNumber(java.lang.Object number)
number
- the floating point number to check.public static Function createFunction(java.lang.String functionType) throws java.lang.Exception
functionType
- the type of function to create. These are listed in AiHeuristicConst
.java.lang.Exception
- any error.public static Function createFunction(java.lang.String functionType, java.lang.String thisValueType) throws java.lang.Exception
createFunction
call that does not require parameters.functionType
- the type of function to create. These are listed in AiHeuristicConst
.thisValueType
- the type of object being evaluated. Can be null if set later or not used.java.lang.Exception
- any error.public static Function createFunction(java.lang.String functionType, java.lang.String thisValueType, java.util.HashMap<java.lang.String,?> thisConfig) throws java.lang.Exception
createFunction
call that only requires thisValueType
.functionType
- the type of function to create. These are listed in AiHeuristicConst
.thisValueType
- the type of object being evaluated. Can be null if set later or not used.thisConfig
- list of initialisation function-specific parameters.java.lang.Exception
- any error.