接口 StreamableIterable<T>
- 所有超级接口:
Iterable<T>
-
字段概要
字段 -
方法概要
修饰符和类型方法说明default booleanCheck if all elements in thisStreamableIterablematch the given predicate.default booleanCheck if any elements in thisStreamableIterablematch the given predicate.default StreamableIterable<T>Concatenates anotherStreamableIterableonto this one.static <T> StreamableIterable<T>Returns anStreamableIterablecontaining the elements from all the provided iterables concatenated together.static <T> StreamableIterable<T>concatMany(Iterable<? extends Iterable<? extends T>> iterables) Returns anStreamableIterablecontaining the elements from all the provided iterables concatenated together.default intcount()Count the number of elements in thisStreamableIterable.default StreamableIterable<T>distinct()Filter the elements in thisStreamableIterableby their hashcode/equals.default doubledoubleSum(ToDoubleFunction<? super T> func) Map all elements of thisStreamableIterableto a double, then sum the result.static <T> StreamableIterable<T>empty()Returns an emptyStreamableIterable.default StreamableIterable<T>Filter the elements in thisStreamableIterableby matching aPredicate.default StreamableIterable<T>Filter the elements in thisStreamableIterableby matching aPredicate.default <R> StreamableIterable<R>Flat map the elements in thisStreamableIterable.fold(BinaryOperator<T> accumulator) Folds each element of thisStreamableIterableinto the previous.default Tfold(T identity, BinaryOperator<@Nullable T> accumulator) 已过时。Remains for ABI compat.default <U> Ufold(U identity, BiFunction<? super @Nullable U, ? super T, ? extends U> accumulator) Folds each element of thisStreamableIterableinto the previous.Collects thisStreamableIterableinto aHashMapgrouped by a key.Collects thisStreamableIterableinto aHashMapgrouped by a key.Collects thisStreamableIterableinto aMapgrouped by a key.groupByImmutable(Function<T, K> keyFunc) Collects thisStreamableIterableinto aImmutableMapgrouped by a key.default <K,V> com.google.common.collect.ImmutableMap<K, List<V>> groupByImmutable(Function<T, K> keyFunc, Function<T, V> valueFunc) Collects thisStreamableIterableinto aImmutableMapgrouped by a key.default <K> LinkedHashMap<K,List<T>> groupByLinked(Function<T, K> keyFunc) Collects thisStreamableIterableinto aLinkedHashMapgrouped by a key.default <K,V> LinkedHashMap<K, List<V>> groupByLinked(Function<T, K> keyFunc, Function<T, V> valueFunc) Collects thisStreamableIterableinto aLinkedHashMapgrouped by a key.default intintSum(ToIntFunction<? super T> func) Map all elements of thisStreamableIterableto an int, then sum the result.default booleanisEmpty()default Stringdefault StreamableIterable<T>limit(@org.jetbrains.annotations.Range(from=-1L, to=2147483647L) int max) Limit the number of elements returned by thisStreamableIterableto the given value.default longlongSum(ToLongFunction<? super T> func) Map all elements of thisStreamableIterableto a long, then sum the result.default <R> StreamableIterable<R>Transform the elements in thisStreamableIterable.default booleanCheck if no elements in thisStreamableIterablematch the given predicate.static <T> StreamableIterable<T>of()Returns an emptyStreamableIterable.static <T> StreamableIterable<T>Constructs aStreamableIterablewrapper from the givenIterable.static <T> StreamableIterable<T>Creates anStreamableIterablefor anOptionalvalue.static <T> StreamableIterable<T>of(T thing) Creates aStreamableIterablefor single input.static <T> StreamableIterable<T>of(T... things) Creates anStreamableIterablefrom a variable list of inputs.static <T> StreamableIterable<T>ofNullable(T thing) Creates anStreamableIterablefor a Nullable value.Convert thisStreamableIterableto a parallelStream.default StreamableIterable<T>Peek the elements of thisStreamableIterableas they are consumed.default StreamableIterable<T>skip(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int n) Skip n number of elements in thisStreamableIterable.stream()Convert thisStreamableIterableto aStream.default Object[]toArray()Collect thisStreamableIterableto an array.default T[]Collect thisStreamableIterableto an array.default com.google.common.collect.ImmutableList<T>Collect thisStreamableIterableto anImmutableList.default <K,V> com.google.common.collect.ImmutableMap<K, V> toImmutableMap(Function<T, K> keyFunc, Function<T, V> valueFunc) Collect thisStreamableIterableto amImmutableMap.default <K,V> com.google.common.collect.ImmutableMap<K, V> toImmutableMap(Function<T, K> keyFunc, Function<T, V> valueFunc, BinaryOperator<V> mergeFunc) Collect thisStreamableIterableto amImmutableMap.default com.google.common.collect.ImmutableSet<T>Collect thisStreamableIterableto aLinkedHashSet.default <K,V> HashMap<K, V> toLinkedHashMap(Function<T, K> keyFunc, Function<T, V> valueFunc) Collect thisStreamableIterableto aLinkedHashMap.default <K,V> HashMap<K, V> toLinkedHashMap(Function<T, K> keyFunc, Function<T, V> valueFunc, BinaryOperator<V> mergeFunc) Collect thisStreamableIterableto aLinkedHashMap.default LinkedHashSet<T>Collect thisStreamableIterableto aLinkedHashSet.default LinkedList<T>Collect thisStreamableIterableto aLinkedList.toList()Collect thisStreamableIterableto anArrayList.default <K,V> HashMap<K, V> Collect thisStreamableIterableto aHashMap.default <K,V> HashMap<K, V> Collect thisStreamableIterableto aHashMap.default <K,V, M extends Map<K, V>>
MCollect thisStreamableIterableto aMap.default <K,V, M extends Map<K, V>>
MCollect thisStreamableIterableto aMap.toSet()Collect thisStreamableIterableto aHashSet.从接口继承的方法 java.lang.Iterable
forEach, iterator, spliterator
-
字段详细资料
-
EMPTY
Static empty instance. You wantempty().
-
-
方法详细资料
-
empty
Returns an emptyStreamableIterable.- 返回:
- The empty
StreamableIterable
-
of
Constructs aStreamableIterablewrapper from the givenIterable.- 参数:
itr- TheIterableto wrap.- 返回:
- The
StreamableIterable
-
of
Returns an emptyStreamableIterable.- 返回:
- The empty
StreamableIterable
-
of
Creates aStreamableIterablefor single input.- 参数:
thing- The thing.- 返回:
- the
StreamableIterable.
-
ofNullable
Creates anStreamableIterablefor a Nullable value.If the value provided is
null, this method will returnempty(), otherwise it will return a newStreamableIterablecontaining only the value provided.- 参数:
thing- The thing.- 返回:
- The
StreamableIterable.
-
of
Creates anStreamableIterablefor anOptionalvalue.If the value provided is not present, this method will return
empty(), otherwise it will return a newStreamableIterablecontaining only the value provided.- 参数:
optional- The thing.- 返回:
- The
StreamableIterable.
-
of
Creates anStreamableIterablefrom a variable list of inputs.- 参数:
things- The things.- 返回:
- the
StreamableIterable.
-
concat
Returns anStreamableIterablecontaining the elements from all the provided iterables concatenated together.- 参数:
iterables- TheIterables to concatenate.- 返回:
- The concatenated
StreamableIterable.
-
concatMany
Returns anStreamableIterablecontaining the elements from all the provided iterables concatenated together.- 参数:
iterables- TheIterables to concatenate.- 返回:
- The concatenated
StreamableIterable.
-
concat
Concatenates anotherStreamableIterableonto this one.- 参数:
other- The otherIterableto append.- 返回:
- The new concatenated
StreamableIterable.
-
filter
Filter the elements in thisStreamableIterableby matching aPredicate.All elements which match this Predicate will be in the resulting
StreamableIterable.- 参数:
pred- The predicate.- 返回:
- A wrapped
StreamableIterablewith the filter applied.
-
filterNot
Filter the elements in thisStreamableIterableby matching aPredicate.All elements which do not match this Predicate will be in the resulting
StreamableIterable.- 参数:
pred- The predicate.- 返回:
- A wrapped
StreamableIterablewith the filter applied.
-
map
Transform the elements in thisStreamableIterable.- 参数:
func- TheFunctionto transform with.- 返回:
- A wrapped
StreamableIterablewith the mapped elements.
-
flatMap
Flat map the elements in thisStreamableIterable.- 参数:
func- The function to get/create the iterable for a given element.- 返回:
- A wrapped
StreamableIterablewith the flat mapped elements.
-
distinct
Filter the elements in thisStreamableIterableby their hashcode/equals.- 返回:
- A wrapped
StreamableIterablewith the filtered elements.
-
peek
Peek the elements of thisStreamableIterableas they are consumed.- 参数:
action- The consumer.- 返回:
- A wrapped
StreamableIterablewith the peek function applied.
-
limit
default StreamableIterable<T> limit(@org.jetbrains.annotations.Range(from=-1L, to=2147483647L) int max) Limit the number of elements returned by thisStreamableIterableto the given value.- 参数:
max- The limit. -1 for infinite.- 返回:
- A wrapped
StreamableIterablewith the max filter applied. In the event-1is supplied, the sameStreamableIterablewill be provided. In the event0is supplied, an emptyStreamableIterablewill be provided.
-
skip
Skip n number of elements in thisStreamableIterable.- 参数:
n- The number of elements to skip.- 返回:
- A wrapped
StreamableIterablewith the max filter applied. In the event0is supplied, the sameStreamableIterablewill be provided.
-
toArray
Collect thisStreamableIterableto an array.- 返回:
- The array.
-
toArray
Collect thisStreamableIterableto an array.- 参数:
arr- The array to add the elements to. If all elements to not fit in this array a new array will be returned of appropriate size.- 返回:
- Either the array passed in or one of appropriate size with all elements of the Iterable.
-
fold
@Nullable @Contract("!null,_ -> !null") @Deprecated @ScheduledForRemoval(inVersion="0.5.0") default T fold(@Nullable T identity, BinaryOperator<@Nullable T> accumulator) 已过时。Remains for ABI compat.Folds each element of thisStreamableIterableinto the previous.- 参数:
identity- The starting element.accumulator- The function to fold elements with.- 返回:
- The result.
-
fold
@Nullable @Contract("!null,_ -> !null") default <U> U fold(@Nullable U identity, BiFunction<? super @Nullable U, ? super T, ? extends U> accumulator) Folds each element of thisStreamableIterableinto the previous.- 参数:
identity- The starting element.accumulator- The function to fold elements with.- 返回:
- The result.
-
fold
Folds each element of thisStreamableIterableinto the previous.- 参数:
accumulator- The function to fold elements with.- 返回:
- The result. Empty if no elements exist.
-
count
default int count()Count the number of elements in thisStreamableIterable.- 返回:
- The number of elements.
-
intSum
Map all elements of thisStreamableIterableto an int, then sum the result.- 参数:
func- The mapping function.- 返回:
- The sum result.
-
longSum
Map all elements of thisStreamableIterableto a long, then sum the result.- 参数:
func- The mapping function.- 返回:
- The sum result.
-
doubleSum
Map all elements of thisStreamableIterableto a double, then sum the result.- 参数:
func- The mapping function.- 返回:
- The sum result.
-
isEmpty
default boolean isEmpty()- 返回:
- If this
StreamableIterableis empty.
-
anyMatch
Check if any elements in thisStreamableIterablematch the given predicate.- 参数:
test- The predicate.- 返回:
- The result.
-
allMatch
Check if all elements in thisStreamableIterablematch the given predicate.- 参数:
test- The predicate.- 返回:
- The result.
-
noneMatch
Check if no elements in thisStreamableIterablematch the given predicate.- 参数:
test- The predicate.- 返回:
- The result.
-
toList
Collect thisStreamableIterableto anArrayList.- 返回:
- The
ArrayList.
-
toLinkedList
Collect thisStreamableIterableto aLinkedList.- 返回:
- The
LinkedList.
-
toImmutableList
Collect thisStreamableIterableto anImmutableList.- 返回:
- The
ImmutableList.
-
toSet
Collect thisStreamableIterableto aHashSet.- 返回:
- The
HashSet.
-
toLinkedHashSet
Collect thisStreamableIterableto aLinkedHashSet.- 返回:
- The
LinkedHashSet.
-
toImmutableSet
Collect thisStreamableIterableto aLinkedHashSet.- 返回:
- The
LinkedHashSet.
-
toMap
Collect thisStreamableIterableto aHashMap. This method will always resolve the existing element on collision.- 参数:
keyFunc- The function for extracting the key.valueFunc- The function for extracting the value.- 返回:
- The
Map.
-
toMap
default <K,V> HashMap<K,V> toMap(Function<T, K> keyFunc, Function<T, V> valueFunc, BinaryOperator<V> mergeFunc) Collect thisStreamableIterableto aHashMap.- 参数:
keyFunc- The function for extracting the key.valueFunc- The function for extracting the value.mergeFunc- The function for merging 2 values on collision. (Left existing, Right toAdd)- 返回:
- The
Map.
-
toLinkedHashMap
Collect thisStreamableIterableto aLinkedHashMap. This method will always resolve the existing element on collision.- 参数:
keyFunc- The function for extracting the key.valueFunc- The function for extracting the value.- 返回:
- The
Map.
-
toLinkedHashMap
default <K,V> HashMap<K,V> toLinkedHashMap(Function<T, K> keyFunc, Function<T, V> valueFunc, BinaryOperator<V> mergeFunc) Collect thisStreamableIterableto aLinkedHashMap.- 参数:
keyFunc- The function for extracting the key.valueFunc- The function for extracting the value.mergeFunc- The function for merging 2 values on collision. (Left existing, Right toAdd)- 返回:
- The
Map.
-
toImmutableMap
default <K,V> com.google.common.collect.ImmutableMap<K,V> toImmutableMap(Function<T, K> keyFunc, Function<T, V> valueFunc) Collect thisStreamableIterableto amImmutableMap.This function collects to an intermediate
LinkedHashMapinternally, iteration order will be preserved.- 参数:
keyFunc- The function for extracting the key.valueFunc- The function for extracting the value.- 返回:
- The
ImmutableMap.
-
toImmutableMap
default <K,V> com.google.common.collect.ImmutableMap<K,V> toImmutableMap(Function<T, K> keyFunc, Function<T, V> valueFunc, BinaryOperator<V> mergeFunc) Collect thisStreamableIterableto amImmutableMap.This function collects to an intermediate
LinkedHashMapinternally, iteration order will be preserved.- 参数:
keyFunc- The function for extracting the key.valueFunc- The function for extracting the value.mergeFunc- The function for merging 2 values on collision. (Left existing, Right toAdd)- 返回:
- The
ImmutableMap.
-
toMap
Collect thisStreamableIterableto aMap. This method will always resolve the existing element on collision.- 参数:
map- The map to add the elements to.keyFunc- The function for extracting the key.valueFunc- The function for extracting the value.- 返回:
- The same map that was passed in.
-
toMap
default <K,V, M toMapM extends Map<K, V>> (M map, Function<T, K> keyFunc, Function<T, V> valueFunc, BinaryOperator<V> mergeFunc) Collect thisStreamableIterableto aMap.- 参数:
map- The map to add the elements to.keyFunc- The function for extracting the key.valueFunc- The function for extracting the value.mergeFunc- The function for merging 2 values on collision. (Left existing, Right toAdd)- 返回:
- The same map that was passed in.
-
groupBy
Collects thisStreamableIterableinto aHashMapgrouped by a key.This function uses
ArrayListvalues. -
groupBy
Collects thisStreamableIterableinto aHashMapgrouped by a key.This function uses
ArrayListvalues. -
groupByLinked
Collects thisStreamableIterableinto aLinkedHashMapgrouped by a key.This function uses
LinkedListvalues.- 参数:
keyFunc- The function to extract theLinkedHashMapkey.- 返回:
- The
LinkedHashMaprepresenting the grouped values.
-
groupByLinked
default <K,V> LinkedHashMap<K,List<V>> groupByLinked(Function<T, K> keyFunc, Function<T, V> valueFunc) Collects thisStreamableIterableinto aLinkedHashMapgrouped by a key.This function uses
LinkedListvalues.This function will preserve iteration order.
- 参数:
keyFunc- The function to extract theLinkedHashMapkey.valueFunc- The function to extract theLinkedListvalue.- 返回:
- The
LinkedHashMaprepresenting the grouped values.
-
groupByImmutable
default <K> com.google.common.collect.ImmutableMap<K,List<T>> groupByImmutable(Function<T, K> keyFunc) Collects thisStreamableIterableinto aImmutableMapgrouped by a key.This function uses
ImmutableListvalues.This function will preserve iteration order.
- 参数:
keyFunc- The function to extract theImmutableMapkey.- 返回:
- The
ImmutableMaprepresenting the grouped values.
-
groupByImmutable
default <K,V> com.google.common.collect.ImmutableMap<K,List<V>> groupByImmutable(Function<T, K> keyFunc, Function<T, V> valueFunc) Collects thisStreamableIterableinto aImmutableMapgrouped by a key.This function uses
ImmutableListvalues.This function will preserve iteration order.
- 参数:
keyFunc- The function to extract theImmutableMapkey.valueFunc- The function to extract theImmutableListvalue.- 返回:
- The
ImmutableMaprepresenting the grouped values.
-
groupBy
default <K,V, M groupByL extends List<V>, M extends Map<K, L>> (M map, Supplier<L> listFactory, Function<T, K> keyFunc, Function<T, V> valueFunc) Collects thisStreamableIterableinto aMapgrouped by a key. -
join
- 参数:
sep- The separator.- 返回:
- The joined string.
-
stream
Convert thisStreamableIterableto aStream.- 返回:
- The
Stream
-
parallelStream
Convert thisStreamableIterableto a parallelStream.- 返回:
- The
Stream
-