Interface WritableFeatureSet

All Superinterfaces:
Data­Set, Feature­Set, Resource

public interface WritableFeatureSet extends FeatureSet
A Feature­Set with writing capabilities. Writable­Feature­Set inherits the reading capabilities from its parent and adds the capabilities to add, remove or replace feature instances.
Since:
1.0

Defined in the sis-storage module

  • Method Details

    • updateType

      void updateType(DefaultFeatureType newType) throws DataStoreException
      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 Illegal­Feature­Type­Exception will be thrown if the given type contains incompatible property changes.

      Parameters:
      new­Type - new feature type definition (not null).
      Throws:
      Illegal­Feature­Type­Exception - if the given type is not compatible with the types supported by the store.
      Data­Store­Exception - if another error occurred while changing the feature type.
    • add

      void add(Iterator<? extends AbstractFeature> features) throws DataStoreException
      Inserts new feature instances in this Feature­Set. Any feature already present in this Feature­Set 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.
      After successful insertion, the new features may appear after the features already present but not necessarily; ordering is Data­Store specific.
      API note: this method expects an Iterator rather than a Stream for easing inter-operability with various API. Implementing a custom Iterator requires less effort than implementing a Stream. On the other side if the user has a Stream, obtaining an Iterator can be done by a call to Base­Stream​.iterator().
      Parameters:
      features - feature instances to insert or copy in this Feature­Set.
      Throws:
      Illegal­Feature­Type­Exception - if a feature given by the iterator is not of the type expected by this Feature­Set.
      Data­Store­Exception - if another error occurred while storing new features.
    • removeIf

      boolean removeIf(Predicate<? super AbstractFeature> filter) throws DataStoreException
      Removes all feature instances from this Feature­Set which matches the given predicate.
      Possible API change: The boolean return type may be removed in a future version. It currently exists for compatibility with the Collection​.remove­If(Predicate) method if an implementation chooses to implements Writable­Feature­Set and Collection in same time. But this is not recommended, and the current method signature is a blocker for deferred method execution. Telling if there is any feature to remove requires immediate execution of the filter, while an implementation may want to wait in case the filtering can be combined with other operations such as add(…) or replace­If(…). See SIS-560 on issue tracker.
      Parameters:
      filter - a predicate which returns true for feature instances to be removed.
      Returns:
      true if any elements were removed.
      Throws:
      Data­Store­Exception - if an error occurred while removing features.
    • replaceIf

      void replaceIf(Predicate<? super AbstractFeature> filter, UnaryOperator<AbstractFeature> updater) throws DataStoreException
      Updates all feature instances from this Feature­Set which match the given predicate. For each Feature instance matching the given Predicate, the Unary­Operator​.apply(Feature) method will be invoked. Unary­Operators are free to modify the given Feature 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 the Feature­Set.
      Parameters:
      filter - a predicate which returns true for feature instances to be updated.
      updater - operation called for each matching Feature instance.
      Throws:
      Illegal­Feature­Type­Exception - if a feature given by the operator is not of the type expected by this Feature­Set.
      Data­Store­Exception - if another error occurred while replacing features.