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
The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
new 7e19b7fe50 Restore contravariance on `FeatureQuery` class. This is a
much smaller scope than the previous contravariance on `Filter` interface.
Furthermore the addition of `getResourceClass()` in previous commit allows some
type checks if needed.
7e19b7fe50 is described below
commit 7e19b7fe50ba1c7d484b35b8a2c94deb80e0da54
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Mon May 1 17:27:24 2023 +0200
Restore contravariance on `FeatureQuery` class.
This is a much smaller scope than the previous contravariance on `Filter`
interface.
Furthermore the addition of `getResourceClass()` in previous commit allows
some type checks if needed.
---
.../apache/sis/feature/ExpressionOperation.java | 4 ++--
.../org/apache/sis/feature/FeatureOperations.java | 4 ++--
.../java/org/apache/sis/storage/FeatureQuery.java | 22 +++++++++++-----------
.../java/org/apache/sis/storage/FeatureSubset.java | 4 ++--
4 files changed, 17 insertions(+), 17 deletions(-)
diff --git
a/core/sis-feature/src/main/java/org/apache/sis/feature/ExpressionOperation.java
b/core/sis-feature/src/main/java/org/apache/sis/feature/ExpressionOperation.java
index efbc5cb83c..c5990072e8 100644
---
a/core/sis-feature/src/main/java/org/apache/sis/feature/ExpressionOperation.java
+++
b/core/sis-feature/src/main/java/org/apache/sis/feature/ExpressionOperation.java
@@ -64,7 +64,7 @@ final class ExpressionOperation<V> extends AbstractOperation {
* The expression on which to delegate the execution of this operation.
*/
@SuppressWarnings("serial") // Not statically
typed as serializable.
- private final Function<Feature, ? extends V> expression;
+ private final Function<? super Feature, ? extends V> expression;
/**
* The type of result of evaluating the expression.
@@ -88,7 +88,7 @@ final class ExpressionOperation<V> extends AbstractOperation {
* @param result type of values computed by the expression.
*/
ExpressionOperation(final Map<String,?> identification,
- final Function<Feature, ? extends V> expression,
+ final Function<? super Feature, ? extends V>
expression,
final AttributeType<? super V> result)
{
super(identification);
diff --git
a/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureOperations.java
b/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureOperations.java
index b4ab1692d0..15c36b01cb 100644
---
a/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureOperations.java
+++
b/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureOperations.java
@@ -280,7 +280,7 @@ public final class FeatureOperations extends Static {
* @since 1.4
*/
public static <V> Operation expression(final Map<String,?> identification,
- final Function<Feature, ? extends
V> expression,
+ final Function<? super Feature, ?
extends V> expression,
final AttributeType<? super V>
result)
{
ArgumentChecks.ensureNonNull("expression", expression);
@@ -304,7 +304,7 @@ public final class FeatureOperations extends Static {
* @since 1.4
*/
public static <V> Operation expressionToResult(final Map<String,?>
identification,
- final Expression<Feature,
?> expression,
+ final Expression<? super
Feature, ?> expression,
final AttributeType<V>
result)
{
return expression(identification,
expression.toValueType(result.getValueClass()), result);
diff --git
a/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureQuery.java
b/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureQuery.java
index 0459d9af4f..0f4bb9e3e7 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureQuery.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureQuery.java
@@ -116,7 +116,7 @@ public class FeatureQuery extends Query implements
Cloneable, Serializable {
* @see #setSelection(Filter)
*/
@SuppressWarnings("serial") // Most SIS implementations
are serializable.
- private Filter<Feature> selection;
+ private Filter<? super Feature> selection;
/**
* The number of feature instances to skip from the beginning.
@@ -197,12 +197,12 @@ public class FeatureQuery extends Query implements
Cloneable, Serializable {
* @throws IllegalArgumentException if a property is duplicated.
*/
@SafeVarargs
- public final void setProjection(final Expression<Feature, ?>...
properties) {
+ public final void setProjection(final Expression<? super Feature, ?>...
properties) {
NamedExpression[] wrappers = null;
if (properties != null) {
wrappers = new NamedExpression[properties.length];
for (int i=0; i<wrappers.length; i++) {
- final Expression<Feature, ?> e = properties[i];
+ final Expression<? super Feature, ?> e = properties[i];
ArgumentChecks.ensureNonNullElement("properties", i, e);
wrappers[i] = new NamedExpression(e);
}
@@ -278,7 +278,7 @@ public class FeatureQuery extends Query implements
Cloneable, Serializable {
*
* @param selection the filter, or {@code null} if none.
*/
- public void setSelection(final Filter<Feature> selection) {
+ public void setSelection(final Filter<? super Feature> selection) {
this.selection = selection;
}
@@ -289,7 +289,7 @@ public class FeatureQuery extends Query implements
Cloneable, Serializable {
*
* @return the filter, or {@code null} if none.
*/
- public Filter<Feature> getSelection() {
+ public Filter<? super Feature> getSelection() {
return selection;
}
@@ -483,7 +483,7 @@ public class FeatureQuery extends Query implements
Cloneable, Serializable {
* Never {@code null}.
*/
@SuppressWarnings("serial")
- public final Expression<Feature,?> expression;
+ public final Expression<? super Feature, ?> expression;
/**
* The name to assign to the expression result, or {@code null} if
unspecified.
@@ -506,7 +506,7 @@ public class FeatureQuery extends Query implements
Cloneable, Serializable {
*
* @param expression the literal, value reference or expression to be
retrieved by a {@code Query}.
*/
- public NamedExpression(final Expression<Feature,?> expression) {
+ public NamedExpression(final Expression<? super Feature, ?>
expression) {
this(expression, (GenericName) null);
}
@@ -516,7 +516,7 @@ public class FeatureQuery extends Query implements
Cloneable, Serializable {
* @param expression the literal, value reference or expression to be
retrieved by a {@code Query}.
* @param alias the name to assign to the expression result, or
{@code null} if unspecified.
*/
- public NamedExpression(final Expression<Feature,?> expression, final
GenericName alias) {
+ public NamedExpression(final Expression<? super Feature,?> expression,
final GenericName alias) {
this(expression, alias, ProjectionType.STORED);
}
@@ -527,7 +527,7 @@ public class FeatureQuery extends Query implements
Cloneable, Serializable {
* @param expression the literal, value reference or expression to be
retrieved by a {@code Query}.
* @param alias the name to assign to the expression result, or
{@code null} if unspecified.
*/
- public NamedExpression(final Expression<Feature,?> expression, final
String alias) {
+ public NamedExpression(final Expression<? super Feature,?> expression,
final String alias) {
ArgumentChecks.ensureNonNull("expression", expression);
this.expression = expression;
this.alias = (alias != null) ? Names.createLocalName(null, null,
alias) : null;
@@ -543,7 +543,7 @@ public class FeatureQuery extends Query implements
Cloneable, Serializable {
*
* @since 1.4
*/
- public NamedExpression(final Expression<Feature,?> expression, final
GenericName alias, ProjectionType type) {
+ public NamedExpression(final Expression<? super Feature,?> expression,
final GenericName alias, ProjectionType type) {
ArgumentChecks.ensureNonNull("expression", expression);
ArgumentChecks.ensureNonNull("type", type);
this.expression = expression;
@@ -687,7 +687,7 @@ public class FeatureQuery extends Query implements
Cloneable, Serializable {
* For each property, get the expected type (mandatory) and its
name (optional).
* A default name will be computed if no alias were explicitly
given by user.
*/
- final Expression<Feature,?> expression = item.expression;
+ final Expression<? super Feature,?> expression = item.expression;
final FeatureExpression<?,?> fex =
FeatureExpression.castOrCopy(expression);
final PropertyTypeBuilder resultType;
if (fex == null || (resultType = fex.expectedType(valueType, ftb))
== null) {
diff --git
a/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSubset.java
b/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSubset.java
index 920c859c43..dc4a9f6992 100644
---
a/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSubset.java
+++
b/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSubset.java
@@ -110,7 +110,7 @@ final class FeatureSubset extends AbstractFeatureSet {
/*
* Apply filter.
*/
- final Filter<Feature> selection = query.getSelection();
+ final Filter<? super Feature> selection = query.getSelection();
if (selection != null && !selection.equals(Filter.include())) {
stream = stream.filter(selection);
}
@@ -142,7 +142,7 @@ final class FeatureSubset extends AbstractFeatureSet {
final FeatureQuery.NamedExpression[] projection =
query.getProjection();
if (projection != null) {
@SuppressWarnings({"unchecked", "rawtypes"})
- final Expression<Feature,?>[] expressions = new
Expression[projection.length];
+ final Expression<? super Feature,?>[] expressions = new
Expression[projection.length];
for (int i=0; i<expressions.length; i++) {
expressions[i] = projection[i].expression;
}