Class FeatureList<T extends FeatureInput>

Object
org.anchoranalysis.bean.AnchorBean<FeatureList<T>>
org.anchoranalysis.feature.bean.list.FeatureList<T>
Type Parameters:
T - input type of features contained in the list
All Implemented Interfaces:
Iterable<Feature<T>>

public class FeatureList<T extends FeatureInput>
extends AnchorBean<FeatureList<T>>
implements Iterable<Feature<T>>
A list of features with the same input-type.
Author:
Owen Feehan
See Also:
for the preferred means of creating instances.
  • Constructor Details

    • FeatureList

      public FeatureList()
      Creates with an empty list.
    • FeatureList

      public FeatureList​(int capacity)
      Creates with an empty list of particular capacity.
      Parameters:
      capacity - initial capacity of the created empty list.
    • FeatureList

      public FeatureList​(Feature<T> feature)
      Creates with a single Feature.
      Parameters:
      feature - the feature.
    • FeatureList

      public FeatureList​(Stream<Feature<T>> stream)
      Creates from a stream of Features.
      Parameters:
      stream - the stream of features.
    • FeatureList

      public FeatureList​(List<Feature<T>> list)
      Wraps an existing list.
      Parameters:
      list - the list to wrap.
  • Method Details

    • initializeRecursive

      public void initializeRecursive​(FeatureInitialization initialization, Logger logger) throws InitializeException
      Initializes all features in the list, and recursively any features they contain.

      A feature must be initialized before being used for calculation.

      Parameters:
      initialization - the initialization parameters.
      logger - the logger.
      Throws:
      InitializeException - if any feature cannot be successfully initialized.
    • map

      public <S extends FeatureInput,​ E extends Exception> FeatureList<S> map​(CheckedFunction<Feature<T>,​Feature<S>,​E> mapFunc) throws E extends Exception
      Creates a new feature-list where each feature is the result of applying a map-function to an existing feature.
      Type Parameters:
      S - input-type of feature to be created as result of mapping
      E - exception that can be thrown during mapping
      Parameters:
      mapFunc - function to perform the mapping of each item.
      Returns:
      a newly created feature-list (with the same number of items) containing the mapped features.
      Throws:
      E - if the mapping-function throws this exception.
      E extends Exception
    • filterAndMap

      public <S extends FeatureInput,​ E extends Exception> FeatureList<S> filterAndMap​(Predicate<Feature<T>> predicate, CheckedFunction<Feature<T>,​Feature<S>,​E> mappingFunction) throws E extends Exception
      Type Parameters:
      S - input-type of feature to be created as result of mapping
      E - exception that can be thrown during mapping
      Parameters:
      mappingFunction - the function that performs the mapping.
      predicate - iff true object is included, otherwise excluded.
      Returns:
      a newly created feature-list, a filtered version of all features, then mapped.
      Throws:
      E - if the mapping-function throws this exception.
      E extends Exception
    • append

      public FeatureList<T> append​(Optional<FeatureList<T>> featureList)
      Appends the features one or more (optional) feature-lists to the existing list.

      This is an immutable operation and the existing list is not altered.

      Parameters:
      featureList - the optional feature-lists to append.
      Returns:
      a newly-created list with all the existing features, as well as any optional additional features.
    • deriveNames

      public FeatureNameList deriveNames()
      Derives the names of the features.
      Returns:
      the names.
    • sort

      public FeatureList<T> sort​(Comparator<Feature<T>> comparator)
      Creates a new feature-list sorted in a particular order.
      Parameters:
      comparator - used to determine the order of elements when sorting.
      Returns:
      a newly-created list with the same elements in sorted order.
    • shallowDuplicate

      public FeatureList<T> shallowDuplicate()
      Creates a new feature-list which contains identical elements.
      Returns:
      a newly-created list with the same elements in the same order.
    • add

      public void add​(Feature<? extends T> feature)
      Adds a feature to the current list.
      Parameters:
      feature - the feature to add.
    • isEmpty

      public boolean isEmpty()
      Returns true if this list contains no elements.
      Returns:
      true if this list contains no elements.
    • iterator

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

      public int size()
      Returns the number of elements in this list.
      Returns:
      the number of elements in this list.
    • asList

      public List<Feature<T>> asList()
      Exposes the underlying list of features in this data-structure.

      Changing this list, will change the current instance.

      Returns:
      the internal list used to store features.
    • describeBean

      public String describeBean()
      Overrides:
      describeBean in class AnchorBean<FeatureList<T extends FeatureInput>>
    • get

      public Feature<T> get​(int index)
      Returns the element at the specified position in this list.
      Parameters:
      index - the index.
      Returns:
      the feature at position index in the list.
    • clear

      public void clear()
      Removes all of the elements from this list.

      The list will be empty after this call returns.

    • addAll

      public void addAll​(FeatureList<? extends T> toAdd)
      Add all the features in other to the current list.
      Parameters:
      toAdd - the features to add.
    • getList

      public List<Feature<T>> getList()
      The list of features.
    • setList

      public void setList​(List<Feature<T>> list)
      The list of features.