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 fdf44c16053314d6e870823b67f559493561bc39 Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Sat Mar 25 13:37:44 2023 +0100 Add an `AbstractFeatureSet` constructor receiving a `Resource` argument. This is a complement to similar change in `AbstractGridCoverageResource`. This commit contains an incompatible change in the following classes: - org.apache.sis.storage.aggregate.JoinFeatureSet - org.apache.sis.storage.aggregate.ConcatenatedFeatureSet In those two classes, the `StoreListeners` argument in constructor has been replaced by `Resource` argument for easier usage. We expect low impact because those classes are rarely used, and when they are the argument value is almost always null. --- .../org/apache/sis/internal/storage/MemoryFeatureSet.java | 10 +++++----- .../java/org/apache/sis/storage/AbstractFeatureSet.java | 14 +++++++++++++- .../main/java/org/apache/sis/storage/FeatureSubset.java | 4 ++-- .../apache/sis/storage/aggregate/AggregatedFeatureSet.java | 13 ++++++++++++- .../sis/storage/aggregate/ConcatenatedFeatureSet.java | 8 ++++---- .../org/apache/sis/storage/aggregate/JoinFeatureSet.java | 10 +++++----- 6 files changed, 41 insertions(+), 18 deletions(-) diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MemoryFeatureSet.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MemoryFeatureSet.java index fa8a48e24f..4c3a19aae4 100644 --- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MemoryFeatureSet.java +++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MemoryFeatureSet.java @@ -19,8 +19,8 @@ package org.apache.sis.internal.storage; import java.util.Collection; import java.util.OptionalLong; import java.util.stream.Stream; +import org.apache.sis.storage.Resource; import org.apache.sis.storage.AbstractFeatureSet; -import org.apache.sis.storage.event.StoreListeners; import org.apache.sis.util.ArgumentChecks; // Branch-dependent imports @@ -34,7 +34,7 @@ import org.opengis.feature.FeatureType; * * @author Johann Sorel (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 1.2 + * @version 1.4 * @since 1.0 */ public class MemoryFeatureSet extends AbstractFeatureSet { @@ -54,12 +54,12 @@ public class MemoryFeatureSet extends AbstractFeatureSet { * <code>{@linkplain Feature#getType()} == type</code> for all elements in the given collection * (this is not verified). * - * @param parent listeners of the parent resource, or {@code null} if none. + * @param parent the parent resource, or {@code null} if none. * @param type the type of all features in the given collection. * @param features collection of stored features. This collection will not be copied. */ - public MemoryFeatureSet(final StoreListeners parent, final FeatureType type, final Collection<Feature> features) { - super(parent, false); + public MemoryFeatureSet(final Resource parent, final FeatureType type, final Collection<Feature> features) { + super(parent); ArgumentChecks.ensureNonNull("type", type); ArgumentChecks.ensureNonNull("features", features); this.type = type; diff --git a/storage/sis-storage/src/main/java/org/apache/sis/storage/AbstractFeatureSet.java b/storage/sis-storage/src/main/java/org/apache/sis/storage/AbstractFeatureSet.java index a45012e593..b7196fd9f9 100644 --- a/storage/sis-storage/src/main/java/org/apache/sis/storage/AbstractFeatureSet.java +++ b/storage/sis-storage/src/main/java/org/apache/sis/storage/AbstractFeatureSet.java @@ -45,10 +45,22 @@ import org.opengis.feature.FeatureType; * * @author Johann Sorel (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 1.2 + * @version 1.4 * @since 1.2 */ public abstract class AbstractFeatureSet extends AbstractResource implements FeatureSet { + /** + * Creates a new resource, potentially as a child of another resource. + * The parent resource is typically, but not necessarily, an {@link Aggregate}. + * + * @param parent the parent resource, or {@code null} if none. + * + * @since 1.4 + */ + protected AbstractFeatureSet(final Resource parent) { + super(parent); + } + /** * Creates a new resource which can send notifications to the given set of listeners. * If {@code hidden} is {@code false} (the recommended value), then this resource will have its own set of 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 80e2b71ff4..be35261e5c 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 @@ -40,7 +40,7 @@ import org.opengis.filter.SortBy; * * @author Johann Sorel (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 1.3 + * @version 1.4 * @since 1.0 */ final class FeatureSubset extends AbstractFeatureSet { @@ -65,7 +65,7 @@ final class FeatureSubset extends AbstractFeatureSet { * This given query is stored as-is (it is not cloned neither optimized). */ FeatureSubset(final FeatureSet source, final FeatureQuery query) { - super(source instanceof AbstractResource ? ((AbstractResource) source).listeners : null, false); + super(source); this.source = source; this.query = query; } diff --git a/storage/sis-storage/src/main/java/org/apache/sis/storage/aggregate/AggregatedFeatureSet.java b/storage/sis-storage/src/main/java/org/apache/sis/storage/aggregate/AggregatedFeatureSet.java index 487b1db342..6f6450f292 100644 --- a/storage/sis-storage/src/main/java/org/apache/sis/storage/aggregate/AggregatedFeatureSet.java +++ b/storage/sis-storage/src/main/java/org/apache/sis/storage/aggregate/AggregatedFeatureSet.java @@ -26,6 +26,7 @@ import org.opengis.metadata.maintenance.ScopeCode; import org.opengis.referencing.operation.TransformException; import org.apache.sis.geometry.ImmutableEnvelope; import org.apache.sis.geometry.Envelopes; +import org.apache.sis.storage.Resource; import org.apache.sis.storage.FeatureSet; import org.apache.sis.storage.DataStoreException; import org.apache.sis.storage.event.StoreListeners; @@ -45,7 +46,7 @@ import org.opengis.feature.FeatureType; * Subclasses need to implement {@link #dependencies()}.</p> * * @author Martin Desruisseaux (Geomatys) - * @version 1.2 + * @version 1.4 * @since 1.0 */ abstract class AggregatedFeatureSet extends AbstractFeatureSet { @@ -61,6 +62,16 @@ abstract class AggregatedFeatureSet extends AbstractFeatureSet { */ private boolean isEnvelopeComputed; + /** + * Creates a new aggregated feature set. + * + * @param parent the parent resource, or {@code null} if none. + * This is usually the {@link org.apache.sis.storage.DataStore} that created this resource. + */ + protected AggregatedFeatureSet(final Resource parent) { + super(parent); + } + /** * Creates a new aggregated feature set. * diff --git a/storage/sis-storage/src/main/java/org/apache/sis/storage/aggregate/ConcatenatedFeatureSet.java b/storage/sis-storage/src/main/java/org/apache/sis/storage/aggregate/ConcatenatedFeatureSet.java index 97390dd7ed..cc9f56d6e3 100644 --- a/storage/sis-storage/src/main/java/org/apache/sis/storage/aggregate/ConcatenatedFeatureSet.java +++ b/storage/sis-storage/src/main/java/org/apache/sis/storage/aggregate/ConcatenatedFeatureSet.java @@ -32,8 +32,8 @@ import org.apache.sis.internal.util.CollectionsExt; import org.apache.sis.internal.util.UnmodifiableArrayList; import org.apache.sis.internal.storage.Resources; import org.apache.sis.storage.AbstractFeatureSet; -import org.apache.sis.storage.event.StoreListeners; import org.apache.sis.storage.Query; +import org.apache.sis.storage.Resource; // Branch-dependent imports import org.opengis.feature.Feature; @@ -57,7 +57,7 @@ import org.opengis.feature.FeatureType; * * @author Alexis Manin (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 1.2 + * @version 1.4 * @since 1.0 */ public class ConcatenatedFeatureSet extends AggregatedFeatureSet { @@ -87,12 +87,12 @@ public class ConcatenatedFeatureSet extends AggregatedFeatureSet { * this verification must be done by the caller. This constructor retains the given {@code sources} array * by direct reference; clone, if desired, shall be done by the caller. * - * @param parent listeners of the parent resource, or {@code null} if none. + * @param parent the parent resource, or {@code null} if none. * @param sources the sequence of feature sets to expose in a single set. * Must neither be null, empty nor contain a single element only. * @throws DataStoreException if given feature sets does not share any common type. */ - protected ConcatenatedFeatureSet(final StoreListeners parent, final FeatureSet[] sources) throws DataStoreException { + protected ConcatenatedFeatureSet(final Resource parent, final FeatureSet[] sources) throws DataStoreException { super(parent); for (int i=0; i<sources.length; i++) { ArgumentChecks.ensureNonNullElement("sources", i, sources[i]); diff --git a/storage/sis-storage/src/main/java/org/apache/sis/storage/aggregate/JoinFeatureSet.java b/storage/sis-storage/src/main/java/org/apache/sis/storage/aggregate/JoinFeatureSet.java index 90e06f4e4c..898e02089e 100644 --- a/storage/sis-storage/src/main/java/org/apache/sis/storage/aggregate/JoinFeatureSet.java +++ b/storage/sis-storage/src/main/java/org/apache/sis/storage/aggregate/JoinFeatureSet.java @@ -28,10 +28,10 @@ import org.apache.sis.feature.FeatureOperations; import org.apache.sis.feature.DefaultFeatureType; import org.apache.sis.feature.DefaultAssociationRole; import org.apache.sis.internal.feature.AttributeConvention; -import org.apache.sis.storage.FeatureQuery; +import org.apache.sis.storage.Resource; import org.apache.sis.storage.FeatureSet; +import org.apache.sis.storage.FeatureQuery; import org.apache.sis.storage.DataStoreException; -import org.apache.sis.storage.event.StoreListeners; import org.apache.sis.util.ArraysExt; import org.apache.sis.util.collection.BackingStoreException; import org.apache.sis.util.collection.Containers; @@ -69,7 +69,7 @@ import org.apache.sis.filter.DefaultFilterFactory; * * @author Johann Sorel (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 1.1 + * @version 1.4 * @since 1.0 */ public class JoinFeatureSet extends AggregatedFeatureSet { @@ -195,7 +195,7 @@ public class JoinFeatureSet extends AggregatedFeatureSet { * <li>{@code "identifierSuffix"} — string to insert at the end of join identifiers (optional).</li> * </ul> * - * @param parent listeners of the parent resource, or {@code null} if none. + * @param parent the parent resource, or {@code null} if none. * @param left the first source of features. This is often (but not necessarily) the largest set. * @param leftAlias name of the associations to the {@code left} features, or {@code null} for a default name. * @param right the second source of features. Should be the set in which iterations are cheapest. @@ -205,7 +205,7 @@ public class JoinFeatureSet extends AggregatedFeatureSet { * @param featureInfo information about the {@link FeatureType} of this feature set. * @throws DataStoreException if an error occurred while creating the feature set. */ - public JoinFeatureSet(final StoreListeners parent, + public JoinFeatureSet(final Resource parent, final FeatureSet left, String leftAlias, final FeatureSet right, String rightAlias, final Type joinType, final BinaryComparisonOperator<? super Feature> condition,