Class ConversionUtils
java.lang.Object
de.hybris.platform.webservicescommons.conversion.ConversionUtils
Utility class for converting collections of items into other collection of items using some function
-
Method Summary
Modifier and TypeMethodDescriptionstatic <I,R, O> R convert(ConfigurablePopulator<I, R, O> populator, Supplier<R> supplier, I source, O... options) static <R,I> List<R> convert(Collection<I> collection, Function<I, R> function) Converts collection of type I into list of type T using function.static <T,S, I> List<T> convert(S source, Collection<I> collection, BiFunction<I, S, T> function) Converts collection of type I into list of type T using function.static <I,R, O> Function<I, R> mapper(ConfigurablePopulator<I, R, O> populator, Supplier<R> supplier, O... options) Mapper which creates a single argument function from ConfigurablePopulator.
-
Method Details
-
convert
public static <T,S, List<T> convertI> (S source, Collection<I> collection, BiFunction<I, S, T> function) Converts collection of type I into list of type T using function. Function should accept item form collection and source for transformation. If function returns null element won't be included in result.- Parameters:
source- - second constant argument for mapping functioncollection- - collection of item to convertfunction- - converting function- Returns:
- list of converted elements without null's
-
convert
Converts collection of type I into list of type T using function. Function should accept item form collection for transformation. If function returns null element won't be included in result.- Parameters:
collection- - collection of item to convertfunction- - converting function- Returns:
- list of converted elements without null's
-
convert
@SafeVarargs public static <I,R, R convertO> (ConfigurablePopulator<I, R, O> populator, Supplier<R> supplier, I source, O... options) -
mapper
@SafeVarargs public static <I,R, Function<I,O> R> mapper(ConfigurablePopulator<I, R, O> populator, Supplier<R> supplier, O... options) Mapper which creates a single argument function from ConfigurablePopulator.- Parameters:
populator-supplier-options-- Returns:
-