This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git

commit ee3cd7d4eacd842f8d777ad0e8b9aed40d4f7236
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Sat Jan 24 16:57:04 2026 +0100

    Move `ArithmeticFunctionTest` to the correct package.
    Reuse existing `ScopedName` in `ArithmeticFunction`.
    Documentation fixes.
---
 .../org/apache/sis/filter/ComparisonFilter.java    |  2 +-
 .../main/org/apache/sis/filter/TemporalFilter.java | 17 +++--
 .../main/org/apache/sis/filter/base/Node.java      |  2 +-
 .../apache/sis/filter/math/ArithmeticFunction.java | 79 +++++++++-------------
 .../org/apache/sis/filter/math/BinaryOperator.java |  9 +--
 .../main/org/apache/sis/filter/math/Function.java  |  6 ++
 .../main/org/apache/sis/filter/math/Predicate.java |  3 +-
 .../org/apache/sis/filter/math/UnaryOperator.java  |  3 +-
 .../filter/{ => math}/ArithmeticFunctionTest.java  |  5 +-
 9 files changed, 61 insertions(+), 65 deletions(-)

diff --git 
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/ComparisonFilter.java
 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/ComparisonFilter.java
index 1f07dff723..3c48ac4b32 100644
--- 
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/ComparisonFilter.java
+++ 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/ComparisonFilter.java
@@ -368,7 +368,7 @@ abstract class ComparisonFilter<R> extends 
BinaryFunctionWidening<R, Object, Obj
      * This method handles a few types from the {@link java.time} package and 
legacy types like
      * {@link Date} (with a special case for SQL dates) and {@link Calendar}.
      */
-    static Instant toInstant(final Object value) {
+    private static Instant toInstant(final Object value) {
         if (value instanceof Instant) {
             return (Instant) value;
         } else if (value instanceof OffsetDateTime) {
diff --git 
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/TemporalFilter.java
 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/TemporalFilter.java
index a1cabfcc7b..c32399731f 100644
--- 
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/TemporalFilter.java
+++ 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/TemporalFilter.java
@@ -33,9 +33,12 @@ import org.opengis.filter.InvalidFilterValueException;
 
 
 /**
- * Temporal operations between a period and an instant or between two periods.
- * The base class represents the general case when don't know if the the 
argument are periods or not.
- * The subclasses represent specializations when at least one of the arguments 
is known to be a period.
+ * Temporal operations between a period and a Java temporal object or between 
two periods.
+ * The base class represents the general case when we don't know which 
operands are periods.
+ * The subclasses represent specializations when the type of temporal values 
is known in advance.
+ *
+ * <p>In the context of this class, "instant" can be understood as 
<abbr>ISO</abbr> 19108 instant
+ * or as the various {@link java.time} objects, not restricted to {@link 
java.time.Instant}.</p>
  *
  * @author  Johann Sorel (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
@@ -74,9 +77,11 @@ class TemporalFilter<R,T> extends BinaryFunction<R,T,T>
     /**
      * Creates a new temporal function.
      *
+     * @param  <R>          the type of resources (e.g. {@code Feature}) used 
as inputs.
+     * @param  <v>          compile-type value of the {@code type} argument.
+     * @param  type         the base type of values computed by the two given 
operands.
      * @param  expression1  the first of the two expressions to be used by 
this function.
      * @param  expression2  the second of the two expressions to be used by 
this function.
-     * @param  operation    the operation to apply on instants or periods.
      */
     @SuppressWarnings({"rawtypes", "unchecked"})
     public static <R,V> TemporalFilter<R,?> create(
@@ -209,7 +214,9 @@ class TemporalFilter<R,T> extends BinaryFunction<R,T,T>
 
 
     /**
-     * A temporal filters where both operands are ISO 19108 instants.
+     * A temporal filters where both operands are <abbr>ISO</abbr> 19108 
instants.
+     * Instants can be represented by the GeoAPI interface or by the various
+     * {@link java.time} objects, not restricted to {@link java.time.Instant}.
      *
      * @param  <R>  the type of resources used as inputs.
      * @param  <T>  the base type of temporal objects.
diff --git 
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/base/Node.java 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/base/Node.java
index 660e8988e8..6b78d84819 100644
--- 
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/base/Node.java
+++ 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/base/Node.java
@@ -91,7 +91,7 @@ public abstract class Node implements Serializable {
      *
      * @param  <T>   compile-time value of {@code type}.
      * @param  type  type of values in the attribute.
-     * @param  name  name of the attribute to create.
+     * @param  name  name of the attribute to create as a {@link 
org.opengis.util.GenericName} or a {@link String}.
      * @return an attribute of the given type and name.
      *
      * @see Expression#getFunctionName()
diff --git 
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/math/ArithmeticFunction.java
 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/math/ArithmeticFunction.java
index aa94231833..469d03b35c 100644
--- 
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/math/ArithmeticFunction.java
+++ 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/math/ArithmeticFunction.java
@@ -40,9 +40,8 @@ import org.opengis.filter.Expression;
  * @author  Martin Desruisseaux (Geomatys)
  *
  * @param  <R>  the type of resources (typically {@code Feature}) used as 
inputs.
- * @param  <A>  the type of value computed by the two expressions used as 
inputs.
  */
-public abstract class ArithmeticFunction<R, A extends Number> extends 
BinaryFunctionWidening<R, A, A>
+public abstract class ArithmeticFunction<R> extends BinaryFunctionWidening<R, 
Number, Number>
         implements FeatureExpression<R, Number>, Optimization.OnExpression<R, 
Number>
 {
     /**
@@ -56,8 +55,8 @@ public abstract class ArithmeticFunction<R, A extends Number> 
extends BinaryFunc
      * @param  expression1  the first of the two expressions to be used by 
this function.
      * @param  expression2  the second of the two expressions to be used by 
this function.
      */
-    protected ArithmeticFunction(final Expression<R, ? extends A> expression1,
-                                 final Expression<R, ? extends A> expression2)
+    protected ArithmeticFunction(final Expression<R, ? extends Number> 
expression1,
+                                 final Expression<R, ? extends Number> 
expression2)
     {
         super(expression1, expression2);
     }
@@ -94,7 +93,7 @@ public abstract class ArithmeticFunction<R, A extends Number> 
extends BinaryFunc
      * @param  name  name of the attribute to create.
      * @return an attribute of the given name for numbers.
      */
-    private static AttributeType<Number> createNumericType(final String name) {
+    private static AttributeType<Number> createNumericType(final ScopedName 
name) {
         return createType(Number.class, name);
     }
 
@@ -137,8 +136,8 @@ public abstract class ArithmeticFunction<R, A extends 
Number> extends BinaryFunc
     @SuppressWarnings("unchecked")
     public final Expression<R, ? extends Number> optimize(final Optimization 
optimization) {
         final Expression<R, ? extends Number> result = 
Optimization.OnExpression.super.optimize(optimization);
-        if (result instanceof ArithmeticFunction<?,?>) {
-            final var optimized = ((ArithmeticFunction<R,?>) 
result).specialize();
+        if (result instanceof ArithmeticFunction<?>) {
+            final var optimized = ((ArithmeticFunction<R>) 
result).specialize();
             if (optimized != null) {
                 return optimized;
             }
@@ -175,9 +174,8 @@ public abstract class ArithmeticFunction<R, A extends 
Number> extends BinaryFunc
      * The "Add" (+) expression.
      *
      * @param  <R>  the type of resources (typically {@code Feature}) used as 
inputs.
-     * @param  <V>  the type of value computed by the two expressions used as 
inputs.
      */
-    public static final class Add<R, V extends Number> extends 
ArithmeticFunction<R,V> {
+    public static final class Add<R> extends ArithmeticFunction<R> {
         /** For cross-version compatibility during (de)serialization. */
         private static final long serialVersionUID = 5445433312445869201L;
 
@@ -187,8 +185,8 @@ public abstract class ArithmeticFunction<R, A extends 
Number> extends BinaryFunc
          * @param  expression1  the first of the two expressions to be used by 
this operation.
          * @param  expression2  the second of the two expressions to be used 
by this operation.
          */
-        public Add(final Expression<R, ? extends V> expression1,
-                   final Expression<R, ? extends V> expression2)
+        public Add(final Expression<R, ? extends Number> expression1,
+                   final Expression<R, ? extends Number> expression2)
         {
             super(expression1, expression2);
         }
@@ -199,14 +197,11 @@ public abstract class ArithmeticFunction<R, A extends 
Number> extends BinaryFunc
                              effective[1].toValueType(Number.class));
         }
 
-        /** Description of results of the {@code "Add"} expression. */
+        private static final ScopedName NAME = createName(FunctionNames.Add);
+        private static final AttributeType<Number> TYPE = 
createNumericType(NAME);
         @Override protected AttributeType<Number> expectedType() {return TYPE;}
-        private static final AttributeType<Number> TYPE = 
createNumericType(FunctionNames.Add);
-
-        /** Representation of the {@code "Add"} operation. */
-        @Override protected char symbol() {return '+';}
         @Override public ScopedName getFunctionName() {return NAME;}
-        private static final ScopedName NAME = createName(FunctionNames.Add);
+        @Override protected char symbol() {return '+';}
 
         /** Applies this expression to the given operands. */
         @Override protected Number applyAsDouble  (double     left, double     
right) {return left + right;}
@@ -221,9 +216,8 @@ public abstract class ArithmeticFunction<R, A extends 
Number> extends BinaryFunc
      * The "Subtract" (−) expression.
      *
      * @param  <R>  the type of resources (typically {@code Feature}) used as 
inputs.
-     * @param  <V>  the type of value computed by the two expressions used as 
inputs.
      */
-    public static final class Subtract<R, V extends Number> extends 
ArithmeticFunction<R,V> {
+    public static final class Subtract<R> extends ArithmeticFunction<R> {
         /** For cross-version compatibility during (de)serialization. */
         private static final long serialVersionUID = 3048878022726271508L;
 
@@ -233,8 +227,8 @@ public abstract class ArithmeticFunction<R, A extends 
Number> extends BinaryFunc
          * @param  expression1  the first of the two expressions to be used by 
this operation.
          * @param  expression2  the second of the two expressions to be used 
by this operation.
          */
-        public Subtract(final Expression<R, ? extends V> expression1,
-                        final Expression<R, ? extends V> expression2)
+        public Subtract(final Expression<R, ? extends Number> expression1,
+                        final Expression<R, ? extends Number> expression2)
         {
             super(expression1, expression2);
         }
@@ -245,14 +239,11 @@ public abstract class ArithmeticFunction<R, A extends 
Number> extends BinaryFunc
                                   effective[1].toValueType(Number.class));
         }
 
-        /** Description of results of the {@code "Subtract"} expression. */
+        private static final ScopedName NAME = 
createName(FunctionNames.Subtract);
+        private static final AttributeType<Number> TYPE = 
createNumericType(NAME);
         @Override protected AttributeType<Number> expectedType() {return TYPE;}
-        private static final AttributeType<Number> TYPE = 
createNumericType(FunctionNames.Subtract);
-
-        /** Representation of the {@code "Subtract"} operation. */
-        @Override protected char symbol() {return '−';}
         @Override public ScopedName getFunctionName() {return NAME;}
-        private static final ScopedName NAME = 
createName(FunctionNames.Subtract);
+        @Override protected char symbol() {return '−';}
 
         /** Applies this expression to the given operands. */
         @Override protected Number applyAsDouble  (double     left, double     
right) {return left - right;}
@@ -267,9 +258,8 @@ public abstract class ArithmeticFunction<R, A extends 
Number> extends BinaryFunc
      * The "Multiply" (×) expression.
      *
      * @param  <R>  the type of resources (typically {@code Feature}) used as 
inputs.
-     * @param  <V>  the type of value computed by the two expressions used as 
inputs.
      */
-    public static final class Multiply<R, V extends Number> extends 
ArithmeticFunction<R,V> {
+    public static final class Multiply<R> extends ArithmeticFunction<R> {
         /** For cross-version compatibility during (de)serialization. */
         private static final long serialVersionUID = -1300022614832645625L;
 
@@ -279,8 +269,8 @@ public abstract class ArithmeticFunction<R, A extends 
Number> extends BinaryFunc
          * @param  expression1  the first of the two expressions to be used by 
this operation.
          * @param  expression2  the second of the two expressions to be used 
by this operation.
          */
-        public Multiply(final Expression<R, ? extends V> expression1,
-                        final Expression<R, ? extends V> expression2)
+        public Multiply(final Expression<R, ? extends Number> expression1,
+                        final Expression<R, ? extends Number> expression2)
         {
             super(expression1, expression2);
         }
@@ -291,14 +281,11 @@ public abstract class ArithmeticFunction<R, A extends 
Number> extends BinaryFunc
                                   effective[1].toValueType(Number.class));
         }
 
-        /** Description of results of the {@code "Multiply"} expression. */
+        private static final ScopedName NAME = 
createName(FunctionNames.Multiply);
+        private static final AttributeType<Number> TYPE = 
createNumericType(NAME);
         @Override protected AttributeType<Number> expectedType() {return TYPE;}
-        private static final AttributeType<Number> TYPE = 
createNumericType(FunctionNames.Multiply);
-
-        /** Representation of the {@code "Multiply"} operation. */
-        @Override protected char symbol() {return '×';}
         @Override public ScopedName getFunctionName() {return NAME;}
-        private static final ScopedName NAME = 
createName(FunctionNames.Multiply);
+        @Override protected char symbol() {return '×';}
 
         /** Applies this expression to the given operands. */
         @Override protected Number applyAsDouble  (double     left, double     
right) {return left * right;}
@@ -313,9 +300,8 @@ public abstract class ArithmeticFunction<R, A extends 
Number> extends BinaryFunc
      * The "Divide" (÷) expression.
      *
      * @param  <R>  the type of resources (typically {@code Feature}) used as 
inputs.
-     * @param  <V>  the type of value computed by the two expressions used as 
inputs.
      */
-    public static final class Divide<R, V extends Number> extends 
ArithmeticFunction<R,V> {
+    public static final class Divide<R> extends ArithmeticFunction<R> {
         /** For cross-version compatibility during (de)serialization. */
         private static final long serialVersionUID = -7709291845568648891L;
 
@@ -325,8 +311,8 @@ public abstract class ArithmeticFunction<R, A extends 
Number> extends BinaryFunc
          * @param  expression1  the first of the two expressions to be used by 
this operation.
          * @param  expression2  the second of the two expressions to be used 
by this operation.
          */
-        public Divide(final Expression<R, ? extends V> expression1,
-                      final Expression<R, ? extends V> expression2)
+        public Divide(final Expression<R, ? extends Number> expression1,
+                      final Expression<R, ? extends Number> expression2)
         {
             super(expression1, expression2);
         }
@@ -337,16 +323,13 @@ public abstract class ArithmeticFunction<R, A extends 
Number> extends BinaryFunc
                                 effective[1].toValueType(Number.class));
         }
 
-        /** Description of results of the {@code "Divide"} expression. */
+        private static final ScopedName NAME = 
createName(FunctionNames.Divide);
+        private static final AttributeType<Number> TYPE = 
createNumericType(NAME);
         @Override protected AttributeType<Number> expectedType() {return TYPE;}
-        private static final AttributeType<Number> TYPE = 
createNumericType(FunctionNames.Divide);
-
-        /** Representation of the {@code "Divide"} operation. */
-        @Override protected char symbol() {return '÷';}
         @Override public ScopedName getFunctionName() {return NAME;}
-        private static final ScopedName NAME = 
createName(FunctionNames.Divide);
+        @Override protected char symbol() {return '÷';}
 
-        /** Divides the given integers, changing the type if the result is not 
an integer. */
+        /** Applies this expression to the given operands. */
         @Override protected Number applyAsDouble  (double     left, double     
right) {return left / right;}
         @Override protected Number applyAsFraction(Fraction   left, Fraction   
right) {return left.divide(right);}
         @Override protected Number applyAsDecimal (BigDecimal left, BigDecimal 
right) {return left.divide(right);}
diff --git 
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/math/BinaryOperator.java
 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/math/BinaryOperator.java
index a39dd543e6..00dec862b7 100644
--- 
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/math/BinaryOperator.java
+++ 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/math/BinaryOperator.java
@@ -30,8 +30,10 @@ import org.opengis.filter.Expression;
 
 
 /**
- * An operation upon two numerical operands. Inputs are {@link Number} 
instances
- * which will be converted to {@link Double}. Output are {@link Double}.
+ * An operation upon two numerical operands.
+ * Inputs are {@link Number} instances that are unconditionally converted to 
{@code double} type
+ * (i.e., there is no specialized code for specific numeric classes such as 
{@code BigDecimal}).
+ * Output are {@link Double}.
  *
  * <h2>Terminology</h2>
  * "Binary operator" is a specialization of "binary function" in that it 
restricts
@@ -96,8 +98,7 @@ final class BinaryOperator<R> extends BinaryFunction<R, 
Number, Number>
     }
 
     /**
-     * Provides the type of results computed by this expression. That type 
depends only
-     * on the {@code ArithmeticFunction} subclass and is given by {@link 
#expectedType()}.
+     * Provides the type of results computed by this expression.
      */
     @Override
     public final FeatureProjectionBuilder.Item 
expectedType(FeatureProjectionBuilder addTo) {
diff --git 
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/math/Function.java
 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/math/Function.java
index 7a75572a39..f63c98b24c 100644
--- 
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/math/Function.java
+++ 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/math/Function.java
@@ -247,6 +247,8 @@ public enum Function implements FunctionIdentifier, 
AvailableFunction {
 
     /**
      * Returns the function name.
+     *
+     * @return the function name.
      */
     @Override
     public LocalName getName() {
@@ -283,6 +285,8 @@ public enum Function implements FunctionIdentifier, 
AvailableFunction {
 
     /**
      * Returns the type of return value.
+     *
+     * @return the type of return value.
      */
     @Override
     public TypeName getReturnType() {
@@ -296,6 +300,8 @@ public enum Function implements FunctionIdentifier, 
AvailableFunction {
 
     /**
      * Returns the list of arguments expected by the function.
+     *
+     * @return the function operands.
      */
     @Override
     public List<? extends ParameterDescriptor<?>> getArguments() {
diff --git 
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/math/Predicate.java
 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/math/Predicate.java
index 5e0e31be44..6b0e27f403 100644
--- 
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/math/Predicate.java
+++ 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/math/Predicate.java
@@ -87,8 +87,7 @@ final class Predicate<R> extends UnaryFunction<R, Number>
     }
 
     /**
-     * Provides the type of results computed by this expression. That type 
depends only
-     * on the {@code ArithmeticFunction} subclass and is given by {@link 
#expectedType()}.
+     * Provides the type of results computed by this expression.
      */
     @Override
     public final FeatureProjectionBuilder.Item 
expectedType(FeatureProjectionBuilder addTo) {
diff --git 
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/math/UnaryOperator.java
 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/math/UnaryOperator.java
index 535dfb33d2..165b557474 100644
--- 
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/math/UnaryOperator.java
+++ 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/math/UnaryOperator.java
@@ -87,8 +87,7 @@ final class UnaryOperator<R> extends UnaryFunction<R, Number>
     }
 
     /**
-     * Provides the type of results computed by this expression. That type 
depends only
-     * on the {@code ArithmeticFunction} subclass and is given by {@link 
#expectedType()}.
+     * Provides the type of results computed by this expression.
      */
     @Override
     public final FeatureProjectionBuilder.Item 
expectedType(FeatureProjectionBuilder addTo) {
diff --git 
a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/ArithmeticFunctionTest.java
 
b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/math/ArithmeticFunctionTest.java
similarity index 97%
rename from 
endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/ArithmeticFunctionTest.java
rename to 
endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/math/ArithmeticFunctionTest.java
index 5d09d33270..ba86d653a2 100644
--- 
a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/ArithmeticFunctionTest.java
+++ 
b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/math/ArithmeticFunctionTest.java
@@ -14,7 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.filter;
+package org.apache.sis.filter.math;
+
+import org.apache.sis.filter.DefaultFilterFactory;
 
 // Test dependencies
 import org.junit.jupiter.api.Test;
@@ -32,7 +34,6 @@ import org.opengis.filter.FilterFactory;
  *
  * @author  Johann Sorel (Geomatys)
  */
-@SuppressWarnings("exports")
 public final class ArithmeticFunctionTest extends TestCase {
     /**
      * The factory to use for creating the objects to test.

Reply via email to