Package org.apache.sis.filter
Class BinaryFunction<R,V1,V2>
java.lang.Object
org.apache.sis.internal.filter.Node
org.apache.sis.filter.BinaryFunction<R,V1,V2>
- Type Parameters:
R- the type of resources (e.g.Feature) used as inputs.V1- the type of value computed by the first expression.V2- the type of value computed by the second expression.
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ArithmeticFunction,ComparisonFilter,TemporalFilter
Base class for expressions, comparators or filters performing operations on two expressions.
The nature of the operation depends on the subclass. If operands are numerical values, they
may be converted to a common type before the operation is performed. That operation is not
necessarily an arithmetic operation; it may be a comparison for example.
- Since:
- 1.1
- Version:
- 1.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Expression<? super R,? extends V1> The first of the two expressions to be used by this function.protected final Expression<? super R,? extends V2> The second of the two expressions to be used by this function.private static final longFor cross-version compatibility. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBinaryFunction(Expression<? super R, ? extends V1> expression1, Expression<? super R, ? extends V2> expression2) Creates a new binary function. -
Method Summary
Modifier and TypeMethodDescriptionprotected final NumberEvaluates the expression for producing a result of numeric type.protected NumberapplyAsDecimal(BigDecimal left, BigDecimal right) Calculates this function using given operands ofBigDecimaltype.protected NumberapplyAsDouble(double left, double right) Calculates this function using given operands ofdoubleprimitive type.protected NumberapplyAsFraction(Fraction left, Fraction right) Calculates this function using given operands ofFractiontype.protected NumberapplyAsInteger(BigInteger left, BigInteger right) Calculates this function using given operands ofBigIntegertype.protected NumberapplyAsLong(long left, long right) Calculates this function using given operands oflongprimitive type.protected final Collection<?>Returns the two expressions in a list of size 2.List<Expression<? super R,?>> Returns the two expressions used as parameters by this filter.final List<Expression<? super R,?>> Returns the expressions used as parameters by this function.Methods inherited from class org.apache.sis.internal.filter.Node
createName, createType, equals, getGeometryLibrary, hashCode, symbol, toGeometryWrapper, toString, unwrap, warning
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
expression1
The first of the two expressions to be used by this function.- See Also:
-
#getExpression1()
-
expression2
The second of the two expressions to be used by this function.- See Also:
-
#getExpression2()
-
-
Constructor Details
-
BinaryFunction
protected BinaryFunction(Expression<? super R, ? extends V1> expression1, Expression<? super R, ? extends V2> expression2) Creates a new binary function.- Parameters:
expression1- the first of the two expressions to be used by this function.expression2- the second of the two expressions to be used by this function.
-
-
Method Details
-
getParameters
Returns the expressions used as parameters by this function. Defined forExpression.getParameters()implementations. -
getExpressions
Returns the two expressions used as parameters by this filter. Defined forFilter.getExpressions()implementations.- Returns:
- a list of size 2 containing the two expressions.
-
getChildren
Returns the two expressions in a list of size 2. This is used forNode.toString(),Node.hashCode()andNode.equals(Object)implementations.- Specified by:
getChildrenin classNode- Returns:
- the children of this node, or an empty collection if none.
-
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.- Parameters:
left- the left operand. Cannot be null.right- the right operand. Cannot be null.- Returns:
- result of this function applied on the two given operands.
May be
nullonly if anapplyAs(…)implementation returned a null value.
-
applyAsLong
Calculates this function using given operands oflongprimitive type. If this function is a filter, then this method should returns anIntegervalue 0 or 1 for false or true respectively. Otherwise the result is usually aLong, except for division which may produce other types. This method may returnnullif the operation cannot apply on numbers.- Throws:
ArithmeticException- if the operation overflows or if there is a division by zero.
-
applyAsDouble
Calculates this function using given operands ofdoubleprimitive type. If this function is a filter, then this method should returns anIntegervalue 0 or 1 for false or true respectively. Otherwise the result is usually aDouble. This method may returnnullif the operation cannot apply on numbers. -
applyAsFraction
Calculates this function using given operands ofFractiontype. If this function is a filter, then this method should returns anIntegervalue 0 or 1 for false or true respectively. Otherwise the result is usually aFraction. This method may returnnullif the operation cannot apply on numbers.- Throws:
ArithmeticException- if the operation overflows or if there is a division by zero.
-
applyAsInteger
Calculates this function using given operands ofBigIntegertype. If this function is a filter, then this method should returns anIntegervalue 0 or 1 for false or true respectively. Otherwise the result is usually aBigInteger, except for division which may produce other types. This method may returnnullif the operation cannot apply on numbers.- Throws:
ArithmeticException- if there is a division by zero.
-
applyAsDecimal
Calculates this function using given operands ofBigDecimaltype. If this function is a filter, then this method should returns anIntegervalue 0 or 1 for false or true respectively. Otherwise the result is usually aBigDecimal. This method may returnnullif the operation cannot apply on numbers.- Throws:
ArithmeticException- if a division does not have a terminating decimal expansion.
-