Class FeatureListFactory

Object
FeatureListFactory

public class FeatureListFactory extends Object
Factory for creating FeatureList in different ways.
Author:
Owen Feehan
  • Method Details

    • empty

      public static <T extends FeatureInput> FeatureList<T> empty()
      Creates an empty list of features
      Type Parameters:
      T - input-type of feature(s) in list
      Returns:
      a newly created empty list
    • from

      @SafeVarargs public static <T extends FeatureInput> FeatureList<T> from(Feature<T>... feature)
      Creates a list for one or more features
      Type Parameters:
      T - input-type of feature(s) in list
      Parameters:
      feature - the feature(s)
      Returns:
      a newly-created list with each feature included in identical order to the argument
    • fromProvider

      public static <T extends FeatureInput> FeatureList<T> fromProvider(Provider<Feature<T>> featureProvider) throws ProvisionFailedException
      Creates a list for a single-feature created from a provider
      Type Parameters:
      T - input-type of feature(s) in list
      Parameters:
      featureProvider - provides the single feature
      Returns:
      a newly-created list
      Throws:
      ProvisionFailedException
    • fromIterable

      public static <T extends FeatureInput> FeatureList<T> fromIterable(Iterable<Feature<T>> iterable)
      Creates a list of features from an iterable
      Type Parameters:
      T - input-type of feature(s) in list
      Parameters:
      iterable - the iterable
      Returns:
      a newly created list
    • fromStream

      public static <T extends FeatureInput> FeatureList<T> fromStream(Stream<Feature<T>> stream)
      Creates a list of features from a stream
      Type Parameters:
      T - input-type of feature(s) in list
      Parameters:
      stream - the stream
      Returns:
      a newly created list
    • fromProviders

      public static <T extends FeatureInput> FeatureList<T> fromProviders(Collection<FeatureProvider<T>> providers) throws ProvisionFailedException
      Creates a list of features from a collection of feature-providers
      Type Parameters:
      T - input-type of feature(s) in list
      Parameters:
      providers - the providers, each of which provides a single feature
      Returns:
      a newly created list
      Throws:
      ProvisionFailedException - if an exception is occurring creating from the provider
    • wrapReuse

      public static <T extends FeatureInput> FeatureList<T> wrapReuse(List<Feature<T>> list)
      Wraps an existing list, reusing the list in the internals of the FeatureList
      Type Parameters:
      T - input-type of feature(s) in list
      Parameters:
      list - the list to wrap
      Returns:
      a newly created feature-list, using the list argument internally as its data container
    • wrapDuplicate

      public static <T extends FeatureInput> FeatureList<T> wrapDuplicate(List<Feature<T>> list)
      Wraps an existing list, WITHOUT reusing the list in the internals of the FeatureList i.e. create a new list internally
      Type Parameters:
      T - input-type of feature(s) in list
      Parameters:
      list - the list to wrap
      Returns:
      a newly-created feature-list, using the same features as the list argument but not the same list data structure.
    • mapFrom

      public static <S, T extends FeatureInput, E extends Exception> FeatureList<T> mapFrom(Iterable<S> iterable, CheckedFunction<S,Feature<T>,E> mapFunc) throws E
      Creates a new feature-list by mapping an Iterable to Feature
      Type Parameters:
      S - type that will be mapped to Feature
      T - feature input-type for the result of the mapping
      E - exception-type that can be thrown during mapping
      Parameters:
      iterable - source of entities to be mapped
      mapFunc - function for mapping
      Returns:
      a newly created feature-list, with the result (in order) of the mapping of each iterm in Iterable
      Throws:
      E - exception if it occurs during mapping
    • mapFromFiltered

      public static <S, T extends FeatureInput, E extends Exception> FeatureList<T> mapFromFiltered(Iterable<S> iterable, Predicate<S> predicate, CheckedFunction<S,Feature<T>,E> mapFunc) throws E
      Creates a new feature-list by filtering an iterable and then mapping it to a feature
      Type Parameters:
      S - type that will be filtered and then mapped to a feature
      T - feature input-type for the result of the mapping
      E - exception-type that can be thrown during mapping
      Parameters:
      iterable - source of entities to be mapped
      predicate - only items in iterable that fulfill this condition will be mapped
      mapFunc - function for mapping
      Returns:
      a newly created feature-list, with the result (in order) of the mapping of each item in iterable
      Throws:
      E - exception if it occurs during mapping
    • flatMapFromOptional

      public static <S, T extends FeatureInput, E extends Exception> FeatureList<T> flatMapFromOptional(Iterable<S> iterable, CheckedFunction<S,Optional<FeatureList<T>>,E> flatMapFunc) throws E
      Creates a new feature-list by flat-mapping an iterable to an optional feature

      Any Optional.empty() results are not included.

      Type Parameters:
      S - type that will be mapped to an optional feature.
      T - feature input-type for the result of the mapping
      E - exception-type that can be thrown during mapping
      Parameters:
      iterable - source of entities to be mapped
      flatMapFunc - function for mapping
      Returns:
      a newly created feature-list, with the result (in order) of the mapping of each item in iterable
      Throws:
      E - exception if it occurs during mapping
    • mapFromRange

      public static <T extends FeatureInput> FeatureList<T> mapFromRange(int startInclusive, int endExclusive, IntFunction<Feature<T>> mapFunc)
      Creates a new feature-list by mapping integers (from a range) each to a feature
      Type Parameters:
      T - feature input-type for the result of the mapping
      Parameters:
      startInclusive - start index for the integer range (inclusive)
      endExclusive - end index for the integer range (exclusive)
      mapFunc - function for mapping
      Returns:
      a newly created feature-list
    • mapFromRangeOptional

      public static <T extends FeatureInput, E extends Exception> FeatureList<T> mapFromRangeOptional(int startInclusive, int endExclusive, Class<? extends Exception> throwableClass, CheckedIntFunction<Optional<Feature<T>>,E> mapFunc) throws E
      Creates a new feature-list by mapping integers (from a range) each to an optional feature
      Type Parameters:
      T - feature input-type for the result of the mapping
      E - an exception that be thrown during mapping
      Parameters:
      startInclusive - start index for the integer range (inclusive)
      endExclusive - end index for the integer range (exclusive)
      throwableClass - the class of E
      mapFunc - function for mapping
      Returns:
      a newly created feature-list
      Throws:
      E - if the exception is thrown during mapping