Package org.forgerock.http.util
Class CaseInsensitiveSet
- java.lang.Object
-
- org.forgerock.http.util.SetDecorator<String>
-
- org.forgerock.http.util.CaseInsensitiveSet
-
public class CaseInsensitiveSet extends SetDecorator<String>
An implementation of a set whose values are case-insensitive strings. All operations match values in a case-insensitive manner. The original cases of values are retained, so theiterator()
method for example returns the originally values.Note: The behavior of this class is undefined when wrapping a set that has keys that would result in duplicate case-insensitive values.
-
-
Field Summary
-
Fields inherited from class org.forgerock.http.util.SetDecorator
set
-
-
Constructor Summary
Constructors Constructor Description CaseInsensitiveSet()
Constructs a new empty case-insensitive set.CaseInsensitiveSet(int initialCapacity)
Constructs a new, empty case-insensitive set; the backingHashSet
instance has the specified initial capacity and default load factor.CaseInsensitiveSet(int initialCapacity, float loadFactor)
Constructs a new, empty case-insensitive set; the backingHashSet
instance has the specified initial capacity and the specified load factor.CaseInsensitiveSet(Collection<String> c)
Constructs a new case-insensitive set containing the elements in the specified collection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(String e)
Adds the specified element to the set if it is not already present (optional operation).boolean
addAll(Collection<? extends String> c)
Adds all of the elements in the specified collection to the set if they're not already present (optional operation).void
clear()
Removes all of the elements from the set (optional operation).boolean
contains(Object o)
Returnstrue
if the set contains the specified element.boolean
containsAll(Collection<?> c)
Returnstrue
if the set contains all of the elements of the specified collection.boolean
remove(Object o)
Removes the specified element from the set if it is present (optional operation).boolean
removeAll(Collection<?> c)
Removes from the set all of its elements that are contained in the specified collection (optional operation).boolean
retainAll(Collection<?> c)
Retains only the elements in the set that are contained in the specified collection (optional operation).-
Methods inherited from class org.forgerock.http.util.SetDecorator
equals, hashCode, isEmpty, iterator, size, toArray, toArray
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.Set
spliterator
-
-
-
-
Constructor Detail
-
CaseInsensitiveSet
public CaseInsensitiveSet()
Constructs a new empty case-insensitive set. The backing set is a newHashSet
with default initial capacity and load factor.
-
CaseInsensitiveSet
public CaseInsensitiveSet(Collection<String> c)
Constructs a new case-insensitive set containing the elements in the specified collection. TheHashSet
is created with default load factor and an initial capacity sufficient to contain the elements in the specified collection.- Parameters:
c
- the collection whose elements are to be placed into this set.- Throws:
NullPointerException
- if the specified collection isnull
.
-
CaseInsensitiveSet
public CaseInsensitiveSet(int initialCapacity, float loadFactor)
Constructs a new, empty case-insensitive set; the backingHashSet
instance has the specified initial capacity and the specified load factor.- Parameters:
initialCapacity
- the initial capacity of the hash set.loadFactor
- the load factor of the hash set.- Throws:
IllegalArgumentException
- if the initial capacity is less than zero, or if the load factor is nonpositive.
-
CaseInsensitiveSet
public CaseInsensitiveSet(int initialCapacity)
Constructs a new, empty case-insensitive set; the backingHashSet
instance has the specified initial capacity and default load factor.- Parameters:
initialCapacity
- the initial capacity of the hash set.- Throws:
IllegalArgumentException
- if the initial capacity is less than zero.
-
-
Method Detail
-
contains
public boolean contains(Object o)
Description copied from class:SetDecorator
Returnstrue
if the set contains the specified element.- Specified by:
contains
in interfaceCollection<String>
- Specified by:
contains
in interfaceSet<String>
- Overrides:
contains
in classSetDecorator<String>
- Parameters:
o
- element whose presence in the set is to be tested.- Returns:
true
if the set contains the specified element.
-
add
public boolean add(String e)
Description copied from class:SetDecorator
Adds the specified element to the set if it is not already present (optional operation).- Specified by:
add
in interfaceCollection<String>
- Specified by:
add
in interfaceSet<String>
- Overrides:
add
in classSetDecorator<String>
- Parameters:
e
- element to be added to the set.- Returns:
true
if the set did not already contain the specified element.
-
remove
public boolean remove(Object o)
Description copied from class:SetDecorator
Removes the specified element from the set if it is present (optional operation).- Specified by:
remove
in interfaceCollection<String>
- Specified by:
remove
in interfaceSet<String>
- Overrides:
remove
in classSetDecorator<String>
- Parameters:
o
- object to be removed from the set, if present.- Returns:
true
if the set contained the specified element.
-
containsAll
public boolean containsAll(Collection<?> c)
Description copied from class:SetDecorator
Returnstrue
if the set contains all of the elements of the specified collection.- Specified by:
containsAll
in interfaceCollection<String>
- Specified by:
containsAll
in interfaceSet<String>
- Overrides:
containsAll
in classSetDecorator<String>
- Parameters:
c
- collection to be checked for containment in the set.- Returns:
true
if the set contains all of the elements of the specified collection.
-
addAll
public boolean addAll(Collection<? extends String> c)
Description copied from class:SetDecorator
Adds all of the elements in the specified collection to the set if they're not already present (optional operation).- Specified by:
addAll
in interfaceCollection<String>
- Specified by:
addAll
in interfaceSet<String>
- Overrides:
addAll
in classSetDecorator<String>
- Parameters:
c
- collection containing elements to be added to the set.- Returns:
true
if the set changed as a result of the call.
-
retainAll
public boolean retainAll(Collection<?> c)
Description copied from class:SetDecorator
Retains only the elements in the set that are contained in the specified collection (optional operation).- Specified by:
retainAll
in interfaceCollection<String>
- Specified by:
retainAll
in interfaceSet<String>
- Overrides:
retainAll
in classSetDecorator<String>
- Parameters:
c
- collection containing elements to be retained in the set.- Returns:
true
if the set changed as a result of the call.
-
removeAll
public boolean removeAll(Collection<?> c)
Description copied from class:SetDecorator
Removes from the set all of its elements that are contained in the specified collection (optional operation).- Specified by:
removeAll
in interfaceCollection<String>
- Specified by:
removeAll
in interfaceSet<String>
- Overrides:
removeAll
in classSetDecorator<String>
- Parameters:
c
- collection containing elements to be removed from the set.- Returns:
true
if the set changed as a result of the call.
-
clear
public void clear()
Description copied from class:SetDecorator
Removes all of the elements from the set (optional operation).- Specified by:
clear
in interfaceCollection<String>
- Specified by:
clear
in interfaceSet<String>
- Overrides:
clear
in classSetDecorator<String>
-
-