Package com.im.commons.util
Class CaseInsensitiveList
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.ArrayList<java.lang.String>
-
- com.im.commons.util.CaseInsensitiveList
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.lang.Iterable<java.lang.String>
,java.util.Collection<java.lang.String>
,java.util.List<java.lang.String>
,java.util.RandomAccess
public final class CaseInsensitiveList extends java.util.ArrayList<java.lang.String>
This class is a copy of ArrayList implementation, specialized for Strings. Comparisons are case-sensitive. The list cannot contain null values. In case of adding null valueNullPointerException
is thrown.- Author:
- svata
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description CaseInsensitiveList()
Constructs an empty list with an initial capacity of ten.CaseInsensitiveList(int initialCapacity)
Constructs an empty list with the specified initial capacity.CaseInsensitiveList(java.util.Collection<java.lang.String> c)
Constructs a list containing the elements of the specified collection, in the order they are returned by the collection's iterator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index, java.lang.String element)
Inserts the specified element at the specified position in this list.boolean
add(java.lang.String e)
Appends the specified element to the end of this list.boolean
addAll(int index, java.util.Collection<? extends java.lang.String> c)
boolean
addAll(java.util.Collection<? extends java.lang.String> c)
java.lang.Object
clone()
int
indexOf(java.lang.Object elem)
int
lastIndexOf(java.lang.Object elem)
boolean
remove(java.lang.Object o)
boolean
removeAll(java.util.Collection<?> c)
boolean
retainAll(java.util.Collection<?> c)
-
Methods inherited from class java.util.ArrayList
clear, contains, ensureCapacity, equals, forEach, get, hashCode, isEmpty, iterator, listIterator, listIterator, remove, removeIf, removeRange, replaceAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
-
-
-
-
Constructor Detail
-
CaseInsensitiveList
public CaseInsensitiveList(int initialCapacity)
Constructs an empty list with the specified initial capacity.- Parameters:
initialCapacity
- The initial capacity of the list.- Throws:
java.lang.IllegalArgumentException
- if the specified initial capacity is negative
-
CaseInsensitiveList
public CaseInsensitiveList()
Constructs an empty list with an initial capacity of ten.
-
CaseInsensitiveList
public CaseInsensitiveList(java.util.Collection<java.lang.String> c)
Constructs a list containing the elements of the specified collection, in the order they are returned by the collection's iterator. TheArrayList
instance has an initial capacity of 110% the size of the specified collection.- Parameters:
c
- The collection whose elements are to be placed into this list.- Throws:
java.lang.NullPointerException
- if the specified collection is null.
-
-
Method Detail
-
add
public boolean add(java.lang.String e)
Appends the specified element to the end of this list.- Specified by:
add
in interfacejava.util.Collection<java.lang.String>
- Specified by:
add
in interfacejava.util.List<java.lang.String>
- Overrides:
add
in classjava.util.ArrayList<java.lang.String>
- Parameters:
e
- element to be appended to this list- Returns:
true
(as specified byCollection.add(E)
)- Throws:
java.lang.NullPointerException
- if null value is added
-
add
public void add(int index, java.lang.String element)
Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).- Specified by:
add
in interfacejava.util.List<java.lang.String>
- Overrides:
add
in classjava.util.ArrayList<java.lang.String>
- Parameters:
index
- index at which the specified element is to be insertedelement
- element to be inserted- Throws:
java.lang.IndexOutOfBoundsException
java.lang.NullPointerException
- if null value is added
-
addAll
public boolean addAll(java.util.Collection<? extends java.lang.String> c)
- Specified by:
addAll
in interfacejava.util.Collection<java.lang.String>
- Specified by:
addAll
in interfacejava.util.List<java.lang.String>
- Overrides:
addAll
in classjava.util.ArrayList<java.lang.String>
-
addAll
public boolean addAll(int index, java.util.Collection<? extends java.lang.String> c)
- Specified by:
addAll
in interfacejava.util.List<java.lang.String>
- Overrides:
addAll
in classjava.util.ArrayList<java.lang.String>
-
indexOf
public int indexOf(java.lang.Object elem)
- Specified by:
indexOf
in interfacejava.util.List<java.lang.String>
- Overrides:
indexOf
in classjava.util.ArrayList<java.lang.String>
-
lastIndexOf
public int lastIndexOf(java.lang.Object elem)
- Specified by:
lastIndexOf
in interfacejava.util.List<java.lang.String>
- Overrides:
lastIndexOf
in classjava.util.ArrayList<java.lang.String>
-
clone
public java.lang.Object clone()
- Overrides:
clone
in classjava.util.ArrayList<java.lang.String>
-
remove
public boolean remove(java.lang.Object o)
- Specified by:
remove
in interfacejava.util.Collection<java.lang.String>
- Specified by:
remove
in interfacejava.util.List<java.lang.String>
- Overrides:
remove
in classjava.util.ArrayList<java.lang.String>
-
removeAll
public boolean removeAll(java.util.Collection<?> c)
- Specified by:
removeAll
in interfacejava.util.Collection<java.lang.String>
- Specified by:
removeAll
in interfacejava.util.List<java.lang.String>
- Overrides:
removeAll
in classjava.util.ArrayList<java.lang.String>
-
retainAll
public boolean retainAll(java.util.Collection<?> c)
- Specified by:
retainAll
in interfacejava.util.Collection<java.lang.String>
- Specified by:
retainAll
in interfacejava.util.List<java.lang.String>
- Overrides:
retainAll
in classjava.util.ArrayList<java.lang.String>
-
-