Modifier and Type | Method and Description |
---|---|
static <S,T,E extends Exception> |
filterAndMapToList(List<S> list,
CheckedPredicate<S,E> predicate,
CheckedFunction<S,T,E> mapFunction)
Creates a new collection by filtering a list and then mapping to a list of another type.
|
static <S,T,E extends Exception> |
filterAndMapWithIndexToList(List<S> list,
java.util.function.Predicate<S> predicate,
CheckedFunctionWithInt<S,T,E> mapFuncWithIndex)
Creates a new collection by filtering a list and then mapping (with an index) to a list of
another type.
|
static <T,E extends Exception> |
filterToList(Collection<T> collection,
Class<? extends Exception> throwableClass,
CheckedPredicate<T,E> predicate)
Filters a collection and maps the result to a list.
|
static <T> List<T> |
filterToList(Collection<T> collection,
java.util.function.Predicate<T> predicate)
Filters a collection and maps the result to a list.
|
static <S,T,E extends Exception> |
flatMapToList(Collection<S> collection,
Class<? extends Exception> throwableClass,
CheckedFunction<S,java.util.stream.Stream<? extends T>,E> mapFunction)
Flat-maps a collection to a list where in the original collection can produce many elements
in the outgoing list.
|
static <S,T> List<T> |
flatMapToList(Collection<S> collection,
java.util.function.Function<S,java.util.stream.Stream<T>> mapFunction)
Flat-maps a collection to a list where in the original collection can produce many elements
in the outgoing list.
|
static <T> List<T> |
mapRangeToList(int startInclusive,
int endExclusive,
java.util.function.IntFunction<T> mapFunction)
Creates a list of elements, where each element corresponds to an index in a range.
|
static <S,T,E extends Exception> |
mapToList(Collection<S> collection,
Class<? extends Exception> throwableClass,
CheckedFunction<S,T,E> mapFunction)
Like
mapToList(Object[], Function) but tolerates exceptions in the mapping function. |
static <S,T,U> List<T> |
mapToList(Collection<S> collection,
Collection<U> arguments,
java.util.function.BiFunction<S,U,T> mapFunction)
Maps a collection to a list with each element derived from a corresponding element in the
original collection, as well as a corresponding argument from a second list.
|
static <S,T> List<T> |
mapToList(Collection<S> collection,
java.util.function.Function<S,T> mapFunction)
Maps a collection to a list with each element derived from a corresponding element in the
original collection.
|
static <S,T,E extends Exception> |
mapToList(S[] array,
Class<? extends Exception> throwableClass,
CheckedFunction<S,T,E> mapFunction)
Like
mapToList(Object[], Function) but tolerates exceptions in the mapping function. |
static <S,T> List<T> |
mapToList(S[] array,
java.util.function.Function<S,T> mapFunction)
Maps an array to a list with each element derived from a corresponding element in the
original array.
|
static <S,T,E extends Exception> |
mapToList(java.util.stream.Stream<S> stream,
Class<? extends Exception> throwableClass,
CheckedFunction<S,T,E> mapFunction)
Like
mapToList(Stream, Function) but tolerates exceptions in the mapping function. |
static <S,T> List<T> |
mapToList(java.util.stream.Stream<S> stream,
java.util.function.Function<S,T> mapFunction)
Maps a stream to a list with each element derived from a corresponding element in the
original collection.
|
static <S,T,E extends Exception> |
mapToListOptional(Collection<S> collection,
Class<? extends Exception> throwableClass,
CheckedFunction<S,Optional<T>,E> mapFunction)
Maps a collection to a list with each element in the original collection maybe producing an
element in the output.
|
static <S,T> List<T> |
mapToListOptional(Collection<S> collection,
java.util.function.Function<S,Optional<T>> mapFunction)
Maps a collection to a list with each element in the original collection maybe producing an
element in the output.
|
static <S,T,E extends Exception> |
mapToListOptional(java.util.stream.Stream<S> stream,
Class<? extends Exception> throwableClass,
CheckedFunction<S,Optional<T>,E> mapFunction)
Maps a stream to a list with each element in the original collection maybe producing an
element in the output.
|
static <S,T,E extends Exception> |
mapToListOptionalWithIndex(List<S> list,
Class<? extends Exception> throwableClass,
CheckedFunctionWithInt<S,Optional<T>,E> mapFunction)
Maps a list to a new list with each element in the original collection maybe producing an
element in the output.
|
static <S,T,E extends Exception> |
mapToListWithIndex(List<S> list,
Class<? extends Exception> throwableClass,
CheckedFunctionWithInt<S,T,E> mapFunction)
Maps a collection to a list with each element derived from a corresponding element in the
original collection - and also letting the map function use an index.
|
static <S,T> List<T> |
mapToListWithIndex(List<S> list,
FunctionWithInt<S,T> mapFunction)
Maps a collection to a list with each element derived from a corresponding element in the
original collection - and also letting the map function use an index.
|
static <T> List<T> |
of(java.util.stream.Stream<T> stream)
Creates a list from a stream.
|
static <T> List<T> |
repeat(int numberRepeats,
java.util.function.Supplier<T> mapFunction)
Creates a list of elements, by repeatedly calling the same operation.
|
static <S,T> List<org.apache.commons.lang3.tuple.Pair<S,T>> |
zip(Collection<S> first,
Collection<T> second)
Create a list of pairs of elements from two separate collections.
|
static <S,T,V> List<V> |
zip(Collection<S> first,
Collection<T> second,
java.util.function.BiFunction<S,T,V> combine)
Create a list of elements from two separate collections.
|
public static <T> List<T> of(java.util.stream.Stream<T> stream)
This function's purpose is mostly an convenience utility to make source-code easier to read, as the paradigm below (although very idiomatic) occurs frequently.
T
- item-typestream
- the stream to create the list frompublic static <S,T> List<T> mapToList(java.util.stream.Stream<S> stream, java.util.function.Function<S,T> mapFunction)
This function's purpose is mostly an convenience utility to make source-code easier to read, as the paradigm below (although very idiomatic) occurs frequently.
S
- parameter-type for functionT
- return-type for functionstream
- the stream to be mappedmapFunction
- function to do the mappingpublic static <S,T> List<T> mapToList(Collection<S> collection, java.util.function.Function<S,T> mapFunction)
This function's purpose is mostly an convenience utility to make source-code easier to read, as the paradigm below (although very idiomatic) occurs frequently.
S
- parameter-type for functionT
- return-type for functioncollection
- the collection to be mapped.mapFunction
- function to do the mapping.public static <S,T,U> List<T> mapToList(Collection<S> collection, Collection<U> arguments, java.util.function.BiFunction<S,U,T> mapFunction)
This function's purpose is mostly an convenience utility to make source-code easier to read, as the paradigm below (although very idiomatic) occurs frequently.
S
- parameter-type for functionT
- return-type for functionU
- type of second argument for functioncollection
- the collection to be mapped.arguments
- the argument to use together with element in collection
.mapFunction
- function to do the mapping.public static <S,T> List<T> mapToList(S[] array, java.util.function.Function<S,T> mapFunction)
This function's purpose is mostly an convenience utility to make source-code easier to read, as the paradigm below (although very idiomatic) occurs frequently.
S
- parameter-type for functionT
- return-type for functionarray
- the array to be mapped.mapFunction
- function to do the mapping.public static <S,T,E extends Exception> List<T> mapToList(Collection<S> collection, Class<? extends Exception> throwableClass, CheckedFunction<S,T,E> mapFunction) throws E extends Exception
mapToList(Object[], Function)
but tolerates exceptions in the mapping function.S
- parameter-type for functionT
- return-type for functionE
- exception that can be thrown by @mapFunction
collection
- the collection to be mapped.throwableClass
- class type of exception that may be thrown by mapFunction
.mapFunction
- function to do the mapping.E
- if the exception is thrown during mappingE extends Exception
public static <S,T,E extends Exception> List<T> mapToList(S[] array, Class<? extends Exception> throwableClass, CheckedFunction<S,T,E> mapFunction) throws E extends Exception
mapToList(Object[], Function)
but tolerates exceptions in the mapping function.S
- parameter-type for functionT
- return-type for functionE
- exception that can be thrown by mapFunction
array
- the array to be mappedthrowableClass
- class type of exception that may be thrown by mapFunction
.mapFunction
- function to do the mapping.E
- if the exception is thrown during mapping.E extends Exception
public static <S,T,E extends Exception> List<T> mapToList(java.util.stream.Stream<S> stream, Class<? extends Exception> throwableClass, CheckedFunction<S,T,E> mapFunction) throws E extends Exception
mapToList(Stream, Function)
but tolerates exceptions in the mapping function.S
- parameter-type for functionT
- return-type for functionE
- exception that can be thrown by @mapFunction
stream
- the stream to be mapped.throwableClass
- class type of exception that may be thrown by mapFunction
.mapFunction
- function to do the mapping.E
- if the exception is thrown during mapping.E extends Exception
public static <S,T> List<T> mapToListWithIndex(List<S> list, FunctionWithInt<S,T> mapFunction)
S
- parameter-type for functionT
- return-type for functionlist
- the list to be mapped.mapFunction
- function to do the mapping.public static <S,T,E extends Exception> List<T> mapToListWithIndex(List<S> list, Class<? extends Exception> throwableClass, CheckedFunctionWithInt<S,T,E> mapFunction) throws E extends Exception
S
- parameter-type for functionT
- return-type for functionE
- exception that can be thrown by @mapFunction
list
- the list to be mapped.throwableClass
- class type of exception that may be thrown by mapFunction
.mapFunction
- function to do the mapping.E
- if the exception is thrown during mapping.E extends Exception
public static <S,T> List<T> mapToListOptional(Collection<S> collection, java.util.function.Function<S,Optional<T>> mapFunction)
S
- parameter-type for functionT
- return-type for functioncollection
- the collection to be mapped.mapFunction
- function to do the mapping to an Optional (the item is included in the
output if the optional is defined).public static <S,T,E extends Exception> List<T> mapToListOptional(Collection<S> collection, Class<? extends Exception> throwableClass, CheckedFunction<S,Optional<T>,E> mapFunction) throws E extends Exception
S
- parameter-type for functionT
- return-type for functionE
- an exception that may be thrown by an mapFunction
collection
- the collection to be mapped.throwableClass
- class type of exception that may be thrown by mapFunction
.mapFunction
- function to do the mapping to an Optional (the item is included in the
output if the optional is defined).E
- if it is thrown by any call to mapFunction
E extends Exception
public static <S,T,E extends Exception> List<T> mapToListOptional(java.util.stream.Stream<S> stream, Class<? extends Exception> throwableClass, CheckedFunction<S,Optional<T>,E> mapFunction) throws E extends Exception
S
- parameter-type for functionT
- return-type for functionE
- an exception that may be thrown by an mapFunction
stream
- the stream to be mapped.throwableClass
- class type of exception that may be thrown by mapFunction
.mapFunction
- function to do the mapping to an Optional (the item is included in the
output if the optional is defined).E
- if it is thrown by any call to mapFunction
E extends Exception
public static <S,T,E extends Exception> List<T> mapToListOptionalWithIndex(List<S> list, Class<? extends Exception> throwableClass, CheckedFunctionWithInt<S,Optional<T>,E> mapFunction) throws E extends Exception
S
- parameter-type for functionT
- return-type for functionE
- an exception that may be thrown by an mapFunction
list
- the list to be mapped.throwableClass
- class type of exception that may be thrown by mapFunction
.mapFunction
- function to do the mapping to an Optional (the item is included in the
output if the optional is defined).E
- if it is thrown by any call to mapFunction
E extends Exception
public static <S,T> List<T> flatMapToList(Collection<S> collection, java.util.function.Function<S,java.util.stream.Stream<T>> mapFunction)
S
- parameter-type for functionT
- return-type for functioncollection
- the collection to be mappedmapFunction
- function to do the mappingpublic static <S,T,E extends Exception> List<T> flatMapToList(Collection<S> collection, Class<? extends Exception> throwableClass, CheckedFunction<S,java.util.stream.Stream<? extends T>,E> mapFunction) throws E extends Exception
S
- parameter-type for functionT
- return-type for functionE
- exception that may be thrown by collection
collection
- the collection to be mappedthrowableClass
- the class of E
.mapFunction
- function to do the mappingE
- if thrown by mapFunction
E extends Exception
public static <T> List<T> mapRangeToList(int startInclusive, int endExclusive, java.util.function.IntFunction<T> mapFunction)
T
- element-type in the liststartInclusive
- minimum-element in range (inclusive).endExclusive
- maximum-element in range (exclusive).mapFunction
- function to do the mapping.public static <T> List<T> repeat(int numberRepeats, java.util.function.Supplier<T> mapFunction)
T
- element-type in the listnumberRepeats
- the number of repeats.mapFunction
- function to create each element.public static <T> List<T> filterToList(Collection<T> collection, java.util.function.Predicate<T> predicate)
This function's purpose is mostly an convenience utility to make source-code easier to read, as the paradigm below (although idiomatic) occurs in multiple places.
T
- list item-typepredicate
- predicate to first filter the input collection before mapping.collection
- the collection to be filtered.public static <T,E extends Exception> List<T> filterToList(Collection<T> collection, Class<? extends Exception> throwableClass, CheckedPredicate<T,E> predicate) throws E extends Exception
This function's purpose is mostly an convenience utility to make source-code easier to read, as the paradigm below (although idiomatic) occurs in multiple places.
T
- list item-typeE
- exception that may be thrown during evaluating the predicatepredicate
- predicate to first filter the input collection before mapping.collection
- the collection to be filtered.throwableClass
- class type of exception that may be thrown by mapFunction
.E
- if an exception is thrown during evaluating the predicate.E extends Exception
public static <S,T,E extends Exception> LinkedList<T> filterAndMapToList(List<S> list, CheckedPredicate<S,E> predicate, CheckedFunction<S,T,E> mapFunction) throws E extends Exception
S
- type that will be mapped fromT
- type that will be mapped toE
- exception that may be thrown during mappinglist
- incoming list to be mapped.predicate
- a condition that must be fulfilled for elements in list
to be
included in the returned list.mapFunction
- function for mapping.E
- if an exception is thrown while calling predicate
or mapFunction
.E extends Exception
public static <S,T,E extends Exception> List<T> filterAndMapWithIndexToList(List<S> list, java.util.function.Predicate<S> predicate, CheckedFunctionWithInt<S,T,E> mapFuncWithIndex) throws E extends Exception
S
- type that will be mapped fromT
- type that will be mapped toE
- exception that may be thrown during mappinglist
- incoming list to be mappedpredicate
- a condition that must be fulfilled for elements in list
to be
included in the returned list.mapFuncWithIndex
- function for mapping, also including an index (the original position
in the bounding-box).E
- if an exception is thrown during mapping.E extends Exception
public static <S,T> List<org.apache.commons.lang3.tuple.Pair<S,T>> zip(Collection<S> first, Collection<T> second)
Elements are combined from each in the same order as iteration.
S
- element-type in first collectionT
- element-type in second collectionfirst
- first collection.second
- second collection.first
and the corresponding element from second
.public static <S,T,V> List<V> zip(Collection<S> first, Collection<T> second, java.util.function.BiFunction<S,T,V> combine)
Elements are combined from each in the same order as iteration.
S
- element-type in first collectionT
- element-type in second collectionV
- combined-element typefirst
- first collection.second
- second collection.combine
- how to combine a first and second element.first
and the corresponding element from second
.Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.