sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jso...@apache.org
Subject svn commit: r1824217 - in /sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis: internal/storage/ storage/
Date Wed, 14 Feb 2018 10:37:11 GMT
Author: jsorel
Date: Wed Feb 14 10:37:11 2018
New Revision: 1824217

URL: http://svn.apache.org/viewvc?rev=1824217&view=rev
Log:
Storage : split Aggregate/FeatureSet in read/write interfaces, add FileSystemResource and
Transaction

Added:
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ResourceTransaction.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/TransactionalResource.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/WritableAggregate.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/WritableFeatureSet.java
Modified:
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/Aggregate.java
    sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSet.java

Added: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ResourceTransaction.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ResourceTransaction.java?rev=1824217&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ResourceTransaction.java
(added)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ResourceTransaction.java
Wed Feb 14 10:37:11 2018
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.storage;
+
+import org.apache.sis.storage.Aggregate;
+import org.apache.sis.storage.DataStoreException;
+import org.apache.sis.storage.Resource;
+
+/**
+ * A transaction resource.
+ * This transaction include both this resource and all children resources
+ * if it is an {@linkplain Aggregate}.
+ *
+ * @author Johann Sorel (Geomatys)
+ * @since 1.0
+ * @module
+ */
+public interface ResourceTransaction extends Resource {
+
+    /**
+     * Apply all the changes made in this transaction.
+     *
+     * @throws DataStoreException
+     */
+    void commit() throws DataStoreException;
+
+    /**
+     * Revert all changes made in this session.
+     *
+     * @throws DataStoreException
+     */
+    void rollback() throws DataStoreException;
+
+}

Added: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/TransactionalResource.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/TransactionalResource.java?rev=1824217&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/TransactionalResource.java
(added)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/TransactionalResource.java
Wed Feb 14 10:37:11 2018
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.storage;
+
+import org.apache.sis.storage.DataStoreException;
+import org.apache.sis.storage.Resource;
+
+/**
+ * This interface identify resources which support a transactional procedure.
+ * Example : Databases, WFS
+ *
+ * @author Johann Sorel (Geomatys)
+ * @since 1.0
+ * @module
+ */
+public interface TransactionalResource extends Resource {
+
+    /**
+     * Start a new transaction on this resource.
+     * The returned resource should have the same capabilities of this
+     * resource and writing capabilities.
+     *
+     * @return new TransactionResource
+     * @throws org.apache.sis.storage.DataStoreException
+     */
+    ResourceTransaction newTransaction() throws DataStoreException;
+
+}

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/Aggregate.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/Aggregate.java?rev=1824217&r1=1824216&r2=1824217&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/Aggregate.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/Aggregate.java
[UTF-8] Wed Feb 14 10:37:11 2018
@@ -17,10 +17,6 @@
 package org.apache.sis.storage;
 
 import java.util.Collection;
-import org.opengis.metadata.Metadata;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.internal.storage.Resources;
-
 
 /**
  * A collection of resources. An aggregate can have two or more components.
@@ -91,52 +87,4 @@ public interface Aggregate extends Resou
      */
     Collection<Resource> components() throws DataStoreException;
 
-    /**
-     * Adds a new {@code Resource} in this {@code Aggregate}.
-     * The given {@link Resource} will be copied, and the <cite>effectively added</cite>
resource returned.
-     * The effectively added resource may differ from the given resource in many aspects.
-     * The possible changes may include the followings but not only:
-     * <ul>
-     *  <li>types and properties names</li>
-     *  <li>{@link CoordinateReferenceSystem}</li>
-     *  <li>{@link Metadata}</li>
-     * </ul>
-     *
-     * <div class="note"><b>Warning:</b>
-     * copying informations between stores may produce differences in many aspects.
-     * The range of changes depends both on the original {@link Resource} structure
-     * and the target {@code Resource} structure. If the differences are too large,
-     * then this {@code Aggregate} may throw an exception.
-     * </div>
-     *
-     * <p>The {@link Capability#WRITABLE} flag if present in the {@link Resource#getCapabilities()
} set
-     * indicate this method should be implemented</p>
-     *
-     * <p>The default implementation throws {@link ReadOnlyStorageException}.</p>
-     *
-     * @param  resource  the resource to copy in this {@code Aggregate}.
-     * @return the effectively added resource. May be {@code resource} itself if it has been
added verbatim.
-     * @throws ReadOnlyStorageException if this instance does not support write operations.
-     * @throws DataStoreException if the given resource can not be stored in this {@code
Aggregate} for another reason.
-     */
-    default Resource add(Resource resource) throws ReadOnlyStorageException, DataStoreException
{
-        throw new ReadOnlyStorageException(this, Resources.Keys.StoreIsReadOnly);
-    }
-
-    /**
-     * Removes a {@code Resource} from this {@code Aggregate}.
-     * This operation is destructive: the {@link Resource} and it's related data will be
removed.
-     *
-     * <p>The {@link Capability#WRITABLE} flag if present in the {@link Resource#getCapabilities()
} set
-     * indicate this method should be implemented</p>
-     *
-     * <p>The default implementation throws {@link ReadOnlyStorageException}.</p>
-     *
-     * @param  resource  child resource to remove, should not be null.
-     * @throws ReadOnlyStorageException if this instance does not support write operations.
-     * @throws DataStoreException if the given resource could not be removed for another
reason.
-     */
-    default void remove(Resource resource) throws ReadOnlyStorageException, DataStoreException
{
-        throw new ReadOnlyStorageException(this, Resources.Keys.StoreIsReadOnly);
-    }
 }

Modified: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSet.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSet.java?rev=1824217&r1=1824216&r2=1824217&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSet.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSet.java
[UTF-8] Wed Feb 14 10:37:11 2018
@@ -16,12 +16,7 @@
  */
 package org.apache.sis.storage;
 
-import java.util.Iterator;
-import org.apache.sis.internal.storage.Resources;
-
 // Branch-dependent imports
-import java.util.function.Predicate;
-import java.util.function.UnaryOperator;
 import java.util.stream.Stream;
 import org.opengis.feature.Feature;
 import org.opengis.feature.FeatureType;
@@ -75,33 +70,6 @@ public interface FeatureSet extends Data
     FeatureType getType() throws DataStoreException;
 
     /**
-     * Redefine the feature type of this feature set, including all features.
-     * This operation may take an undefined time since all features in the set must be transformed.
-     *
-     * <p>
-     * An {@linkplain  org.apache.sis.storage.IllegalFeatureTypeException} will be throw
-     * when the provided type contains incompatible attribute changes.
-     * </p>
-     *
-     * <p>
-     * In the case of a newly created feature set, this method can be used to define
-     * stored feature type.
-     * </p>
-     *
-     * <p>
-     * Default implementation throw a {@linkplain  org.apache.sis.storage.ReadOnlyStorageException}.
-     * </p>
-     *
-     * @param newType new feature type definition, (not {@code null}).
-     * @throws ReadOnlyStorageException if this instance does not support schema update
-     * @throws IllegalFeatureTypeException if the given type is not compatible
-     * @throws DataStoreException if another error occurred while changing feature type.
-     */
-    default void updateType(FeatureType newType) throws ReadOnlyStorageException, IllegalFeatureTypeException,
DataStoreException {
-        throw new ReadOnlyStorageException(this, Resources.Keys.StoreIsReadOnly);
-    }
-
-    /**
      * Requests a subset of features and feature properties from this resource.
      * The filtering can be applied in two domains:
      *
@@ -168,71 +136,4 @@ public interface FeatureSet extends Data
      */
     Stream<Feature> features(boolean parallel) throws DataStoreException;
 
-    /**
-     * Inserts new features in this {@code FeatureSet}.
-     * Any feature already present in the {@link FeatureSet} will remain unmodified.
-     *
-     * <div class="note"><b>API note:</b>
-     * this method expects an {@link Iterator} rather then a {@link java.util.stream.Stream}
for easing
-     * inter-operability with various API. Implementing a custom {@link Iterator} requires
less effort
-     * than implementing a {@link Stream}. On the other side if the user has a {@link Stream},
-     * obtaining an {@link Iterator} can be done by a call to {@link Stream#iterator()}.</div>
-     *
-     * <p>The {@link Capability#WRITABLE} flag if present in the {@link Resource#getCapabilities()
} set
-     * indicate this method should be implemented</p>
-     *
-     * <p>The default implementation throws {@link ReadOnlyStorageException}.</p>
-     *
-     * @param  features features to insert in this {@code FeatureSet}.
-     * @throws ReadOnlyStorageException if this instance does not support write operations.
-     * @throws DataStoreException if another error occurred while storing new features.
-     */
-    default void add(Iterator<? extends Feature> features) throws ReadOnlyStorageException,
DataStoreException {
-        throw new ReadOnlyStorageException(this, Resources.Keys.StoreIsReadOnly);
-    }
-
-    /**
-     * Removes all features from this {@code FeatureSet} which matches the given predicate.
-     *
-     * <p>The {@link Capability#WRITABLE} flag if present in the {@link Resource#getCapabilities()
} set
-     * indicate this method should be implemented</p>
-     *
-     * <p>The default implementation throws {@link ReadOnlyStorageException}.</p>
-     *
-     * @param  filter  a predicate which returns true for resources to be removed.
-     * @return {@code true} if any elements were removed.
-     * @throws ReadOnlyStorageException if this instance does not support write operations.
-     * @throws DataStoreException if another error occurred while removing features.
-     */
-    default boolean removeIf(Predicate<? super Feature> filter) throws ReadOnlyStorageException,
DataStoreException {
-        throw new ReadOnlyStorageException(this, Resources.Keys.StoreIsReadOnly);
-    }
-
-    /**
-     * Updates all features from this {@code FeatureSet} which matches the given predicate.
-     * For each {@link Feature} instance matching the given {@link Predicate},
-     * the <code>{@linkplain UnaryOperator#apply UnaryOperator.apply(Feature)}</code>
method will be invoked.
-     * {@code UnaryOperator}s are free to modify the given {@code Feature} <i>in-place</i>
or to return a
-     * different feature instance. Two behaviors are possible:
-     * <ul>
-     *   <li>If the operator returns a non-null {@link Feature}, then the modified
feature is stored
-     *       in replacement of the previous feature (not necessarily at the same location).</li>
-     *   <li>If the operator returns {@code null}, then the feature will be removed
from the {@code FeatureSet}.</li>
-     * </ul>
-     *
-     * <p>The {@link Capability#WRITABLE} flag if present in the {@link Resource#getCapabilities()
} set
-     * indicate this method should be implemented</p>
-     *
-     * <p>The default implementation throws {@link ReadOnlyStorageException}.</p>
-     *
-     * @param  filter   a predicate which returns true for resources to be updated.
-     * @param  updater  operation called for each matching {@link Feature}.
-     * @throws ReadOnlyStorageException if this instance does not support write operations.
-     * @throws DataStoreException if another error occurred while replacing features.
-     */
-    default void replaceIf(Predicate<? super Feature> filter, UnaryOperator<Feature>
updater)
-            throws ReadOnlyStorageException, DataStoreException
-    {
-        throw new ReadOnlyStorageException(this, Resources.Keys.StoreIsReadOnly);
-    }
 }

Added: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/WritableAggregate.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/WritableAggregate.java?rev=1824217&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/WritableAggregate.java
(added)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/WritableAggregate.java
Wed Feb 14 10:37:11 2018
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.storage;
+
+import org.apache.sis.internal.storage.Resources;
+
+/**
+ * Subtype of {@linkplain Aggregate} with writing capabilities.
+ *
+ * @author Johann Sorel (Geomatys)
+ * @version 1.0
+ * @since   1.0
+ * @module
+ */
+public interface WritableAggregate extends Aggregate {
+
+    /**
+     * Adds a new {@code Resource} in this {@code Aggregate}.
+     * The given {@link Resource} will be copied, and the <cite>effectively added</cite>
resource returned.
+     * The effectively added resource may differ from the given resource in many aspects.
+     * The possible changes may include the followings but not only:
+     * <ul>
+     *  <li>types and properties names</li>
+     *  <li>{@link CoordinateReferenceSystem}</li>
+     *  <li>{@link Metadata}</li>
+     * </ul>
+     *
+     * <div class="note"><b>Warning:</b>
+     * copying informations between stores may produce differences in many aspects.
+     * The range of changes depends both on the original {@link Resource} structure
+     * and the target {@code Resource} structure. If the differences are too large,
+     * then this {@code Aggregate} may throw an exception.
+     * </div>
+     *
+     * <p>The {@link Capability#WRITABLE} flag if present in the {@link Resource#getCapabilities()
} set
+     * indicate this method should be implemented</p>
+     *
+     * <p>The default implementation throws {@link ReadOnlyStorageException}.</p>
+     *
+     * @param  resource  the resource to copy in this {@code Aggregate}.
+     * @return the effectively added resource. May be {@code resource} itself if it has been
added verbatim.
+     * @throws ReadOnlyStorageException if this instance does not support write operations.
+     * @throws DataStoreException if the given resource can not be stored in this {@code
Aggregate} for another reason.
+     */
+    default Resource add(Resource resource) throws ReadOnlyStorageException, DataStoreException
{
+        throw new ReadOnlyStorageException(this, Resources.Keys.StoreIsReadOnly);
+    }
+
+    /**
+     * Removes a {@code Resource} from this {@code Aggregate}.
+     * This operation is destructive: the {@link Resource} and it's related data will be
removed.
+     *
+     * <p>The {@link Capability#WRITABLE} flag if present in the {@link Resource#getCapabilities()
} set
+     * indicate this method should be implemented</p>
+     *
+     * <p>The default implementation throws {@link ReadOnlyStorageException}.</p>
+     *
+     * @param  resource  child resource to remove, should not be null.
+     * @throws ReadOnlyStorageException if this instance does not support write operations.
+     * @throws DataStoreException if the given resource could not be removed for another
reason.
+     */
+    default void remove(Resource resource) throws ReadOnlyStorageException, DataStoreException
{
+        throw new ReadOnlyStorageException(this, Resources.Keys.StoreIsReadOnly);
+    }
+
+}

Added: sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/WritableFeatureSet.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/WritableFeatureSet.java?rev=1824217&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/WritableFeatureSet.java
(added)
+++ sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/WritableFeatureSet.java
Wed Feb 14 10:37:11 2018
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.storage;
+
+import java.util.Iterator;
+import java.util.function.Predicate;
+import java.util.function.UnaryOperator;
+import org.apache.sis.internal.storage.Resources;
+import org.opengis.feature.Feature;
+import org.opengis.feature.FeatureType;
+
+/**
+ * Subtype of {@linkplain FeatureSet} with writing capabilities.
+ *
+ * @author Johann Sorel (Geomatys)
+ * @version 1.0
+ * @since   1.0
+ * @module
+ */
+public interface WritableFeatureSet extends FeatureSet {
+
+    /**
+     * Redefine the feature type of this feature set, including all features.
+     * This operation may take an undefined time since all features in the set must be transformed.
+     *
+     * <p>
+     * An {@linkplain  org.apache.sis.storage.IllegalFeatureTypeException} will be throw
+     * when the provided type contains incompatible attribute changes.
+     * </p>
+     *
+     * <p>
+     * In the case of a newly created feature set, this method can be used to define
+     * stored feature type.
+     * </p>
+     *
+     * <p>
+     * Default implementation throw a {@linkplain  org.apache.sis.storage.ReadOnlyStorageException}.
+     * </p>
+     *
+     * @param newType new feature type definition, (not {@code null}).
+     * @throws ReadOnlyStorageException if this instance does not support schema update
+     * @throws IllegalFeatureTypeException if the given type is not compatible
+     * @throws DataStoreException if another error occurred while changing feature type.
+     */
+    default void updateType(FeatureType newType) throws ReadOnlyStorageException, IllegalFeatureTypeException,
DataStoreException {
+        throw new ReadOnlyStorageException(this, Resources.Keys.StoreIsReadOnly);
+    }
+
+    /**
+     * Inserts new features in this {@code FeatureSet}.
+     * Any feature already present in the {@link FeatureSet} will remain unmodified.
+     *
+     * <div class="note"><b>API note:</b>
+     * this method expects an {@link Iterator} rather then a {@link java.util.stream.Stream}
for easing
+     * inter-operability with various API. Implementing a custom {@link Iterator} requires
less effort
+     * than implementing a {@link Stream}. On the other side if the user has a {@link Stream},
+     * obtaining an {@link Iterator} can be done by a call to {@link Stream#iterator()}.</div>
+     *
+     * <p>The {@link Capability#WRITABLE} flag if present in the {@link Resource#getCapabilities()
} set
+     * indicate this method should be implemented</p>
+     *
+     * <p>The default implementation throws {@link ReadOnlyStorageException}.</p>
+     *
+     * @param  features features to insert in this {@code FeatureSet}.
+     * @throws ReadOnlyStorageException if this instance does not support write operations.
+     * @throws DataStoreException if another error occurred while storing new features.
+     */
+    default void add(Iterator<? extends Feature> features) throws ReadOnlyStorageException,
DataStoreException {
+        throw new ReadOnlyStorageException(this, Resources.Keys.StoreIsReadOnly);
+    }
+
+    /**
+     * Removes all features from this {@code FeatureSet} which matches the given predicate.
+     *
+     * <p>The {@link Capability#WRITABLE} flag if present in the {@link Resource#getCapabilities()
} set
+     * indicate this method should be implemented</p>
+     *
+     * <p>The default implementation throws {@link ReadOnlyStorageException}.</p>
+     *
+     * @param  filter  a predicate which returns true for resources to be removed.
+     * @return {@code true} if any elements were removed.
+     * @throws ReadOnlyStorageException if this instance does not support write operations.
+     * @throws DataStoreException if another error occurred while removing features.
+     */
+    default boolean removeIf(Predicate<? super Feature> filter) throws ReadOnlyStorageException,
DataStoreException {
+        throw new ReadOnlyStorageException(this, Resources.Keys.StoreIsReadOnly);
+    }
+
+    /**
+     * Updates all features from this {@code FeatureSet} which matches the given predicate.
+     * For each {@link Feature} instance matching the given {@link Predicate},
+     * the <code>{@linkplain UnaryOperator#apply UnaryOperator.apply(Feature)}</code>
method will be invoked.
+     * {@code UnaryOperator}s are free to modify the given {@code Feature} <i>in-place</i>
or to return a
+     * different feature instance. Two behaviors are possible:
+     * <ul>
+     *   <li>If the operator returns a non-null {@link Feature}, then the modified
feature is stored
+     *       in replacement of the previous feature (not necessarily at the same location).</li>
+     *   <li>If the operator returns {@code null}, then the feature will be removed
from the {@code FeatureSet}.</li>
+     * </ul>
+     *
+     * <p>The {@link Capability#WRITABLE} flag if present in the {@link Resource#getCapabilities()
} set
+     * indicate this method should be implemented</p>
+     *
+     * <p>The default implementation throws {@link ReadOnlyStorageException}.</p>
+     *
+     * @param  filter   a predicate which returns true for resources to be updated.
+     * @param  updater  operation called for each matching {@link Feature}.
+     * @throws ReadOnlyStorageException if this instance does not support write operations.
+     * @throws DataStoreException if another error occurred while replacing features.
+     */
+    default void replaceIf(Predicate<? super Feature> filter, UnaryOperator<Feature>
updater)
+            throws ReadOnlyStorageException, DataStoreException
+    {
+        throw new ReadOnlyStorageException(this, Resources.Keys.StoreIsReadOnly);
+    }
+}



Mime
View raw message