类 CollectionUtils
- 作者:
- TODAY 2019-12-29 23:39
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static voidaddAll(ArrayHolder c, Object[] elements) static voidaddAll(ArrayHolder c, Collection elements) static voidaddAll(Collection c, Object[] elements) Adds all of the specified elements to the specified collection.static voidaddAll(Collection c, Collection elements) Adds all of the specified elements to the specified collection.static voidaddAll(Collection c, Enumeration values) Adds all of the specified elements to the specified collection.static List<?>arrayToList(Object source) Convert the supplied array into a List.static <K,V> MultiValueMap<K, V> static <K,V> MultiValueMap<K, V> static booleanCheck whether the given Iterable contains the given element.static booleancontains(Enumeration<?> enumeration, Object element) Check whether the given Enumeration contains the given element.static booleanCheck whether the given Iterator contains the given element.static booleancontainsAny(Collection<?> source, Collection<?> candidates) Returntrueif any element in 'candidates' is contained in 'source'; otherwise returnsfalse.static booleancontainsInstance(Collection<?> collection, Object element) Check whether the given Collection contains the given element instance.static <E> Collection<E>createApproximateCollection(Object collection, int capacity) Create the most approximate collection for the given collection.static <K,V> Map<K, V> Create the most approximate map for the given map.static <K,V> Map<K, V> createApproximateMap(Object map, int capacity) Create the most approximate map for the given map.static <E> Collection<E>createCollection(Class<?> collectionType) Create the most appropriate collection for the given collection type.static <E> Collection<E>createCollection(Class<?> collectionType, int capacity) Create the most appropriate collection for the given collection type.static <E> Collection<E>createCollection(Class<?> collectionType, Class<?> elementType, int capacity) Create the most appropriate collection for the given collection type.static <K,V> Map<K, V> Create the most appropriate map for the given map type.static <K,V> Map<K, V> Create the most appropriate map for the given map type.static <K,V> Map<K, V> Create the most appropriate map for the given map type.static PropertiescreateSortedProperties(boolean omitComments) Create a variant ofPropertiesthat sorts properties alphanumerically based on their keys.static PropertiescreateSortedProperties(Properties properties, boolean omitComments) Create a variant ofPropertiesthat sorts properties alphanumerically based on their keys.static PropertiesCreate a variant ofPropertiesthat automatically adapts non-String values to String representations inProperties.getProperty(java.lang.String).static <T> voidfilter(Collection<T> collection, Predicate<? super T> predicate) remove the elements of this collection that match the given predicate.static <E> EfindFirstMatch(Collection<?> source, Collection<E> candidates) Return the first element in 'candidates' that is contained in 'source'.static ObjectfindValueOfType(Collection<?> collection, Class<?>[] types) Find a single value of one of the given types in the given Collection: searching the Collection for a value of the first type, then searching for a value of the second type, etc.static <T> TfindValueOfType(Collection<?> collection, Class<T> type) Find a single value of the given type in the given Collection.static <T> TfirstElement(Iterable<T> iterable) Retrieve the first element of the given Iterable, usingSortedSet.first()or otherwise using the iterator.static <T> TfirstElement(List<T> list) Retrieve the first element of the given List, accessing the zero index.static <T> TfirstElement(T[] array) Retrieve the first element of the given Array, accessing the zero index.static <T> TgetElement(List<T> list, int index) Returns the element at the specified position in this list.static <T> TgetElement(T[] array, int index) Returns the element at the specified position in this list.static booleanhasUniqueObject(Collection<?> collection) Determine whether the given Collection only contains a single unique object.static booleanisApproximableCollectionType(Class<?> collectionType) Determine whether the given collection type is an approximable type, i.e. a type thatcreateApproximateCollection(java.lang.Object, int)can approximate.static booleanisApproximableMapType(Class<?> mapType) Determine whether the given map type is an approximable type, i.e. a type thatcreateApproximateMap(java.lang.Object)can approximate.static booleanisCollection(Class<?> cls) static booleanisEmpty(ArrayHolder<?> holder) Returntrueif the supplied Collection isnullor empty.static booleanisEmpty(Collection<?> collection) Returntrueif the supplied Collection isnullor empty.static booleanReturntrueif the supplied Map isnullor empty.static booleanisNotEmpty(ArrayHolder<?> holder) Returntrueif the supplied Collection is notnulland empty.static booleanisNotEmpty(Collection<?> collection) static booleanisNotEmpty(Map<?, ?> map) static <T> voiditerate(Enumeration<T> enumeration, Consumer<T> consumer) static <T> voidstatic <T> TlastElement(List<T> list) Retrieve the last element of the given List, accessing the highest index.static <T> TlastElement(Set<T> set) Retrieve the last element of the given Set, usingSortedSet.last()or otherwise iterating over all elements (assuming a linked set).static <T> TlastElement(T[] array) Retrieve the last element of the given array, accessing the highest index.static <E> voidmergeArrayIntoCollection(Object array, Collection<E> collection) Merge the given array into the given Collection.static <K,V> void mergePropertiesIntoMap(Properties props, Map<K, V> map) Merge the given Properties instance into the given Map, copying all properties (key-value pairs) over.static <E> ArrayList<E>newArrayList(E... elements) static <K,V> HashMap<K, V> newHashMap(int expectedSize) Instantiate a newHashMapwith an initial capacity that can accommodate the specified number of elements without any immediate resize/rehash operations to be expected.static <E> HashSet<E>newHashSet(E... elements) Create a hash setstatic <K,V> LinkedHashMap<K, V> newLinkedHashMap(int expectedSize) Instantiate a newLinkedHashMapwith an initial capacity that can accommodate the specified number of elements without any immediate resize/rehash operations to be expected.static <E> LinkedHashSet<E>newLinkedHashSet(E... elements) Instantiate a newLinkedHashSetwith an initial elements that can accommodate the specified number of elements without any immediate resize/rehash operations to be expected.static voidCopies all of the mappings from the specified map to target map (optional operation).static <K,V> void reverse source map key-value to target map value-keystatic voidReplaces the element at the specified position in this list with the specified element (optional operation).static <E> Iterator<E>singletonIterator(E e) static <A,E extends A>
A[]toArray(Enumeration<E> enumeration, A[] array) Marshal the elements from the given enumeration into an array of the given type.static <A,E extends A>
A[]Marshal the elements from the given iterator into an array of the given type.static <E> Iterator<E>toIterator(Enumeration<E> enumeration) Adapt anEnumerationto anIterator.static <T,R> List<R> transform(Collection<? extends T> c, Function<T, R> transformer) transform T to Rstatic voidtrimToSize(Object list) Trims the capacity of ArrayList instance to be the list's current size.
-
构造器详细资料
-
CollectionUtils
public CollectionUtils()
-
-
方法详细资料
-
isEmpty
Returntrueif the supplied Collection isnullor empty. Otherwise, returnfalse.- 参数:
collection- the Collection to check- 返回:
- whether the given Collection is empty
-
isNotEmpty
- 从以下版本开始:
- 4.0
-
isNotEmpty
Returntrueif the supplied Collection is notnulland empty. Otherwise, returnfalse.- 参数:
holder- the ArrayHolder to check- 返回:
- whether the given ArrayHolder is not empty
- 从以下版本开始:
- 4.0
-
isEmpty
Returntrueif the supplied Collection isnullor empty. Otherwise, returnfalse.- 参数:
holder- the ArrayHolder to check- 返回:
- whether the given ArrayHolder is empty
- 从以下版本开始:
- 4.0
-
isEmpty
Returntrueif the supplied Map isnullor empty. Otherwise, returnfalse.- 参数:
map- the Map to check- 返回:
- whether the given Map is empty
-
isNotEmpty
- 从以下版本开始:
- 4.0
-
isCollection
-
newHashSet
Create a hash set- 参数:
elements- Elements instance
-
newLinkedHashSet
Instantiate a newLinkedHashSetwith an initial elements that can accommodate the specified number of elements without any immediate resize/rehash operations to be expected.- 参数:
elements- the expected number of elements (with a corresponding capacity to be derived so that no resize/rehash operations are needed)- 从以下版本开始:
- 4.0
- 另请参阅:
-
newArrayList
- 类型参数:
E- Element type- 参数:
elements- elements array- 返回:
- ArrayLost of input elements
- 从以下版本开始:
- 4.0
-
isApproximableCollectionType
Determine whether the given collection type is an approximable type, i.e. a type thatcreateApproximateCollection(java.lang.Object, int)can approximate.- 参数:
collectionType- the collection type to check- 返回:
trueif the type is approximable- 从以下版本开始:
- 3.0
-
createApproximateCollection
Create the most approximate collection for the given collection.Warning: Since the parameterized type
Eis not bound to the type of elements contained in the suppliedcollection, type safety cannot be guaranteed if the suppliedcollectionis anEnumSet. In such scenarios, the caller is responsible for ensuring that the element type for the suppliedcollectionis an enum type matching typeE. As an alternative, the caller may wish to treat the return value as a raw collection or collection ofObject.- 参数:
collection- the original collection object, potentiallynullcapacity- the initial capacity- 返回:
- a new, empty collection instance
- 从以下版本开始:
- 3.0
- 另请参阅:
-
createCollection
Create the most appropriate collection for the given collection type.Delegates to
createCollection(Class, Class, int)with anullelement type, andConstant.ZERO.- 参数:
collectionType- the desired type of the target collection (nevernull)- 返回:
- a new collection instance
- 抛出:
IllegalArgumentException- if the suppliedcollectionTypeisnullor of typeEnumSet- 从以下版本开始:
- 3.0
-
createCollection
Create the most appropriate collection for the given collection type.Delegates to
createCollection(Class, Class, int)with anullelement type.- 参数:
collectionType- the desired type of the target collection (nevernull)capacity- the initial capacity- 返回:
- a new collection instance
- 抛出:
IllegalArgumentException- if the suppliedcollectionTypeisnullor of typeEnumSet- 从以下版本开始:
- 3.0
-
createCollection
public static <E> Collection<E> createCollection(Class<?> collectionType, Class<?> elementType, int capacity) Create the most appropriate collection for the given collection type.Warning: Since the parameterized type
Eis not bound to the suppliedelementType, type safety cannot be guaranteed if the desiredcollectionTypeisEnumSet. In such scenarios, the caller is responsible for ensuring that the suppliedelementTypeis an enum type matching typeE. As an alternative, the caller may wish to treat the return value as a raw collection or collection ofObject.- 参数:
collectionType- the desired type of the target collection (nevernull)elementType- the collection's element type, ornullif unknown (note: only relevant forEnumSetcreation)capacity- the initial capacity- 返回:
- a new collection instance
- 抛出:
IllegalArgumentException- if the suppliedcollectionTypeisnull; or if the desiredcollectionTypeisEnumSetand the suppliedelementTypeis not a subtype ofEnum- 从以下版本开始:
- 3.0
- 另请参阅:
-
isApproximableMapType
Determine whether the given map type is an approximable type, i.e. a type thatcreateApproximateMap(java.lang.Object)can approximate.- 参数:
mapType- the map type to check- 返回:
trueif the type is approximable- 从以下版本开始:
- 3.0
-
createApproximateMap
Create the most approximate map for the given map.Warning: Since the parameterized type
Kis not bound to the type of keys contained in the suppliedmap, type safety cannot be guaranteed if the suppliedmapis anEnumMap. In such scenarios, the caller is responsible for ensuring that the key type in the suppliedmapis an enum type matching typeK. As an alternative, the caller may wish to treat the return value as a raw map or map keyed byObject.use default capacity
Constant.ZERO.- 参数:
map- the original map object, potentiallynull- 返回:
- a new, empty map instance
- 从以下版本开始:
- 3.0
- 另请参阅:
-
createApproximateMap
Create the most approximate map for the given map.Warning: Since the parameterized type
Kis not bound to the type of keys contained in the suppliedmap, type safety cannot be guaranteed if the suppliedmapis anEnumMap. In such scenarios, the caller is responsible for ensuring that the key type in the suppliedmapis an enum type matching typeK. As an alternative, the caller may wish to treat the return value as a raw map or map keyed byObject.- 参数:
map- the original map object, potentiallynullcapacity- the initial capacity- 返回:
- a new, empty map instance
- 从以下版本开始:
- 3.0
- 另请参阅:
-
createMap
Create the most appropriate map for the given map type.Delegates to
createMap(Class, Class, int)with anullkey type, and default capacityConstant.ZERO.- 参数:
mapType- the desired type of the target map- 返回:
- a new map instance
- 抛出:
IllegalArgumentException- if the suppliedmapTypeisnullor of typeEnumMap- 从以下版本开始:
- 3.0
-
createMap
Create the most appropriate map for the given map type.Delegates to
createMap(Class, Class, int)with anullkey type.- 参数:
mapType- the desired type of the target mapcapacity- the initial capacity- 返回:
- a new map instance
- 抛出:
IllegalArgumentException- if the suppliedmapTypeisnullor of typeEnumMap- 从以下版本开始:
- 3.0
-
createMap
Create the most appropriate map for the given map type.Warning: Since the parameterized type
Kis not bound to the suppliedkeyType, type safety cannot be guaranteed if the desiredmapTypeisEnumMap. In such scenarios, the caller is responsible for ensuring that thekeyTypeis an enum type matching typeK. As an alternative, the caller may wish to treat the return value as a raw map or map keyed byObject. Similarly, type safety cannot be enforced if the desiredmapTypeisMultiValueMap.- 参数:
mapType- the desired type of the target map (nevernull)keyType- the map's key type, ornullif unknown (note: only relevant forEnumMapcreation)capacity- the initial capacity- 返回:
- a new map instance
- 抛出:
IllegalArgumentException- if the suppliedmapTypeisnull; or if the desiredmapTypeisEnumMapand the suppliedkeyTypeis not a subtype ofEnum- 从以下版本开始:
- 3.0
- 另请参阅:
-
createStringAdaptingProperties
Create a variant ofPropertiesthat automatically adapts non-String values to String representations inProperties.getProperty(java.lang.String).In addition, the returned
Propertiesinstance sorts properties alphanumerically based on their keys.- 返回:
- a new
Propertiesinstance - 从以下版本开始:
- 3.0
- 另请参阅:
-
createSortedProperties
Create a variant ofPropertiesthat sorts properties alphanumerically based on their keys.This can be useful when storing the
Propertiesinstance in a properties file, since it allows such files to be generated in a repeatable manner with consistent ordering of properties. Comments in generated properties files can also be optionally omitted.- 参数:
omitComments-trueif comments should be omitted when storing properties in a file- 返回:
- a new
Propertiesinstance - 从以下版本开始:
- 3.0
- 另请参阅:
-
createSortedProperties
Create a variant ofPropertiesthat sorts properties alphanumerically based on their keys.This can be useful when storing the
Propertiesinstance in a properties file, since it allows such files to be generated in a repeatable manner with consistent ordering of properties. Comments in generated properties files can also be optionally omitted.The returned
Propertiesinstance will be populated with properties from the suppliedpropertiesobject, but default properties from the suppliedpropertiesobject will not be copied.- 参数:
properties- thePropertiesobject from which to copy the initial propertiesomitComments-trueif comments should be omitted when storing properties in a file- 返回:
- a new
Propertiesinstance - 从以下版本开始:
- 3.0
- 另请参阅:
-
setValue
Replaces the element at the specified position in this list with the specified element (optional operation).- 参数:
list- target listindex- new element's indexelement- element object- 抛出:
IndexOutOfBoundsException- if the index is out of range (index < 0 || index >= size())NullPointerException- if the specified element is null and this list does not permit null elements- 从以下版本开始:
- 3.0
- 另请参阅:
-
getElement
Returns the element at the specified position in this list.list can be
null, then returnsnull- 参数:
index- index of the element to return- 返回:
- the element at the specified position in this list
- 从以下版本开始:
- 4.0
- 另请参阅:
-
getElement
Returns the element at the specified position in this list.list can be
null, then returnsnull- 参数:
index- index of the element to return- 返回:
- the element at the specified position in this list
- 从以下版本开始:
- 4.0
- 另请参阅:
-
addAll
Adds all of the specified elements to the specified collection. Elements to be added may be specified individually or as an array. The behavior of this convenience method is identical to that of c.addAll(Arrays.asList(elements)), but this method is likely to run significantly faster under most implementations.When elements are specified individually, this method provides a convenient way to add a few elements to an existing collection:
CollectionUtils.addAll(flavors, "Peaches 'n Plutonium", "Rocky Racoon"); CollectionUtils.addAll(flavors, null); // add nothing element can be null- 类型参数:
T- the class of the elements to add and of the collection- 参数:
c- the collection into which elements are to be insertedelements- the elements to insert into c- 抛出:
UnsupportedOperationException- if c does not support the add operationNullPointerException- if elements contains one or more null values and c does not permit null elements, or if c or elements are nullIllegalArgumentException- if some property of a value in elements prevents it from being added to c- 从以下版本开始:
- 4.0
- 另请参阅:
-
addAll
Adds all of the specified elements to the specified collection. Elements to be added may be specified individually or as Enumeration.- 类型参数:
T- the class of the elements to add and of the collection- 参数:
c- the collection into which elements are to be insertedvalues- the elements to insert into c- 抛出:
UnsupportedOperationException- if c does not support the add operationNullPointerException- if elements contains one or more null values and c does not permit null elements, or if c or elements are nullIllegalArgumentException- if some property of a value in elements prevents it from being added to c- 从以下版本开始:
- 4.0
- 另请参阅:
-
addAll
Adds all of the specified elements to the specified collection. Elements to be added may be specified individually or as an array. The behavior of this convenience method is identical to that of c.addAll(Arrays.asList(elements)), but this method is likely to run significantly faster under most implementations.When elements are specified individually, this method provides a convenient way to add a few elements to an existing collection:
CollectionUtils.addAll(flavors, list); CollectionUtils.addAll(flavors, null); // add nothing element can be null- 类型参数:
T- the class of the elements to add and of the collection- 参数:
c- the collection into which elements are to be insertedelements- the elements to insert into c- 抛出:
UnsupportedOperationException- if c does not support the add operationNullPointerException- if elements contains one or more null values and c does not permit null elements, or if c or elements are nullIllegalArgumentException- if some property of a value in elements prevents it from being added to c- 从以下版本开始:
- 4.0
- 另请参阅:
-
addAll
- 从以下版本开始:
- 4.0
-
addAll
- 从以下版本开始:
- 4.0
-
putAll
Copies all of the mappings from the specified map to target map (optional operation). The effect of this call is equivalent to that of callingput(k, v)on this map once for each mapping from key k to value v in the specified map. The behavior of this operation is undefined if the specified map is modified while the operation is in progress.- 参数:
mappings- mappings to be stored in target map- 抛出:
UnsupportedOperationException- if the putAll operation is not supported by this mapClassCastException- if the class of a key or value in the specified map prevents it from being stored in this mapNullPointerException- if the specified map is null, or if this map does not permit null keys or values, and the specified map contains null keys or valuesIllegalArgumentException- if some property of a key or value in the specified map prevents it from being stored in this map
-
iterate
- 从以下版本开始:
- 4.0
-
iterate
- 从以下版本开始:
- 4.0
-
trimToSize
Trims the capacity of ArrayList instance to be the list's current size. An application can use this operation to minimize the storage of an ArrayList instance.- 从以下版本开始:
- 4.0
- 另请参阅:
-
reverse
reverse source map key-value to target map value-key- 从以下版本开始:
- 4.0
-
filter
remove the elements of this collection that match the given predicate.- 参数:
predicate- a predicate to apply to each element to determine if it should be removed- 从以下版本开始:
- 4.0
- 另请参阅:
-
transform
transform T to R- 类型参数:
T- value typeR- transformed value type- 参数:
c- collectiontransformer- transformer- 从以下版本开始:
- 4.0
-
buckets
-
buckets
-
firstElement
Retrieve the first element of the given Iterable, usingSortedSet.first()or otherwise using the iterator.- 参数:
iterable- the iterable to check (may benullor empty)- 返回:
- the first element, or
nullif none - 从以下版本开始:
- 4.0
- 另请参阅:
-
firstElement
Retrieve the first element of the given List, accessing the zero index.- 参数:
list- the List to check (may benullor empty)- 返回:
- the first element, or
nullif none - 从以下版本开始:
- 4.0
-
firstElement
Retrieve the first element of the given Array, accessing the zero index.- 参数:
array- the array to check (may benullor empty)- 返回:
- the first element, or
nullif none - 从以下版本开始:
- 4.0
-
lastElement
Retrieve the last element of the given List, accessing the highest index.- 参数:
list- the List to check (may benullor empty)- 返回:
- the last element, or
nullif none - 从以下版本开始:
- 4.0
-
lastElement
Retrieve the last element of the given array, accessing the highest index.- 参数:
array- the array to check (may benullor empty)- 返回:
- the last element, or
nullif none - 从以下版本开始:
- 4.0
-
lastElement
Retrieve the last element of the given Set, usingSortedSet.last()or otherwise iterating over all elements (assuming a linked set).- 参数:
set- the Set to check (may benullor empty)- 返回:
- the last element, or
nullif none - 从以下版本开始:
- 4.0
- 另请参阅:
-
toArray
Marshal the elements from the given enumeration into an array of the given type. Enumeration elements must be assignable to the type of the given array. The array returned will be a different instance than the array given.- 从以下版本开始:
- 4.0
- 另请参阅:
-
toArray
Marshal the elements from the given iterator into an array of the given type. Iterator elements must be assignable to the type of the given array. The array returned will be a different instance than the array given.- 从以下版本开始:
- 4.0
- 另请参阅:
-
toIterator
Adapt anEnumerationto anIterator.- 参数:
enumeration- the originalEnumeration- 返回:
- the adapted
Iterator - 从以下版本开始:
- 4.0
-
singletonIterator
- 从以下版本开始:
- 4.0
-
newHashMap
Instantiate a newHashMapwith an initial capacity that can accommodate the specified number of elements without any immediate resize/rehash operations to be expected.This differs from the regular
HashMapconstructor which takes an initial capacity relative to a load factor but is effectively aligned with the JDK'sConcurrentHashMap(int).- 参数:
expectedSize- the expected number of elements (with a corresponding capacity to be derived so that no resize/rehash operations are needed)- 从以下版本开始:
- 4.0
- 另请参阅:
-
newLinkedHashMap
Instantiate a newLinkedHashMapwith an initial capacity that can accommodate the specified number of elements without any immediate resize/rehash operations to be expected.- 参数:
expectedSize- the expected number of elements (with a corresponding capacity to be derived so that no resize/rehash operations are needed)- 从以下版本开始:
- 4.0
- 另请参阅:
-
arrayToList
Convert the supplied array into a List. A primitive array gets converted into a List of the appropriate wrapper type.NOTE: Generally prefer the standard
Arrays.asList(T...)method. ThisarrayToListmethod is just meant to deal with an incoming Object value that might be anObject[]or a primitive array at runtime.A
nullsource value will be converted to an empty List.- 参数:
source- the (potentially primitive) array- 返回:
- the converted List result
- 从以下版本开始:
- 4.0
- 另请参阅:
-
mergeArrayIntoCollection
Merge the given array into the given Collection.- 参数:
array- the array to merge (may benull)collection- the target Collection to merge the array into- 从以下版本开始:
- 4.0
-
mergePropertiesIntoMap
Merge the given Properties instance into the given Map, copying all properties (key-value pairs) over.Uses
Properties.propertyNames()to even catch default properties linked into the original Properties instance.- 参数:
props- the Properties instance to merge (may benull)map- the target Map to merge the properties into- 从以下版本开始:
- 4.0
-
contains
Check whether the given Iterator contains the given element.- 参数:
iterator- the Iterator to checkelement- the element to look for- 返回:
trueif found,falseotherwise- 从以下版本开始:
- 4.0
-
contains
Check whether the given Enumeration contains the given element.- 参数:
enumeration- the Enumeration to checkelement- the element to look for- 返回:
trueif found,falseotherwise- 从以下版本开始:
- 4.0
-
contains
Check whether the given Iterable contains the given element.- 参数:
iterable- the Iterable to checkelement- the element to look for- 返回:
trueif found,falseotherwise- 从以下版本开始:
- 4.0
-
containsInstance
Check whether the given Collection contains the given element instance.Enforces the given instance to be present, rather than returning
truefor an equal element as well.- 参数:
collection- the Collection to checkelement- the element to look for- 返回:
trueif found,falseotherwise- 从以下版本开始:
- 4.0
-
containsAny
Returntrueif any element in 'candidates' is contained in 'source'; otherwise returnsfalse.- 参数:
source- the source Collectioncandidates- the candidates to search for- 返回:
- whether any of the candidates has been found
- 从以下版本开始:
- 4.0
-
findFirstMatch
Return the first element in 'candidates' that is contained in 'source'. If no element in 'candidates' is present in 'source' returnsnull. Iteration order isCollectionimplementation specific.- 参数:
source- the source Collectioncandidates- the candidates to search for- 返回:
- the first present object, or
nullif not found - 从以下版本开始:
- 4.0
-
hasUniqueObject
Determine whether the given Collection only contains a single unique object.- 参数:
collection- the Collection to check- 返回:
trueif the collection contains a single reference or multiple references to the same instance,falseotherwise- 从以下版本开始:
- 4.0
-
findValueOfType
Find a single value of the given type in the given Collection.- 参数:
collection- the Collection to searchtype- the type to look for- 返回:
- a value of the given type found if there is a clear match,
or
nullif none or more than one such value found - 从以下版本开始:
- 4.0
-
findValueOfType
Find a single value of one of the given types in the given Collection: searching the Collection for a value of the first type, then searching for a value of the second type, etc.- 参数:
collection- the collection to searchtypes- the types to look for, in prioritized order- 返回:
- a value of one of the given types found if there is a clear match,
or
nullif none or more than one such value found - 从以下版本开始:
- 4.0
-