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

abstract class BinaryFunction<R,V1,V2> extends Node
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 Details

    • serialVersionUID

      private static final long serialVersionUID
      For cross-version compatibility.
      See Also:
    • expression1

      protected final Expression<? super R,? extends V1> expression1
      The first of the two expressions to be used by this function.
      See Also:
      • invalid reference
        #getExpression1()
    • expression2

      protected final Expression<? super R,? extends V2> expression2
      The second of the two expressions to be used by this function.
      See Also:
      • invalid reference
        #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

      public final List<Expression<? super R,?>> getParameters()
      Returns the expressions used as parameters by this function. Defined for Expression.getParameters() implementations.
    • getExpressions

      public List<Expression<? super R,?>> getExpressions()
      Returns the two expressions used as parameters by this filter. Defined for Filter.getExpressions() implementations.
      Returns:
      a list of size 2 containing the two expressions.
    • getChildren

      protected final Collection<?> getChildren()
      Returns the two expressions in a list of size 2. This is used for Node.toString(), Node.hashCode() and Node.equals(Object) implementations.
      Specified by:
      getChildren in class Node
      Returns:
      the children of this node, or an empty collection if none.
    • apply

      protected final Number apply(Number left, Number right)
      Evaluates the expression for producing a result of numeric type. This method delegates to one of the applyAs(…) methods. If no applyAs(…) implementations can return null values, this this method never return null.
      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 null only if an applyAs(…) implementation returned a null value.
    • applyAsLong

      protected Number applyAsLong(long left, long right)
      Calculates this function using given operands of long primitive type. If this function is a filter, then this method should returns an Integer value 0 or 1 for false or true respectively. Otherwise the result is usually a Long, except for division which may produce other types. This method may return null if the operation cannot apply on numbers.
      Throws:
      ArithmeticException - if the operation overflows or if there is a division by zero.
    • applyAsDouble

      protected Number applyAsDouble(double left, double right)
      Calculates this function using given operands of double primitive type. If this function is a filter, then this method should returns an Integer value 0 or 1 for false or true respectively. Otherwise the result is usually a Double. This method may return null if the operation cannot apply on numbers.
    • applyAsFraction

      protected Number applyAsFraction(Fraction left, Fraction right)
      Calculates this function using given operands of Fraction type. If this function is a filter, then this method should returns an Integer value 0 or 1 for false or true respectively. Otherwise the result is usually a Fraction. This method may return null if the operation cannot apply on numbers.
      Throws:
      ArithmeticException - if the operation overflows or if there is a division by zero.
    • applyAsInteger

      protected Number applyAsInteger(BigInteger left, BigInteger right)
      Calculates this function using given operands of BigInteger type. If this function is a filter, then this method should returns an Integer value 0 or 1 for false or true respectively. Otherwise the result is usually a BigInteger, except for division which may produce other types. This method may return null if the operation cannot apply on numbers.
      Throws:
      ArithmeticException - if there is a division by zero.
    • applyAsDecimal

      protected Number applyAsDecimal(BigDecimal left, BigDecimal right)
      Calculates this function using given operands of BigDecimal type. If this function is a filter, then this method should returns an Integer value 0 or 1 for false or true respectively. Otherwise the result is usually a BigDecimal. This method may return null if the operation cannot apply on numbers.
      Throws:
      ArithmeticException - if a division does not have a terminating decimal expansion.