public class FunctionalList<T> extends Object implements List<T>
Constructor and Description |
---|
FunctionalList(Iterable<T> list) |
Modifier and Type | Method and Description |
---|---|
void |
add(int index,
T element) |
boolean |
add(T t) |
boolean |
addAll(Collection<? extends T> c) |
boolean |
addAll(int index,
Collection<? extends T> c) |
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) |
List<List<T>> |
batch(int batchSize)
Makes lists of size 'batchSize' from the main list.
|
void |
clear() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
<U> FunctionalList<U> |
each(com.google.common.base.Function<? super T,? extends U> mapper)
Map and filter the list at the same time.
|
boolean |
equals(Object o) |
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() |
void |
forEach(Consumer<? super T> action) |
T |
get(int index) |
int |
hashCode() |
int |
indexOf(Object o) |
boolean |
isEmpty() |
Iterator<T> |
iterator() |
String |
join(String separator) |
String |
joinAndAbbreviate(String separator,
int length) |
int |
lastIndexOf(Object o) |
FunctionalList<T> |
limit(int max) |
ListIterator<T> |
listIterator() |
ListIterator<T> |
listIterator(int index) |
<U> FunctionalList<U> |
map(com.google.common.base.Function<? super T,? extends U> mapper)
Transforms and filters a list.
|
Stream<T> |
parallelStream() |
<U> U |
reduce(U seed,
BiFunction<T,U,U> reducer) |
T |
remove(int index) |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
boolean |
removeIf(Predicate<? super T> filter) |
void |
replaceAll(UnaryOperator<T> operator) |
boolean |
retainAll(Collection<?> c) |
T |
set(int index,
T element) |
int |
size() |
void |
sort(Comparator<? super T> c) |
Spliterator<T> |
spliterator() |
static FunctionalList<String> |
splitList(Object value,
String regexSplitter) |
Stream<T> |
stream() |
List<T> |
subList(int fromIndex,
int toIndex) |
Object[] |
toArray() |
<T1> T1[] |
toArray(T1[] a) |
clone, finalize, getClass, notify, notifyAll, toString, 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
protected final List<T> delegate
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 T first()
public int size()
size
in interface Collection<T>
size
in interface List<T>
public boolean isEmpty()
isEmpty
in interface Collection<T>
isEmpty
in interface List<T>
public boolean contains(Object o)
contains
in interface Collection<T>
contains
in interface List<T>
public Iterator<T> iterator()
public Object[] toArray()
toArray
in interface Collection<T>
toArray
in interface List<T>
public <T1> T1[] toArray(T1[] a)
toArray
in interface Collection<T>
toArray
in interface List<T>
public boolean add(T t)
add
in interface Collection<T>
add
in interface List<T>
public boolean remove(Object o)
remove
in interface Collection<T>
remove
in interface List<T>
public boolean containsAll(Collection<?> c)
containsAll
in interface Collection<T>
containsAll
in interface List<T>
public boolean addAll(Collection<? extends T> c)
addAll
in interface Collection<T>
addAll
in interface List<T>
public boolean addAll(int index, Collection<? extends T> c)
public boolean removeAll(Collection<?> c)
removeAll
in interface Collection<T>
removeAll
in interface List<T>
public boolean retainAll(Collection<?> c)
retainAll
in interface Collection<T>
retainAll
in interface List<T>
public void replaceAll(UnaryOperator<T> operator)
replaceAll
in interface List<T>
public void sort(Comparator<? super T> c)
public void clear()
clear
in interface Collection<T>
clear
in interface List<T>
public boolean equals(Object o)
public int hashCode()
public int lastIndexOf(Object o)
lastIndexOf
in interface List<T>
public ListIterator<T> listIterator()
listIterator
in interface List<T>
public ListIterator<T> listIterator(int index)
listIterator
in interface List<T>
public List<T> subList(int fromIndex, int toIndex)
public Spliterator<T> spliterator()
spliterator
in interface Iterable<T>
spliterator
in interface Collection<T>
spliterator
in interface List<T>
public boolean removeIf(Predicate<? super T> filter)
removeIf
in interface Collection<T>
public Stream<T> stream()
stream
in interface Collection<T>
public Stream<T> parallelStream()
parallelStream
in interface Collection<T>
Copyright © 2020 Play SQL. All rights reserved.