public class FunctionalList<T> extends AbstractDelegatingList<T> implements List<T>
delegate
Constructor and Description |
---|
FunctionalList(Iterable<T> list) |
Modifier and Type | Method and Description |
---|---|
FunctionalList<T> |
addAndReturnThis(T... ts) |
<K> Map<K,List<T>> |
asBuckets(com.google.common.base.Function<T,K> keyExtractor) |
<K> Map<K,T> |
asMap(com.google.common.base.Function<T,K> keyExtractor) |
<K,V> Map<K,V> |
asMap(com.google.common.base.Function<T,K> keyExtractor,
com.google.common.base.Function<T,V> valueExtractor) |
List<List<T>> |
batch(int batchSize)
Makes lists of size 'batchSize' from the main list.
|
Set<T> |
distinct() |
<U> FunctionalList<U> |
each(com.google.common.base.Function<? super T,? extends U> mapper)
Map and filter the list at the same time.
|
static <T> FunctionalList<T> |
f(Iterable<T> list) |
static <T> FunctionalList<T> |
f(T... elements) |
FunctionalList<T> |
filter(Predicate<T> condition) |
T |
find(Predicate<T> condition)
Returns the first element that matches `condition`, or null.
|
T |
first() |
String |
join(String separator) |
String |
joinAndAbbreviate(String separator,
int length) |
FunctionalList<T> |
limit(int max)
Truncates the list to "max"
|
<U> FunctionalList<U> |
map(com.google.common.base.Function<? super T,? extends U> mapper)
Transforms and filters a list.
|
<U> U |
reduce(U seed,
BiFunction<T,U,U> reducer) |
static FunctionalList<String> |
splitList(Object value,
String regexSplitter) |
static <T> List<T> |
union(List<T> listA,
List<T> listB) |
add, add, addAll, addAll, clear, contains, containsAll, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, parallelStream, remove, remove, removeAll, removeIf, replaceAll, retainAll, set, size, sort, spliterator, stream, subList, toArray, toArray, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray
parallelStream, removeIf, stream
public static <T> FunctionalList<T> f(Iterable<T> list)
public static <T> FunctionalList<T> f(T... elements)
public static FunctionalList<String> splitList(Object value, String regexSplitter)
public <U> FunctionalList<U> map(com.google.common.base.Function<? super T,? extends U> mapper)
mapper
- The mapper must return a transformed element, or null if the element shouldn't be included.public FunctionalList<T> limit(int max)
public <U> FunctionalList<U> each(com.google.common.base.Function<? super T,? extends U> mapper)
mapper
- a mapper which either returns the element or null when it should be removedpublic FunctionalList<T> filter(Predicate<T> condition)
public <U> U reduce(U seed, BiFunction<T,U,U> reducer)
public T find(Predicate<T> condition)
public List<List<T>> batch(int batchSize)
public FunctionalList<T> addAndReturnThis(T... ts)
public <K,V> Map<K,V> asMap(com.google.common.base.Function<T,K> keyExtractor, com.google.common.base.Function<T,V> valueExtractor)
public T first()
Copyright © 2022 Requirement Yogi. All rights reserved.