Package org.apache.sis.filter
Class ArithmeticFunction<R>
java.lang.Object
org.apache.sis.internal.filter.Node
org.apache.sis.filter.BinaryFunction<R,Number,Number>
org.apache.sis.filter.ArithmeticFunction<R>
- Type Parameters:
R
- the type of resources (e.g.Feature
) used as inputs.
- All Implemented Interfaces:
Serializable
,Function<R,
,Number> Expression<R,
,Number> Optimization.OnExpression<R,
,Number> FeatureExpression<R,
Number>
- Direct Known Subclasses:
ArithmeticFunction.Add
,ArithmeticFunction.Divide
,ArithmeticFunction.Multiply
,ArithmeticFunction.Subtract
abstract class ArithmeticFunction<R>
extends BinaryFunction<R,Number,Number>
implements FeatureExpression<R,Number>, Optimization.OnExpression<R,Number>
Arithmetic operations between two numerical values.
The nature of the operation depends on the subclass.
- Since:
- 1.1
- Version:
- 1.1
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class
The "Add" (+) expression.(package private) static final class
The "Divide" (÷) expression.(package private) static final class
The "Multiply" (×) expression.(package private) static final class
The "Subtract" (−) expression. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final long
For cross-version compatibility.Fields inherited from class org.apache.sis.filter.BinaryFunction
expression1, expression2
-
Constructor Summary
ConstructorsConstructorDescriptionArithmeticFunction
(Expression<? super R, ? extends Number> expression1, Expression<? super R, ? extends Number> expression2) Creates a new arithmetic function. -
Method Summary
Modifier and TypeMethodDescriptionfinal Number
Evaluates the expression for producing a result of numeric type.(package private) static DefaultAttributeType
<Number> createNumericType
(String name) Creates an attribute type for numeric values of the given name.protected abstract DefaultAttributeType
<Number> Returns the type of results computed by this arithmetic function.final PropertyTypeBuilder
expectedType
(DefaultFeatureType ignored, FeatureTypeBuilder addTo) Provides the type of results computed by this expression.final Class
<?> Returns the type of values computed by this expression.<N> Expression
<R, N> toValueType
(Class<N> target) Returnsthis
if this expression provides values of the specified type, or otherwise returns an expression doing conversions on-the-fly.Methods inherited from class org.apache.sis.filter.BinaryFunction
apply, applyAsDecimal, applyAsDouble, applyAsFraction, applyAsInteger, applyAsLong, getChildren, getExpressions, getParameters
Methods inherited from class org.apache.sis.internal.filter.Node
createName, createType, equals, getGeometryLibrary, hashCode, symbol, toGeometryWrapper, toString, unwrap, warning
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.sis.filter.Expression
getFunctionName, getParameters
Methods inherited from interface org.apache.sis.filter.Optimization.OnExpression
optimize, recreate
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
-
Constructor Details
-
ArithmeticFunction
ArithmeticFunction(Expression<? super R, ? extends Number> expression1, Expression<? super R, ? extends Number> expression2) Creates a new arithmetic function.
-
-
Method Details
-
createNumericType
Creates an attribute type for numeric values of the given name. The attribute is mandatory, unbounded and has no default value.- Parameters:
name
- name of the attribute to create.- Returns:
- an attribute of the given name for numbers.
-
expectedType
Returns the type of results computed by this arithmetic function. -
getValueClass
Returns the type of values computed by this expression.- Specified by:
getValueClass
in interfaceFeatureExpression<R,
Number> - Returns:
- the type of values computed by this expression.
-
expectedType
Provides the type of results computed by this expression. That type depends only on theArithmeticFunction
subclass and is given byexpectedType()
.- Specified by:
expectedType
in interfaceFeatureExpression<R,
Number> - Parameters:
ignored
- the type of features to be evaluated by the given expression.addTo
- where to add the type of properties evaluated by this expression.- Returns:
- builder of the added property, or
null
if this method cannot add a property.
-
apply
Evaluates the expression for producing a result of numeric type. This method delegates to one of theapplyAs(…)
methods. If noapplyAs(…)
implementations can return null values, this this method never returnnull
. -
toValueType
Returnsthis
if this expression provides values of the specified type, or otherwise returns an expression doing conversions on-the-fly.- Specified by:
toValueType
in interfaceExpression<R,
Number> - Type Parameters:
N
- compile-time value oftype
.- Parameters:
target
- desired type of expression results.- Returns:
- expression doing the same operation this this expression but with results of the specified type.
- Throws:
ClassCastException
- if the specified type is not a supported target type.
-