Class NamedFeatureStore<T extends FeatureInput>

Object
NamedFeatureStore<T>
Type Parameters:
T - the feature-input type for all features in the store.
All Implemented Interfaces:
Iterable<NamedBean<Feature<T>>>

public class NamedFeatureStore<T extends FeatureInput> extends Object implements Iterable<NamedBean<Feature<T>>>
Stores Features, each with an associated name, with list-like access and map-like access.

Each feature is stored in an ordered manner, and zero-indexed.

A map between the name of each feature, and the feature's index position is simultaneously maintained.

If the names of two or more Features are identical, only a single Feature will be retrieved by name. The list-access remains unaffected.

Author:
Owen Feehan
  • Constructor Details

    • NamedFeatureStore

      public NamedFeatureStore()
  • Method Details

    • add

      public void add(String name, Feature<T> feature)
      Adds a named-feature to the store. The customName() of the feature is replaced with the name.
      Parameters:
      name - name of the feature.
      feature - the feature to add (whose customName will be overridden with the name).
    • get

      public NamedBean<Feature<T>> get(int index)
      Gets a feature at a particular position.
      Parameters:
      index - the position to retrieve (zero-indexed).
      Returns:
      the feature, encapsulated in the NamedBean that contains it.
    • get

      public NamedBean<Feature<T>> get(String name)
      Gets a feature corresponding to a particular name.
      Parameters:
      name - the name of the feature.
      Returns:
      the feature, encapsulated in the NamedBean that contains it.
    • features

      public FeatureList<T> features()
      All Features in the store, in identical order.
      Returns:
      a newly-created list, that reuses the existing Feature instances.
    • featureNames

      public FeatureNameList featureNames()
      The names of all Features in the store, in identical order to the store.
      Returns:
      a newly created FeatureNameList corresponding to the names of the features.
    • size

      public int size()
      The total number of Features in the store.
      Returns:
      the total number.
    • iterator

      public Iterator<NamedBean<Feature<T>>> iterator()
      Specified by:
      iterator in interface Iterable<T extends FeatureInput>
    • duplicate

      public NamedFeatureStore<T> duplicate()
      Deep-copies the store, including duplicating each feature.
      Returns:
      a deep-copy of the current instance.