Modifier and Type | Field and Description |
---|---|
static int |
MAX_ARRAY_SIZE
A safe maximum size for arrays in the JVM.
|
Modifier and Type | Method and Description |
---|---|
static <T> Collection<T> |
checkedSubTypeCast(Collection<? super T> collection,
Class<T> subTypeClass)
Casts the given collection to a subtype.
|
static <K,V> Map.Entry<K,V> |
entry(K k,
V v)
Returns an immutable
Map.Entry . |
static boolean |
isEmptyOrAllElementsNull(Collection<?> collection)
Returns true if the given collection is empty or contains only null elements.
|
static boolean |
isNullOrEmpty(Collection<?> collection)
Returns true if the given collection is null or empty.
|
static boolean |
isNullOrEmpty(Map<?,?> map) |
static <E> List<E> |
iterableToList(Iterable<E> iterable)
Collects the elements in the Iterable in a List.
|
static <E> List<E> |
iteratorToList(Iterator<E> iterator)
Collects the elements in the Iterator in a List.
|
static <K,V> Map<K,V> |
map(Map.Entry<K,V>... entries)
Returns an immutable
Map from the provided entries. |
static <T,R> Stream<R> |
mapWithIndex(Collection<T> input,
BiFunction<T,Integer,R> mapper) |
static <K,V> HashMap<K,V> |
newHashMapWithExpectedSize(int expectedSize)
Creates a new
HashMap of the expected size, i.e. a hash map that will not rehash if
expectedSize many keys are inserted, considering the load factor. |
static <E> HashSet<E> |
newHashSetWithExpectedSize(int expectedSize)
Creates a new
HashSet of the expected size, i.e. a hash set that will not rehash if
expectedSize many unique elements are inserted, considering the load factor. |
static <K,V> LinkedHashMap<K,V> |
newLinkedHashMapWithExpectedSize(int expectedSize)
Creates a new
LinkedHashMap of the expected size, i.e. a hash map that will not
rehash if expectedSize many keys are inserted, considering the load factor. |
static <E> LinkedHashSet<E> |
newLinkedHashSetWithExpectedSize(int expectedSize)
Creates a new
LinkedHashSet of the expected size, i.e. a hash set that will not
rehash if expectedSize many unique elements are inserted, considering the load factor. |
static <T> Set<T> |
ofNullable(T obj) |
static <T> Collection<List<T>> |
partition(Collection<T> elements,
int numBuckets)
Partition a collection into approximately n buckets.
|
static <I,O> Collection<O> |
project(Collection<I> collection,
Function<I,O> projector) |
static <T> Collection<T> |
subTypeCast(Collection<? super T> collection)
Casts the given collection to a subtype.
|
public static final int MAX_ARRAY_SIZE
public static boolean isNullOrEmpty(Collection<?> collection)
public static boolean isEmptyOrAllElementsNull(Collection<?> collection)
public static boolean isNullOrEmpty(Map<?,?> map)
public static <T,R> Stream<R> mapWithIndex(Collection<T> input, BiFunction<T,Integer,R> mapper)
public static <T> Collection<List<T>> partition(Collection<T> elements, int numBuckets)
public static <I,O> Collection<O> project(Collection<I> collection, Function<I,O> projector)
public static <E> List<E> iterableToList(@Nullable Iterable<E> iterable)
public static <E> List<E> iteratorToList(@Nullable Iterator<E> iterator)
public static <K,V> Map.Entry<K,V> entry(K k, V v)
Map.Entry
.@SafeVarargs public static <K,V> Map<K,V> map(Map.Entry<K,V>... entries)
Map
from the provided entries.public static <K,V> HashMap<K,V> newHashMapWithExpectedSize(int expectedSize)
HashMap
of the expected size, i.e. a hash map that will not rehash if
expectedSize many keys are inserted, considering the load factor.K
- the type of keys maintained by this map.V
- the type of mapped values.expectedSize
- the expected size of the created hash map.public static <K,V> LinkedHashMap<K,V> newLinkedHashMapWithExpectedSize(int expectedSize)
LinkedHashMap
of the expected size, i.e. a hash map that will not
rehash if expectedSize many keys are inserted, considering the load factor.K
- the type of keys maintained by this map.V
- the type of mapped values.expectedSize
- the expected size of the created hash map.public static <E> HashSet<E> newHashSetWithExpectedSize(int expectedSize)
HashSet
of the expected size, i.e. a hash set that will not rehash if
expectedSize many unique elements are inserted, considering the load factor.E
- the type of elements stored by this set.expectedSize
- the expected size of the created hash map.public static <E> LinkedHashSet<E> newLinkedHashSetWithExpectedSize(int expectedSize)
LinkedHashSet
of the expected size, i.e. a hash set that will not
rehash if expectedSize many unique elements are inserted, considering the load factor.E
- the type of elements stored by this set.expectedSize
- the expected size of the created hash map.public static <T> Collection<T> subTypeCast(Collection<? super T> collection)
T
- the subtype to cast to.collection
- the collection to cast.public static <T> Collection<T> checkedSubTypeCast(Collection<? super T> collection, Class<T> subTypeClass)
T
- the subtype to cast to.collection
- the collection to cast.subTypeClass
- the class of the subtype to cast to.Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.