Class FeatureListFactory
Object
FeatureListFactory
Factory for creating
FeatureList
in different ways.- Author:
- Owen Feehan
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends FeatureInput>
FeatureList<T> empty()
Creates an empty list of featuresstatic <S,
T extends FeatureInput, E extends Exception>
FeatureList<T> flatMapFromOptional
(Iterable<S> iterable, CheckedFunction<S, Optional<FeatureList<T>>, E> flatMapFunc) Creates a new feature-list by flat-mapping an iterable to an optional featurestatic <T extends FeatureInput>
FeatureList<T> Creates a list for one or more featuresstatic <T extends FeatureInput>
FeatureList<T> fromIterable
(Iterable<Feature<T>> iterable) Creates a list of features from an iterablestatic <T extends FeatureInput>
FeatureList<T> fromProvider
(Provider<Feature<T>> featureProvider) Creates a list for a single-feature created from a providerstatic <T extends FeatureInput>
FeatureList<T> fromProviders
(Collection<FeatureProvider<T>> providers) Creates a list of features from a collection of feature-providersstatic <T extends FeatureInput>
FeatureList<T> fromStream
(Stream<Feature<T>> stream) Creates a list of features from a streamstatic <S,
T extends FeatureInput, E extends Exception>
FeatureList<T> mapFrom
(Iterable<S> iterable, CheckedFunction<S, Feature<T>, E> mapFunc) static <S,
T extends FeatureInput, E extends Exception>
FeatureList<T> mapFromFiltered
(Iterable<S> iterable, Predicate<S> predicate, CheckedFunction<S, Feature<T>, E> mapFunc) Creates a new feature-list by filtering an iterable and then mapping it to a featurestatic <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 featurestatic <T extends FeatureInput,
E extends Exception>
FeatureList<T> mapFromRangeOptional
(int startInclusive, int endExclusive, Class<? extends Exception> throwableClass, CheckedIntFunction<Optional<Feature<T>>, E> mapFunc) Creates a new feature-list by mapping integers (from a range) each to an optional featurestatic <T extends FeatureInput>
FeatureList<T> wrapDuplicate
(List<Feature<T>> list) Wraps an existing list, WITHOUT reusing the list in the internals of theFeatureList
i.e. create a new list internallystatic <T extends FeatureInput>
FeatureList<T> Wraps an existing list, reusing the list in the internals of theFeatureList
-
Method Details
-
empty
Creates an empty list of features- Type Parameters:
T
- input-type of feature(s) in list- Returns:
- a newly created empty list
-
from
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
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
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
Wraps an existing list, reusing the list in the internals of theFeatureList
- 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
Wraps an existing list, WITHOUT reusing the list in the internals of theFeatureList
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, FeatureList<T> mapFromE extends Exception> (Iterable<S> iterable, CheckedFunction<S, Feature<T>, throws EE> mapFunc) - Type Parameters:
S
- type that will be mapped toFeature
T
- feature input-type for the result of the mappingE
- exception-type that can be thrown during mapping- Parameters:
iterable
- source of entities to be mappedmapFunc
- 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, FeatureList<T> mapFromFilteredE extends Exception> (Iterable<S> iterable, Predicate<S> predicate, CheckedFunction<S, Feature<T>, throws EE> mapFunc) 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 featureT
- feature input-type for the result of the mappingE
- exception-type that can be thrown during mapping- Parameters:
iterable
- source of entities to be mappedpredicate
- only items initerable
that fulfill this condition will be mappedmapFunc
- 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, FeatureList<T> flatMapFromOptionalE extends Exception> (Iterable<S> iterable, CheckedFunction<S, Optional<FeatureList<T>>, throws EE> flatMapFunc) Creates a new feature-list by flat-mapping an iterable to an optional featureAny
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 mappingE
- exception-type that can be thrown during mapping- Parameters:
iterable
- source of entities to be mappedflatMapFunc
- 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 ECreates 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 mappingE
- 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 ofE
mapFunc
- function for mapping- Returns:
- a newly created feature-list
- Throws:
E
- if the exception is thrown during mapping
-