java.lang.Object
org.eclipse.xtext.xbase.lib.CollectionExtensions
This is an extension library for
collections.- Author:
- Sven Efftinge - Initial contribution and API, Sebastian Zarnekow
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> booleanaddAll(Collection<? super T> collection, T... elements) Adds all of the specified elements to the specified collection.static <T> booleanaddAll(Collection<T> collection, Iterable<? extends T> elements) Adds all of the specified elements to the specified collection.static <T> List<T>immutableCopy(List<? extends T> list) Returns an immutable copy of the specifiedlist.static <K,V> Map<K, V> immutableCopy(Map<? extends K, ? extends V> map) Returns an immutable copy of the specifiedmap.static <T> Set<T>immutableCopy(Set<? extends T> set) Returns an immutable copy of the specifiedset.static <K,V> SortedMap<K, V> immutableCopy(SortedMap<K, ? extends V> map) Returns an immutable copy of the specified sortedmap.static <T> SortedSet<T>immutableCopy(SortedSet<T> set) Returns an immutable copy of the specified sortedset.static <E> booleanoperator_add(Collection<? super E> collection, E value) The operator mapping from+=toCollection.add(Object).static <E> booleanoperator_add(Collection<E> collection, Iterable<? extends E> newElements) The operator mapping from+=toaddAll(Collection, Iterable).static <E> booleanoperator_remove(Collection<? super E> collection, E value) The operator mapping from-=toCollection.remove(Object).static <E> booleanoperator_remove(Collection<E> collection, Collection<? extends E> newElements) The operator mapping from-=toremoveAll(Collection, Collection).static <T> booleanremoveAll(Collection<? super T> collection, T... elements) Removes all of the specified elements from the specified collection.static <T> booleanremoveAll(Collection<T> collection, Iterable<? extends T> elements) Removes all of the specified elements from the specified collection.static <T> booleanremoveAll(Collection<T> collection, Collection<? extends T> elements) Removes all of the specified elements from the specified collection.static <T> Collection<T>unmodifiableView(Collection<? extends T> collection) Returns an unmodifiable view of the specifiedcollection.static <T> List<T>unmodifiableView(List<? extends T> list) Returns an unmodifiable view of the specifiedlist.static <K,V> Map<K, V> unmodifiableView(Map<? extends K, ? extends V> map) Returns an unmodifiable view of the specifiedmap.static <T> Set<T>unmodifiableView(Set<? extends T> set) Returns an unmodifiable view of the specifiedset.static <K,V> SortedMap<K, V> unmodifiableView(SortedMap<K, ? extends V> map) Returns an unmodifiable view of the specified sortedmap.static <T> SortedSet<T>unmodifiableView(SortedSet<T> set) Returns an unmodifiable view of the specified sortedset.
-
Constructor Details
-
CollectionExtensions
public CollectionExtensions()
-
-
Method Details
-
operator_add
The operator mapping from+=toCollection.add(Object). Returnstrueif the collection changed due to this operation.- Parameters:
collection- the to-be-changed collection. May not benull.value- the value that should be added to the collection.- Returns:
trueif the collection changed due to this operation.- See Also:
-
operator_add
The operator mapping from+=toaddAll(Collection, Iterable). Returnstrueif the collection changed due to this operation.- Parameters:
collection- the to-be-changed collection. May not benull.newElements- elements to be inserted into the collection. May not benullbut may containnullelements if the target collection supportsnullelements.- Returns:
trueif the collection changed due to this operation.- See Also:
-
operator_remove
The operator mapping from-=toCollection.remove(Object). Returnstrueif the collection changed due to this operation.- Parameters:
collection- the to-be-changed collection. May not benull.value- the value that should be removed from the collection.- Returns:
trueif the collection changed due to this operation.- Since:
- 2.4
- See Also:
-
operator_remove
public static <E> boolean operator_remove(Collection<E> collection, Collection<? extends E> newElements) The operator mapping from-=toremoveAll(Collection, Collection). Returnstrueif the collection changed due to this operation.- Parameters:
collection- the to-be-changed collection. May not benull.newElements- elements to be removed from the collection. May not benullbut may containnullelements if the target collection supportsnullelements.- Returns:
trueif the collection changed due to this operation.- Since:
- 2.4
- See Also:
-
unmodifiableView
Returns an unmodifiable view of the specifiedlist.- Parameters:
list- the list for which an unmodifiable view is to be returned. May not benull.- Returns:
- an unmodifiable view of the specified list.
- See Also:
-
unmodifiableView
Returns an unmodifiable view of the specifiedcollection.- Parameters:
collection- the collection for which an unmodifiable view is to be returned. May not benull.- Returns:
- an unmodifiable view of the specified collection.
- See Also:
-
unmodifiableView
Returns an unmodifiable view of the specifiedset.- Parameters:
set- the set for which an unmodifiable view is to be returned. May not benull.- Returns:
- an unmodifiable view of the specified set.
- See Also:
-
unmodifiableView
Returns an unmodifiable view of the specified sortedset.- Parameters:
set- the sorted set for which an unmodifiable view is to be returned. May not benull.- Returns:
- an unmodifiable view of the specified sorted set.
- See Also:
-
unmodifiableView
Returns an unmodifiable view of the specifiedmap.- Parameters:
map- the map for which an unmodifiable view is to be returned. May not benull.- Returns:
- an unmodifiable view of the specified map.
- See Also:
-
unmodifiableView
Returns an unmodifiable view of the specified sortedmap.- Parameters:
map- the sorted map for which an unmodifiable view is to be returned. May not benull.- Returns:
- an unmodifiable view of the specified sorted map.
- See Also:
-
immutableCopy
Returns an immutable copy of the specifiedlist.- Parameters:
list- the list for which an immutable copy should be created. May not benull.- Returns:
- an immutable copy of the specified list.
-
immutableCopy
Returns an immutable copy of the specifiedset.- Parameters:
set- the set for which an immutable copy should be created. May not benull.- Returns:
- an immutable copy of the specified set.
-
immutableCopy
Returns an immutable copy of the specified sortedset.- Parameters:
set- the sorted set for which an immutable copy should be created. May not benull.- Returns:
- an immutable copy of the specified sorted set.
-
immutableCopy
Returns an immutable copy of the specifiedmap.- Parameters:
map- the map for which an immutable copy should be created. May not benull.- Returns:
- an immutable copy of the specified map.
-
immutableCopy
Returns an immutable copy of the specified sortedmap.- Parameters:
map- the sorted map for which an immutable copy should be created. May not benull.- Returns:
- an immutable copy of the specified sorted map.
-
addAll
Adds all of the specified elements to the specified collection.- Parameters:
collection- the collection into which theelementsare to be inserted. May not benull.elements- the elements to insert into thecollection. May not benullbut may containnullentries if thecollectionallows that.- Returns:
trueif the collection changed as a result of the call
-
addAll
Adds all of the specified elements to the specified collection.- Parameters:
collection- the collection into which theelementsare to be inserted. May not benull.elements- the elements to insert into thecollection. May not benullbut may containnullentries if thecollectionallows that.- Returns:
trueif the collection changed as a result of the call
-
removeAll
Removes all of the specified elements from the specified collection.- Parameters:
collection- the collection from which theelementsare to be removed. May not benull.elements- the elements be remove from thecollection. May not benullbut may containnullentries if thecollectionallows that.- Returns:
trueif the collection changed as a result of the call- Since:
- 2.4
-
removeAll
Removes all of the specified elements from the specified collection.- Parameters:
collection- the collection from which theelementsare to be removed. May not benull.elements- the elements to remove from thecollection. May not benullbut may containnullentries if thecollectionallows that.- Returns:
trueif the collection changed as a result of the call- Since:
- 2.4
-
removeAll
Removes all of the specified elements from the specified collection.- Parameters:
collection- the collection from which theelementsare to be removed. May not benull.elements- the elements to remove from thecollection. May not benullbut may containnullentries if thecollectionallows that.- Returns:
trueif the collection changed as a result of the call- Since:
- 2.4
-