Class SharedFeatures
Object
SharedFeatures
- All Implemented Interfaces:
Iterable<NameValue<Feature<FeatureInput>>>
,NamedProvider<Feature<FeatureInput>>
public class SharedFeatures
extends Object
implements NamedProvider<Feature<FeatureInput>>, Iterable<NameValue<Feature<FeatureInput>>>
A group of features made available to other features to reference.
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.
- Author:
- Owen Feehan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addFromList
(FeatureList<FeatureInput> list) Add features from a feature-list.void
addFromProviders
(NamedProvider<FeatureList<FeatureInput>> provider) Add features from aNamedProvider
of feature-lists.boolean
contains
(Feature<FeatureInput> feature) Whether a particular feature is contained in this instance.A deep copy of the current instance.getOptional
(String key) Retrieves the item if it exists, or returnsOptional.empty()
if it doesn't exist.iterator()
keys()
Returns a set of keys associated with the provider.void
removeIfExists
(FeatureList<FeatureInput> featuresToRemove) Remove all features, if they currently exist, fromfeatures
.<S extends FeatureInput>
SharedFeaturesSubset<S> subsetCompatibleWith
(Class<? extends FeatureInput> inputType) Extracts the subset of inputs that are compatible with a particular input-type.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface org.anchoranalysis.core.identifier.provider.NamedProvider
getArbitraryElement, getException, isEmpty
-
Constructor Details
-
SharedFeatures
public SharedFeatures()Create empty, without any features.
-
-
Method Details
-
subsetCompatibleWith
public <S extends FeatureInput> SharedFeaturesSubset<S> subsetCompatibleWith(Class<? extends FeatureInput> inputType) Extracts the subset of inputs that are compatible with a particular input-type.- Parameters:
inputType
- the class of input-type which we search for features to be compatible with.- Returns:
- a new
SharedFeaturesSubset
containing only the features considered compatible withinputType
.
-
toString
-
contains
Whether a particular feature is contained in this instance.This is checked in constant average-case lookup time.
- Parameters:
feature
- the feature to check.- Returns:
- true if the feature is contained, false otherwise.
-
duplicate
A deep copy of the current instance.- Returns:
- a deep copy.
-
addFromProviders
Add features from aNamedProvider
of feature-lists.Each
Feature
is added directly (without duplication).- Parameters:
provider
- the provider to add features from.
-
addFromList
Add features from a feature-list.Each
Feature
is added directly (without duplication).- Parameters:
list
- the list to add features from.
-
removeIfExists
Remove all features, if they currently exist, fromfeatures
.- Parameters:
featuresToRemove
- a list of features to remove.
-
iterator
- Specified by:
iterator
in interfaceIterable<NameValue<Feature<FeatureInput>>>
-
getOptional
Description copied from interface:NamedProvider
Retrieves the item if it exists, or returnsOptional.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).
- Specified by:
getOptional
in interfaceNamedProvider<Feature<FeatureInput>>
- Parameters:
key
- a unique name for the item.- Returns:
- the item, if it exists, otherwise
Optional.empty()
.
-
keys
Description copied from interface:NamedProvider
Returns a set of keys associated with the provider.There's no guarantee that it refers to all valid keys.
- Specified by:
keys
in interfaceNamedProvider<Feature<FeatureInput>>
- Returns:
- a set of all keys associated with the provider.
-