- All Superinterfaces:
DataSet
,FeatureSet
,Resource
A
FeatureSet
with writing capabilities. WritableFeatureSet
inherits the reading capabilities from
its parent and adds the capabilities to add, remove
or replace feature instances.- Since:
- 1.0
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(Iterator<? extends AbstractFeature> features) Inserts new feature instances in thisFeatureSet
.void
removeIf
(Predicate<? super AbstractFeature> filter) Removes all feature instances from thisFeatureSet
which matches the given predicate.void
replaceIf
(Predicate<? super AbstractFeature> filter, UnaryOperator<AbstractFeature> updater) Updates all feature instances from thisFeatureSet
which match the given predicate.void
updateType
(DefaultFeatureType newType) Declares or redefines the type of all feature instances in this feature set.Methods inherited from interface DataSet
getEnvelope
Methods inherited from interface FeatureSet
features, getType, subset
Methods inherited from interface Resource
addListener, getIdentifier, getMetadata, removeListener
-
Method Details
-
updateType
Declares or redefines the type of all feature instances in this feature set. In the case of a newly created feature set, this method can be used for defining the type of features to be stored (this is not a required step however). In the case of a feature set which already contains feature instances, this operation may take an undefined amount of time to execute since all features in the set may need to be transformed.Feature sets may restrict the kind of changes that are allowed. An
IllegalFeatureTypeException
will be thrown if the given type contains incompatible property changes.- Parameters:
newType
- new feature type definition (notnull
).- Throws:
IllegalFeatureTypeException
- if the given type is not compatible with the types supported by the store.DataStoreException
- if another error occurred while changing the feature type.
-
add
Inserts new feature instances in thisFeatureSet
. Any feature already present in thisFeatureSet
will remain unmodified. If a feature property is used as unique identifier, then:- If a given feature assigns to that property a value already in use, an exception will be thrown.
- If given features do not assign value to that property, identifiers should be generated by the data store.
DataStore
specific.API note
This method expects anIterator
rather than aStream
for easing inter-operability with various API. Implementing a customIterator
requires less effort than implementing aStream
. On the other side if the user has aStream
, obtaining anIterator
can be done by a call toBaseStream.iterator()
.- Parameters:
features
- feature instances to insert or copy in thisFeatureSet
.- Throws:
IllegalFeatureTypeException
- if a feature given by the iterator is not of the type expected by thisFeatureSet
.DataStoreException
- if another error occurred while storing new features.
-
removeIf
Removes all feature instances from thisFeatureSet
which matches the given predicate.- Parameters:
filter
- a predicate which returnstrue
for feature instances to be removed.- Throws:
DataStoreException
- if an error occurred while removing features.
-
replaceIf
void replaceIf(Predicate<? super AbstractFeature> filter, UnaryOperator<AbstractFeature> updater) throws DataStoreException Updates all feature instances from thisFeatureSet
which match the given predicate. For eachFeature
instance matching the givenPredicate
, theUnaryOperator.apply(Feature)
method will be invoked.UnaryOperator
s are free to modify the givenFeature
in-place or to return a different feature instance. Two behaviors are possible:- If the operator returns a non-null
Feature
, then the modified feature is stored in replacement of the previous feature (not necessarily at the same location). - If the operator returns
null
, then the feature will be removed from theFeatureSet
.
- Parameters:
filter
- a predicate which returnstrue
for feature instances to be updated.updater
- operation called for each matchingFeature
instance.- Throws:
IllegalFeatureTypeException
- if a feature given by the operator is not of the type expected by thisFeatureSet
.DataStoreException
- if another error occurred while replacing features.
- If the operator returns a non-null
-