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 valueNullPointerExceptionis 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 voidadd(int index, java.lang.String element)Inserts the specified element at the specified position in this list.booleanadd(java.lang.String e)Appends the specified element to the end of this list.booleanaddAll(int index, java.util.Collection<? extends java.lang.String> c)booleanaddAll(java.util.Collection<? extends java.lang.String> c)java.lang.Objectclone()intindexOf(java.lang.Object elem)intlastIndexOf(java.lang.Object elem)booleanremove(java.lang.Object o)booleanremoveAll(java.util.Collection<?> c)booleanretainAll(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. TheArrayListinstance 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:
addin interfacejava.util.Collection<java.lang.String>- Specified by:
addin interfacejava.util.List<java.lang.String>- Overrides:
addin 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:
addin interfacejava.util.List<java.lang.String>- Overrides:
addin 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.IndexOutOfBoundsExceptionjava.lang.NullPointerException- if null value is added
-
addAll
public boolean addAll(java.util.Collection<? extends java.lang.String> c)
- Specified by:
addAllin interfacejava.util.Collection<java.lang.String>- Specified by:
addAllin interfacejava.util.List<java.lang.String>- Overrides:
addAllin classjava.util.ArrayList<java.lang.String>
-
addAll
public boolean addAll(int index, java.util.Collection<? extends java.lang.String> c)- Specified by:
addAllin interfacejava.util.List<java.lang.String>- Overrides:
addAllin classjava.util.ArrayList<java.lang.String>
-
indexOf
public int indexOf(java.lang.Object elem)
- Specified by:
indexOfin interfacejava.util.List<java.lang.String>- Overrides:
indexOfin classjava.util.ArrayList<java.lang.String>
-
lastIndexOf
public int lastIndexOf(java.lang.Object elem)
- Specified by:
lastIndexOfin interfacejava.util.List<java.lang.String>- Overrides:
lastIndexOfin classjava.util.ArrayList<java.lang.String>
-
clone
public java.lang.Object clone()
- Overrides:
clonein classjava.util.ArrayList<java.lang.String>
-
remove
public boolean remove(java.lang.Object o)
- Specified by:
removein interfacejava.util.Collection<java.lang.String>- Specified by:
removein interfacejava.util.List<java.lang.String>- Overrides:
removein classjava.util.ArrayList<java.lang.String>
-
removeAll
public boolean removeAll(java.util.Collection<?> c)
- Specified by:
removeAllin interfacejava.util.Collection<java.lang.String>- Specified by:
removeAllin interfacejava.util.List<java.lang.String>- Overrides:
removeAllin classjava.util.ArrayList<java.lang.String>
-
retainAll
public boolean retainAll(java.util.Collection<?> c)
- Specified by:
retainAllin interfacejava.util.Collection<java.lang.String>- Specified by:
retainAllin interfacejava.util.List<java.lang.String>- Overrides:
retainAllin classjava.util.ArrayList<java.lang.String>
-
-