Package org.eclipse.xtext.xbase.lib
Class CollectionLiterals
- java.lang.Object
-
- org.eclipse.xtext.xbase.lib.CollectionLiterals
-
@GwtCompatible public class CollectionLiterals extends java.lang.ObjectThis is an extension library forcollections.
-
-
Constructor Summary
Constructors Constructor Description CollectionLiterals()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> java.util.List<T>emptyList()Returns the empty, immutable list.static <K,V>
java.util.Map<K,V>emptyMap()Returns the empty, immutable map.static <T> java.util.Set<T>emptySet()Returns the empty, immutable set.static <T> java.util.ArrayList<T>newArrayList()Creates an empty mutableArrayListinstance.static <T> java.util.ArrayList<T>newArrayList(T... initial)Creates a mutableArrayListinstance containing the given initial elements.static <K,V>
java.util.HashMap<K,V>newHashMap()Creates an empty mutableHashMapinstance.static <K,V>
java.util.HashMap<K,V>newHashMap(Pair<? extends K,? extends V>... initial)Creates a mutableHashMapinstance containing the given initial entries.static <T> java.util.HashSet<T>newHashSet()Creates an empty mutableHashSetinstance.static <T> java.util.HashSet<T>newHashSet(T... initial)Creates a mutableHashSetinstance containing the given initial elements.static <T> java.util.List<T>newImmutableList(T... elements)Returns an immutable list containing the given elements, in order.static <K,V>
java.util.Map<K,V>newImmutableMap(Pair<? extends K,? extends V>... entries)Returns an immutable map containing the given entries.static <T> java.util.Set<T>newImmutableSet(T... elements)Returns an immutable set containing the given elements.static <K,V>
java.util.LinkedHashMap<K,V>newLinkedHashMap()Creates an empty mutableLinkedHashMapinstance.static <K,V>
java.util.LinkedHashMap<K,V>newLinkedHashMap(Pair<? extends K,? extends V>... initial)Creates a mutableLinkedHashMapinstance containing the given initial entries.static <T> java.util.LinkedHashSet<T>newLinkedHashSet()Creates an empty mutableLinkedHashSetinstance.static <T> java.util.LinkedHashSet<T>newLinkedHashSet(T... initial)Creates a mutableLinkedHashSetinstance containing the given initial elements.static <T> java.util.LinkedList<T>newLinkedList()Creates an empty mutableLinkedListinstance.static <T> java.util.LinkedList<T>newLinkedList(T... initial)Creates a mutableLinkedListinstance containing the given initial elements.static <K,V>
java.util.TreeMap<K,V>newTreeMap(java.util.Comparator<? super K> comparator)Creates an empty mutableTreeMapinstance.static <K,V>
java.util.TreeMap<K,V>newTreeMap(java.util.Comparator<? super K> comparator, Pair<? extends K,? extends V>... initial)Creates a mutableTreeMapinstance containing the given initial entries.static <T> java.util.TreeSet<T>newTreeSet(java.util.Comparator<? super T> comparator)Creates an empty mutableTreeSetinstance.static <T> java.util.TreeSet<T>newTreeSet(java.util.Comparator<? super T> comparator, T... initial)Creates a mutableTreeSetinstance containing the given initial elements.
-
-
-
Method Detail
-
emptyList
@Pure public static <T> java.util.List<T> emptyList()
Returns the empty, immutable list.- Returns:
- an empty, immutable list.
- See Also:
Collections.emptyList()
-
emptySet
@Pure public static <T> java.util.Set<T> emptySet()
Returns the empty, immutable set.- Returns:
- an empty, immutable set.
- See Also:
Collections.emptySet()
-
emptyMap
@Pure public static <K,V> java.util.Map<K,V> emptyMap()
Returns the empty, immutable map.- Returns:
- an empty, immutable map.
- See Also:
Collections.emptyMap()
-
newImmutableList
@Pure @SafeVarargs public static <T> java.util.List<T> newImmutableList(T... elements)
Returns an immutable list containing the given elements, in order.- Parameters:
elements- the elements that should be contained in the list. May not benullor contain anynullvalues.- Returns:
- an immutable list containing the given elements.
- Throws:
java.lang.NullPointerException- ifelementsor any of items inelementsisnull
-
newImmutableSet
@Pure @SafeVarargs public static <T> java.util.Set<T> newImmutableSet(T... elements)
Returns an immutable set containing the given elements. Repeated occurrences of an element (according toObject.equals(java.lang.Object)) after the first are ignored- Parameters:
elements- the elements that should be contained in the set. May not benullor contain anynullvalues.- Returns:
- an immutable set containing the given elements.
- Throws:
java.lang.NullPointerException- ifelementsor any of items inelementsisnull
-
newImmutableMap
@Pure @SafeVarargs public static <K,V> java.util.Map<K,V> newImmutableMap(Pair<? extends K,? extends V>... entries)
Returns an immutable map containing the given entries. Repeated occurrences of a keys will cause anIllegalArgumentException.- Parameters:
entries- the entries that should be contained in the map. May not benulland may not contain anynullkeys or values.- Returns:
- an immutable map containing the given entries.
- Throws:
java.lang.NullPointerException- ifentriesor any key or value inentriesisnulljava.lang.IllegalArgumentException- if duplicate keys are contained inentries.
-
newArrayList
@Pure public static <T> java.util.ArrayList<T> newArrayList()
Creates an empty mutableArrayListinstance.- Returns:
- a new
ArrayList - Since:
- 2.13
-
newArrayList
@SafeVarargs @Pure public static <T> java.util.ArrayList<T> newArrayList(T... initial)
Creates a mutableArrayListinstance containing the given initial elements.- Parameters:
initial- the initial elements that the list should contain, in order. May not benullbut may containnullvalues.- Returns:
- a new
ArrayListcontaining those elements
-
newLinkedList
@Pure public static <T> java.util.LinkedList<T> newLinkedList()
Creates an empty mutableLinkedListinstance.- Returns:
- a new
LinkedList - Since:
- 2.13
-
newLinkedList
@SafeVarargs @Pure public static <T> java.util.LinkedList<T> newLinkedList(T... initial)
Creates a mutableLinkedListinstance containing the given initial elements.- Parameters:
initial- the initial elements that the list should contain, in order. May not benullbut may containnullvalues.- Returns:
- a new
LinkedListcontaining those elements
-
newHashSet
@Pure public static <T> java.util.HashSet<T> newHashSet()
Creates an empty mutableHashSetinstance.- Returns:
- a new
HashSet - Since:
- 2.13
-
newHashSet
@SafeVarargs @Pure public static <T> java.util.HashSet<T> newHashSet(T... initial)
Creates a mutableHashSetinstance containing the given initial elements.- Parameters:
initial- the initial elements that the set should contain, in order. May not benullbut may containnullvalues.- Returns:
- a new
HashSetcontaining those elements
-
newLinkedHashSet
@Pure public static <T> java.util.LinkedHashSet<T> newLinkedHashSet()
Creates an empty mutableLinkedHashSetinstance.- Returns:
- a new
LinkedHashSet - Since:
- 2.13
-
newLinkedHashSet
@SafeVarargs @Pure public static <T> java.util.LinkedHashSet<T> newLinkedHashSet(T... initial)
Creates a mutableLinkedHashSetinstance containing the given initial elements.- Parameters:
initial- the initial elements that the set should contain, in order. May not benullbut may containnullvalues.- Returns:
- a new
LinkedHashSetcontaining those elements
-
newTreeSet
@Pure public static <T> java.util.TreeSet<T> newTreeSet(java.util.Comparator<? super T> comparator)
Creates an empty mutableTreeSetinstance.- Parameters:
comparator- the comparator that should be used. May benullwhich indicates that the natural ordering of the items should be used.- Returns:
- a new
TreeSet - Since:
- 2.13
-
newTreeSet
@SafeVarargs @Pure public static <T> java.util.TreeSet<T> newTreeSet(java.util.Comparator<? super T> comparator, T... initial)
Creates a mutableTreeSetinstance containing the given initial elements.- Parameters:
initial- the initial elements that the set should contain, in order. May not benullbut may containnullvalues.comparator- the comparator that should be used. May benullwhich indicates that the natural ordering of the items should be used.- Returns:
- a new
TreeSetcontaining those elements
-
newHashMap
@Pure public static <K,V> java.util.HashMap<K,V> newHashMap()
Creates an empty mutableHashMapinstance.- Returns:
- a new
HashMap - Since:
- 2.13
-
newHashMap
@SafeVarargs @Pure public static <K,V> java.util.HashMap<K,V> newHashMap(Pair<? extends K,? extends V>... initial)
Creates a mutableHashMapinstance containing the given initial entries. Repeated occurrences of a keys will cause anIllegalArgumentException.- Parameters:
initial- the entries that should be contained in the map. May not benullbut may containnullkeys or values.- Returns:
- a new
HashMapcontaining those elements - Throws:
java.lang.IllegalArgumentException- if duplicate keys are contained theinitialentries.
-
newLinkedHashMap
@Pure public static <K,V> java.util.LinkedHashMap<K,V> newLinkedHashMap()
Creates an empty mutableLinkedHashMapinstance.- Returns:
- a new
LinkedHashMap - Since:
- 2.13
-
newLinkedHashMap
@SafeVarargs @Pure public static <K,V> java.util.LinkedHashMap<K,V> newLinkedHashMap(Pair<? extends K,? extends V>... initial)
Creates a mutableLinkedHashMapinstance containing the given initial entries. Repeated occurrences of a keys will cause anIllegalArgumentException.- Parameters:
initial- the entries that should be contained in the map. May not benullbut may containnullkeys or values.- Returns:
- a new
LinkedHashMapcontaining those elements - Throws:
java.lang.IllegalArgumentException- if duplicate keys are contained theinitialentries.
-
newTreeMap
@Pure public static <K,V> java.util.TreeMap<K,V> newTreeMap(java.util.Comparator<? super K> comparator)
Creates an empty mutableTreeMapinstance.- Parameters:
comparator- the comparator that should be used. May benullwhich indicates that the natural ordering of the keys should be used.- Returns:
- a new
TreeMap - Since:
- 2.13
-
newTreeMap
@SafeVarargs @Pure public static <K,V> java.util.TreeMap<K,V> newTreeMap(java.util.Comparator<? super K> comparator, Pair<? extends K,? extends V>... initial)
Creates a mutableTreeMapinstance containing the given initial entries. Repeated occurrences of a keys will cause anIllegalArgumentException.- Parameters:
initial- the entries that should be contained in the map. May not benullbut may containnullkeys or values.comparator- the comparator that should be used. May benullwhich indicates that the natural ordering of the keys should be used.- Returns:
- a new
TreeMapcontaining those elements - Throws:
java.lang.IllegalArgumentException- if duplicate keys are contained theinitialentries.
-
-