Package me.despical.commons.util
Class Collections
java.lang.Object
me.despical.commons.util.Collections
- Author:
- Despical
Created at 4.04.2021
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> booleanaddAll(Collection<T> collection, T... elements) Adds all the elements in the specified collection to this collection (optional operation).static booleanChecks if the object is in the given array.immutableListFromMap(Map<K, V> a) Returns an immutable list containing an arbitrary number of elements.static <T> List<T> immutableListFromSet(Set<T> a) Returns an immutable list containing elements of given set.static <T> List<T> immutableListOf(T... a) Returns an immutable list containing an arbitrary number of elements.static <K,V> Map <K, V> immutableMapOf(Map.Entry<K, V>... a) Returns an immutable map containing an arbitrary number of elements.static <K,V> Map <K, V> immutableMapOf(K a, V b) Returns an immutable map containing one element.static <T> Set<T> immutableSetOf(T... a) Returns an immutable set containing an arbitrary number of elements.listFromMap(Map<K, V> a) Returns a mutable list containing entry set elements of given map.static <T> List<T> listFromSet(Set<T> a) Returns a mutable list containing elements of given set.static <T> List<T> listOf(T... a) Returns a mutable list containing an arbitrary number of elements.static <K,V> Map.Entry <K, V> mapEntry(K a, V b) Returns aMap.Entrycontaining the given key and value.static <K,V> Map <K, V> Returns a mutable map containing an arbitrary number of elements.static <K,V> Map <K, V> mapOf(K a, V b) Returns an mutable map containing one element.static <T> Set<T> setOf(T... a) Returns a mutable set containing an arbitrary number of elements.static <T> Stream<T> streamOf(T... a) Returns a sequential ordered stream whose elements are the specified values.
-
Method Details
-
listOf
Returns a mutable list containing an arbitrary number of elements.- Type Parameters:
T- Type of given parameters.- Parameters:
a- Array of given parameters.- Returns:
- mutable list containing an arbitrary number of elements.
-
immutableListOf
Returns an immutable list containing an arbitrary number of elements.- Type Parameters:
T- Type of given parameters.- Parameters:
a- Array of given parameters.- Returns:
- immutable list containing an arbitrary number of elements.
-
listFromSet
Returns a mutable list containing elements of given set.- Type Parameters:
T- Type of given set.- Parameters:
a- Set to be converted to list.- Returns:
- mutable list containing elements of given set.
-
immutableListFromSet
Returns an immutable list containing elements of given set.- Type Parameters:
T- Type of given set.- Parameters:
a- Set to be converted to list.- Returns:
- immutable list containing elements of given set.
-
listFromMap
Returns a mutable list containing entry set elements of given map.- Type Parameters:
K- Type of entry.V- Value of entry.- Parameters:
a- Map to be converted to list.- Returns:
- mutable list containing entry set elements of given map.
-
immutableListFromMap
Returns an immutable list containing an arbitrary number of elements.- Type Parameters:
K- Type of entry.V- Value of entry.- Parameters:
a- Map to be converted to list.- Returns:
- immutable list containing entry set elements of given map.
-
setOf
Returns a mutable set containing an arbitrary number of elements.- Type Parameters:
T- Type of given parameters.- Parameters:
a- Array of given parameters.- Returns:
- mutable set containing an arbitrary number of elements.
-
immutableSetOf
Returns an immutable set containing an arbitrary number of elements.- Type Parameters:
T- Type of given parameters.- Parameters:
a- Array of given parameters.- Returns:
- immutable set containing an arbitrary number of elements.
-
mapEntry
Returns aMap.Entrycontaining the given key and value.- Type Parameters:
K- new key type to be stored in this entry.V- new value type to be stored in this entry.- Parameters:
a- new key to be stored in this entry.b- new value to be stored in this entry.- Returns:
- new
Map.Entrycontaining the given key and value.
-
mapOf
Returns a mutable map containing an arbitrary number of elements.- Type Parameters:
K- key type to be stored in this map.V- value type to be stored in this map.- Parameters:
a- Array of given entries to be stored in this map.- Returns:
- Returns a mutable map containing an arbitrary number of elements.
-
mapOf
Returns an mutable map containing one element.- Type Parameters:
K- key type to be stored in this map.V- value type to be stored in this map.- Parameters:
a- key to be stored in this map.b- value to be stored in this map.- Returns:
- Returns an mutable map containing one element.
-
immutableMapOf
Returns an immutable map containing one element.- Type Parameters:
K- key type to be stored in this map.V- value type to be stored in this map.- Parameters:
a- key to be stored in this map.b- value to be stored in this map.- Returns:
- Returns an immutable map containing one element.
-
immutableMapOf
Returns an immutable map containing an arbitrary number of elements.- Type Parameters:
K- key type to be stored in this map.V- value type to be stored in this map.- Parameters:
a- Array of given entries to be stored in this map.- Returns:
- immutable map containing an arbitrary number of elements.
-
streamOf
Returns a sequential ordered stream whose elements are the specified values.- Type Parameters:
T- the type of stream elements- Parameters:
a- the elements of the new stream- Returns:
- the new stream
-
contains
Checks if the object is in the given array.The method returns false if a null array is passed in.
- Parameters:
objectToFind- the object to findarray- the array to search through- Returns:
- true if the array contains the object
-
addAll
Adds all the elements in the specified collection to this collection (optional operation). The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified collection is this collection, and this collection is nonempty.)- Parameters:
collection- containing elements to be added to this collection- Returns:
trueif this collection changed as a result of the call- Throws:
UnsupportedOperationException- if theaddAlloperation is not supported by this collectionClassCastException- if the class of an element of the specified collection prevents it from being added to this collectionNullPointerException- if the specified collection contains a null element and this collection does not permit null elements, or if the specified collection is nullIllegalArgumentException- if some property of an element of the specified collection prevents it from being added to this collectionIllegalStateException- if not all the elements can be added at this time due to insertion restrictions
-