public class SharedFeatures extends Object implements NamedProvider<Feature<FeatureInput>>, Iterable<NameValue<Feature<FeatureInput>>>
The features may have heterogeneous feature input-type, and are therefore stored with FeatureInput
input-type, as this is the parent type for all feature-inputs.
This is the principle class for storing all available shared-features.
Constructor and Description |
---|
SharedFeatures()
Create empty, without any features.
|
Modifier and Type | Method and Description |
---|---|
void |
addFromList(FeatureList<FeatureInput> list)
Add features from a feature-list.
|
void |
addFromProviders(NamedProvider<FeatureList<FeatureInput>> provider)
Add features from a
NamedProvider of feature-lists. |
boolean |
contains(Feature<FeatureInput> feature)
Whether a particular feature is contained in this instance.
|
SharedFeatures |
duplicate()
A deep copy of the current instance.
|
Optional<Feature<FeatureInput>> |
getOptional(String key)
Retrieves the item if it exists, or returns
Optional.empty() if it doesn't exist. |
Iterator<NameValue<Feature<FeatureInput>>> |
iterator() |
Set<String> |
keys()
Returns a set of keys associated with the provider.
|
void |
removeIfExists(FeatureList<FeatureInput> featuresToRemove)
Remove all features, if they currently exist, from
features . |
<S extends FeatureInput> |
subsetCompatibleWith(Class<? extends FeatureInput> inputType)
Extracts the subset of inputs that are compatible with a particular input-type.
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getArbitraryElement, getException, isEmpty
forEach, spliterator
public <S extends FeatureInput> SharedFeaturesSubset<S> subsetCompatibleWith(Class<? extends FeatureInput> inputType)
inputType
- the class of input-type which we search for features to be compatible with.SharedFeaturesSubset
containing only the features considered compatible
with inputType
.public boolean contains(Feature<FeatureInput> feature)
This is checked in constant average-case lookup time.
feature
- the feature to check.public SharedFeatures duplicate()
public void addFromProviders(NamedProvider<FeatureList<FeatureInput>> provider)
NamedProvider
of feature-lists.
Each Feature
is added directly (without duplication).
provider
- the provider to add features from.public void addFromList(FeatureList<FeatureInput> list)
Each Feature
is added directly (without duplication).
list
- the list to add features from.public void removeIfExists(FeatureList<FeatureInput> featuresToRemove)
features
.featuresToRemove
- a list of features to remove.public Iterator<NameValue<Feature<FeatureInput>>> iterator()
iterator
in interface Iterable<NameValue<Feature<FeatureInput>>>
public Optional<Feature<FeatureInput>> getOptional(String key)
NamedProvider
Optional.empty()
if it doesn't exist.
Note that a 'key' might still throw an exception for another reason (but never because a particular key is absent).
getOptional
in interface NamedProvider<Feature<FeatureInput>>
key
- a unique name for the item.Optional.empty()
.public Set<String> keys()
NamedProvider
There's no guarantee that it refers to all valid keys.
keys
in interface NamedProvider<Feature<FeatureInput>>
Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.