Java isempty collection utils

Java isempty collection utils

Returns true if no more elements can be added to the Collection. This method uses the BoundedCollection interface to determine the full status. If the collection does not implement this interface then false is returned. The collection does not have to implement this interface directly. If the collection has been decorated using the decorators subpackage then these will be removed to access the BoundedCollection.

maxSize

Get the maximum number of elements that the Collection can contain. This method uses the BoundedCollection interface to determine the maximum size. If the collection does not implement this interface then -1 is returned. The collection does not have to implement this interface directly. If the collection has been decorated using the decorators subpackage then these will be removed to access the BoundedCollection.

retainAll

public static Collection retainAll(Collection collection, Collection retain)

Returns a collection containing all the elements in collection that are also in retain . The cardinality of an element e in the returned collection is the same as the cardinality of e in collection unless retain does not contain e , in which case the cardinality is zero. This method is useful if you do not wish to modify the collection c and thus cannot call c.retainAll(retain); .

removeAll

public static Collection removeAll(Collection collection, Collection remove)

Removes the elements in remove from collection . That is, this method returns a collection containing all the elements in c that are not in remove . The cardinality of an element e in the returned collection is the same as the cardinality of e in collection unless remove contains e , in which case the cardinality is zero. This method is useful if you do not wish to modify the collection c and thus cannot call collection.removeAll(remove); .

Читайте также:  Arrow icon in html

synchronizedCollection

public static Collection synchronizedCollection(Collection collection)

Returns a synchronized collection backed by the given collection. You must manually synchronize on the returned buffer’s iterator to avoid non-deterministic behavior:

Collection c = CollectionUtils.synchronizedCollection(myCollection); synchronized (c) < Iterator i = c.iterator(); while (i.hasNext()) < process (i.next()); >>

unmodifiableCollection

public static Collection unmodifiableCollection(Collection collection)

Returns an unmodifiable collection backed by the given collection. This method uses the implementation in the decorators subpackage.

predicatedCollection

public static Collection predicatedCollection(Collection collection, Predicate predicate)

Returns a predicated (validating) collection backed by the given collection. Only objects that pass the test in the given predicate can be added to the collection. Trying to add an invalid object results in an IllegalArgumentException. It is important not to use the original collection after invoking this method, as it is a backdoor for adding invalid objects.

typedCollection

public static Collection typedCollection(Collection collection, Class type)

Returns a typed collection backed by the given collection. Only objects of the specified type can be added to the collection.

transformedCollection

public static Collection transformedCollection(Collection collection, Transformer transformer)

Returns a transformed bag backed by the given collection. Each object is passed through the transformer as it is added to the Collection. It is important not to use the original collection after invoking this method, as it is a backdoor for adding untransformed objects.

Источник

Оцените статью