Package org.apereo.cas.util
Class CollectionUtils
- java.lang.Object
-
- org.apereo.cas.util.CollectionUtils
-
public class CollectionUtils extends java.lang.ObjectThis isCollectionUtils.- Since:
- 5.0.0
-
-
Constructor Summary
Constructors Constructor Description CollectionUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.springframework.util.MultiValueMapasMultiValueMap(java.lang.String key, java.lang.Object value)As multi value map.static org.springframework.util.MultiValueMapasMultiValueMap(java.lang.String key1, java.lang.Object value1, java.lang.String key2, java.lang.Object value2)As multi value map.static org.springframework.util.MultiValueMapasMultiValueMap(java.util.Map innerMap)As multi value map.static java.util.Map<java.lang.String,java.lang.String>convertDirectedListToMap(java.util.Collection<java.lang.String> inputList)Convert directed list to map.static java.util.Optional<java.lang.Object>firstElement(java.lang.Object obj)Converts the provided object into a collection and return the first element, or empty.static <T> java.util.Optional<T>firstElement(java.lang.Object obj, java.lang.Class<T> clazz)Converts the provided object into a collection and return the first element, or empty.static java.util.Map<java.lang.String,java.lang.Object>merge(java.util.Map<java.lang.String,?>... attributes)Merge map.static java.util.Set<java.lang.Object>toCollection(java.lang.Object obj)Convert the object given into aCollectioninstead.static <T extends java.util.Collection>
TtoCollection(java.lang.Object obj, java.lang.Class<T> clazz)To collection t.static <K,V>
java.util.Map<K,V>wrap(com.google.common.collect.Multimap<K,V> source)Wrap map.static <K,V>
java.util.Map<K,V>wrap(java.lang.String key, java.lang.Object value)Wrap map.static <K extends java.lang.String,V>
java.util.Map<K,V>wrap(java.lang.String key, java.lang.Object value, java.lang.String key2, java.lang.Object value2)Wrap map.static <K,V>
java.util.Map<K,V>wrap(java.lang.String key, java.lang.Object value, java.lang.String key2, java.lang.Object value2, java.lang.String key3, java.lang.Object value3)Wrap map.static <K,V>
java.util.Map<K,V>wrap(java.lang.String key, java.lang.Object value, java.lang.String key2, java.lang.Object value2, java.lang.String key3, java.lang.Object value3, java.lang.String key4, java.lang.Object value4)Wrap map.static <K,V>
java.util.Map<K,V>wrap(java.lang.String key, java.lang.Object value, java.lang.String key2, java.lang.Object value2, java.lang.String key3, java.lang.Object value3, java.lang.String key4, java.lang.Object value4, java.lang.String key5, java.lang.Object value5)Wrap map.static <K,V>
java.util.Map<K,V>wrap(java.lang.String key, java.lang.Object value, java.lang.String key2, java.lang.Object value2, java.lang.String key3, java.lang.Object value3, java.lang.String key4, java.lang.Object value4, java.lang.String key5, java.lang.Object value5, java.lang.String key6, java.lang.Object value6)Wrap map.static <K,V>
java.util.Map<K,V>wrap(java.lang.String key, java.lang.Object value, java.lang.String key2, java.lang.Object value2, java.lang.String key3, java.lang.Object value3, java.lang.String key4, java.lang.Object value4, java.lang.String key5, java.lang.Object value5, java.lang.String key6, java.lang.Object value6, java.lang.String key7, java.lang.Object value7)Wrap map.static <K,V>
java.util.Map<K,V>wrap(java.lang.String key, java.lang.Object value, java.lang.String key2, java.lang.Object value2, java.lang.String key3, java.lang.Object value3, java.lang.String key4, java.lang.Object value4, java.lang.String key5, java.lang.Object value5, java.lang.String key6, java.lang.Object value6, java.lang.String key7, java.lang.Object value7, java.lang.String key8, java.lang.Object value8)Wrap map.static <K,V>
java.util.Map<K,V>wrap(java.lang.String key, java.lang.Object value, java.lang.String key2, java.lang.Object value2, java.lang.String key3, java.lang.Object value3, java.lang.String key4, java.lang.Object value4, java.lang.String key5, java.lang.Object value5, java.lang.String key6, java.lang.Object value6, java.lang.String key7, java.lang.Object value7, java.lang.String key8, java.lang.Object value8, java.lang.String key9, java.lang.Object value9)Wrap map.static <T> java.util.List<T>wrap(java.util.List<T> source)Wraps a possibly null list in an immutable wrapper.static <K,V>
java.util.Map<K,V>wrap(java.util.Map<K,V> source)Wraps a possibly null map in an immutable wrapper.static <T> java.util.Set<T>wrap(java.util.Set<T> source)Wrap varargs.static <T> java.util.List<T>wrap(T source)Wraps a possibly null list in an immutable wrapper.static <T> java.util.ArrayList<T>wrapArrayList(T... source)Wrap array list array list.static <T> java.util.Collection<T>wrapCollection(T... source)Wrap collection.static <T> java.util.HashSet<T>wrapHashSet(java.util.Collection<T> source)Wrap hash set.static <T> java.util.HashSet<T>wrapHashSet(T... source)Wrap hash set.static <T> java.util.Map<java.lang.String,T>wrapLinkedHashMap(java.lang.String key, T source)Wrap linked hash map.static <T> java.util.List<T>wrapList(T... source)Wrap list.static <T> java.util.Set<T>wrapSet(T source)Wrap set set.static <T> java.util.Set<T>wrapSet(T... source)Wrap set.
-
-
-
Method Detail
-
firstElement
public static java.util.Optional<java.lang.Object> firstElement(java.lang.Object obj)
Converts the provided object into a collection and return the first element, or empty.- Parameters:
obj- the obj- Returns:
- the optional
-
firstElement
public static <T> java.util.Optional<T> firstElement(java.lang.Object obj, java.lang.Class<T> clazz)Converts the provided object into a collection and return the first element, or empty.- Type Parameters:
T- the type parameter- Parameters:
obj- the objclazz- the clazz- Returns:
- the optional
-
toCollection
public static <T extends java.util.Collection> T toCollection(java.lang.Object obj, java.lang.Class<T> clazz)To collection t.- Type Parameters:
T- the type parameter- Parameters:
obj- the objclazz- the clazz- Returns:
- the t
-
toCollection
public static java.util.Set<java.lang.Object> toCollection(java.lang.Object obj)
Convert the object given into aCollectioninstead.- Parameters:
obj- the object to convert into a collection- Returns:
- The collection instance containing the object provided
-
wrap
public static <K,V> java.util.Map<K,V> wrap(com.google.common.collect.Multimap<K,V> source)
Wrap map.- Type Parameters:
K- the type parameterV- the type parameter- Parameters:
source- the source- Returns:
- the map
-
wrap
public static <K,V> java.util.Map<K,V> wrap(java.util.Map<K,V> source)
Wraps a possibly null map in an immutable wrapper.- Type Parameters:
K- the key typeV- the value type- Parameters:
source- map to wrap.- Returns:
- the map
-
wrap
public static <K,V> java.util.Map<K,V> wrap(java.lang.String key, java.lang.Object value)Wrap map.- Type Parameters:
K- the type parameterV- the type parameter- Parameters:
key- the keyvalue- the value- Returns:
- the map
-
wrap
public static <K extends java.lang.String,V> java.util.Map<K,V> wrap(java.lang.String key, java.lang.Object value, java.lang.String key2, java.lang.Object value2)Wrap map.- Type Parameters:
K- the type parameterV- the type parameter- Parameters:
key- the keyvalue- the valuekey2- the key 2value2- the value 2- Returns:
- the map
-
wrap
public static <K,V> java.util.Map<K,V> wrap(java.lang.String key, java.lang.Object value, java.lang.String key2, java.lang.Object value2, java.lang.String key3, java.lang.Object value3)Wrap map.- Type Parameters:
K- the type parameterV- the type parameter- Parameters:
key- the keyvalue- the valuekey2- the key 2value2- the value 2key3- the key 3value3- the value 3- Returns:
- the map
-
wrap
public static <K,V> java.util.Map<K,V> wrap(java.lang.String key, java.lang.Object value, java.lang.String key2, java.lang.Object value2, java.lang.String key3, java.lang.Object value3, java.lang.String key4, java.lang.Object value4)Wrap map.- Type Parameters:
K- the type parameterV- the type parameter- Parameters:
key- the keyvalue- the valuekey2- the key 2value2- the value 2key3- the key 3value3- the value 3key4- the key 4value4- the value 4- Returns:
- the map
-
wrap
public static <K,V> java.util.Map<K,V> wrap(java.lang.String key, java.lang.Object value, java.lang.String key2, java.lang.Object value2, java.lang.String key3, java.lang.Object value3, java.lang.String key4, java.lang.Object value4, java.lang.String key5, java.lang.Object value5)Wrap map.- Type Parameters:
K- the type parameterV- the type parameter- Parameters:
key- the keyvalue- the valuekey2- the key 2value2- the value 2key3- the key 3value3- the value 3key4- the key 4value4- the value 4key5- the key 5value5- the value 5- Returns:
- the map
-
wrap
public static <K,V> java.util.Map<K,V> wrap(java.lang.String key, java.lang.Object value, java.lang.String key2, java.lang.Object value2, java.lang.String key3, java.lang.Object value3, java.lang.String key4, java.lang.Object value4, java.lang.String key5, java.lang.Object value5, java.lang.String key6, java.lang.Object value6)Wrap map.- Type Parameters:
K- the type parameterV- the type parameter- Parameters:
key- the keyvalue- the valuekey2- the key 2value2- the value 2key3- the key 3value3- the value 3key4- the key 4value4- the value 4key5- the key 5value5- the value 5key6- the key 6value6- the value 6- Returns:
- the map
-
wrap
public static <K,V> java.util.Map<K,V> wrap(java.lang.String key, java.lang.Object value, java.lang.String key2, java.lang.Object value2, java.lang.String key3, java.lang.Object value3, java.lang.String key4, java.lang.Object value4, java.lang.String key5, java.lang.Object value5, java.lang.String key6, java.lang.Object value6, java.lang.String key7, java.lang.Object value7)Wrap map.- Type Parameters:
K- the type parameterV- the type parameter- Parameters:
key- the keyvalue- the valuekey2- the key 2value2- the value 2key3- the key 3value3- the value 3key4- the key 4value4- the value 4key5- the key 5value5- the value 5key6- the key 6value6- the value 6key7- the key 7value7- the value 7- Returns:
- the map
-
wrap
public static <K,V> java.util.Map<K,V> wrap(java.lang.String key, java.lang.Object value, java.lang.String key2, java.lang.Object value2, java.lang.String key3, java.lang.Object value3, java.lang.String key4, java.lang.Object value4, java.lang.String key5, java.lang.Object value5, java.lang.String key6, java.lang.Object value6, java.lang.String key7, java.lang.Object value7, java.lang.String key8, java.lang.Object value8)Wrap map.- Type Parameters:
K- the type parameterV- the type parameter- Parameters:
key- the keyvalue- the valuekey2- the key 2value2- the value 2key3- the key 3value3- the value 3key4- the key 4value4- the value 4key5- the key 5value5- the value 5key6- the key 6value6- the value 6key7- the key 7value7- the value 7key8- the key 8value8- the value 8- Returns:
- the map
-
wrap
public static <K,V> java.util.Map<K,V> wrap(java.lang.String key, java.lang.Object value, java.lang.String key2, java.lang.Object value2, java.lang.String key3, java.lang.Object value3, java.lang.String key4, java.lang.Object value4, java.lang.String key5, java.lang.Object value5, java.lang.String key6, java.lang.Object value6, java.lang.String key7, java.lang.Object value7, java.lang.String key8, java.lang.Object value8, java.lang.String key9, java.lang.Object value9)Wrap map.- Type Parameters:
K- the type parameterV- the type parameter- Parameters:
key- the keyvalue- the valuekey2- the key 2value2- the value 2key3- the key 3value3- the value 3key4- the key 4value4- the value 4key5- the key 5value5- the value 5key6- the key 6value6- the value 6key7- the key 7value7- the value 7key8- the key 8value8- the value 8key9- the key 9value9- the value 9- Returns:
- the map
-
wrap
public static <T> java.util.List<T> wrap(T source)
Wraps a possibly null list in an immutable wrapper.- Type Parameters:
T- the type parameter- Parameters:
source- list to wrap.- Returns:
- the list
-
wrap
public static <T> java.util.List<T> wrap(java.util.List<T> source)
Wraps a possibly null list in an immutable wrapper.- Type Parameters:
T- the type parameter- Parameters:
source- list to wrap.- Returns:
- the list
-
wrap
public static <T> java.util.Set<T> wrap(java.util.Set<T> source)
Wrap varargs.- Type Parameters:
T- the type parameter- Parameters:
source- the source- Returns:
- the set
-
wrapSet
public static <T> java.util.Set<T> wrapSet(T source)
Wrap set set.- Type Parameters:
T- the type parameter- Parameters:
source- the source- Returns:
- the set
-
wrapSet
public static <T> java.util.Set<T> wrapSet(T... source)
Wrap set.- Type Parameters:
T- the type parameter- Parameters:
source- the source- Returns:
- the set
-
wrapHashSet
public static <T> java.util.HashSet<T> wrapHashSet(T... source)
Wrap hash set.- Type Parameters:
T- the type parameter- Parameters:
source- the source- Returns:
- the set
-
wrapHashSet
public static <T> java.util.HashSet<T> wrapHashSet(java.util.Collection<T> source)
Wrap hash set.- Type Parameters:
T- the type parameter- Parameters:
source- the source- Returns:
- the set
-
wrapList
public static <T> java.util.List<T> wrapList(T... source)
Wrap list.- Type Parameters:
T- the type parameter- Parameters:
source- the source- Returns:
- the set
-
wrapArrayList
public static <T> java.util.ArrayList<T> wrapArrayList(T... source)
Wrap array list array list.- Type Parameters:
T- the type parameter- Parameters:
source- the source- Returns:
- the array list
-
wrapLinkedHashMap
public static <T> java.util.Map<java.lang.String,T> wrapLinkedHashMap(java.lang.String key, T source)Wrap linked hash map.- Type Parameters:
T- the type parameter- Parameters:
key- the keysource- the source- Returns:
- the array list
-
asMultiValueMap
public static org.springframework.util.MultiValueMap asMultiValueMap(java.util.Map innerMap)
As multi value map.- Parameters:
innerMap- the inner map- Returns:
- the multi value map
-
asMultiValueMap
public static org.springframework.util.MultiValueMap asMultiValueMap(java.lang.String key, java.lang.Object value)As multi value map.- Parameters:
key- the keyvalue- the value- Returns:
- the multi value map
-
asMultiValueMap
public static org.springframework.util.MultiValueMap asMultiValueMap(java.lang.String key1, java.lang.Object value1, java.lang.String key2, java.lang.Object value2)As multi value map.- Parameters:
key1- the key 1value1- the value 1key2- the key 2value2- the value 2- Returns:
- the multi value map
-
convertDirectedListToMap
public static java.util.Map<java.lang.String,java.lang.String> convertDirectedListToMap(java.util.Collection<java.lang.String> inputList)
Convert directed list to map.- Parameters:
inputList- the input list- Returns:
- the map
-
wrapCollection
public static <T> java.util.Collection<T> wrapCollection(T... source)
Wrap collection.- Type Parameters:
T- the type parameter- Parameters:
source- the source- Returns:
- the collection
-
merge
public static java.util.Map<java.lang.String,java.lang.Object> merge(java.util.Map<java.lang.String,?>... attributes)
Merge map.- Parameters:
attributes- the attributes- Returns:
- the map
-
-