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 backingHashSetinstance has the specified initial capacity and default load factor.CaseInsensitiveSet(int initialCapacity, float loadFactor)Constructs a new, empty case-insensitive set; the backingHashSetinstance 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 booleanadd(String e)Adds the specified element to the set if it is not already present (optional operation).booleanaddAll(Collection<? extends String> c)Adds all of the elements in the specified collection to the set if they're not already present (optional operation).voidclear()Removes all of the elements from the set (optional operation).booleancontains(Object o)Returnstrueif the set contains the specified element.booleancontainsAll(Collection<?> c)Returnstrueif the set contains all of the elements of the specified collection.booleanremove(Object o)Removes the specified element from the set if it is present (optional operation).booleanremoveAll(Collection<?> c)Removes from the set all of its elements that are contained in the specified collection (optional operation).booleanretainAll(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 newHashSetwith 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. TheHashSetis 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 backingHashSetinstance 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 backingHashSetinstance 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:SetDecoratorReturnstrueif the set contains the specified element.- Specified by:
containsin interfaceCollection<String>- Specified by:
containsin interfaceSet<String>- Overrides:
containsin classSetDecorator<String>- Parameters:
o- element whose presence in the set is to be tested.- Returns:
trueif the set contains the specified element.
-
add
public boolean add(String e)
Description copied from class:SetDecoratorAdds the specified element to the set if it is not already present (optional operation).- Specified by:
addin interfaceCollection<String>- Specified by:
addin interfaceSet<String>- Overrides:
addin classSetDecorator<String>- Parameters:
e- element to be added to the set.- Returns:
trueif the set did not already contain the specified element.
-
remove
public boolean remove(Object o)
Description copied from class:SetDecoratorRemoves the specified element from the set if it is present (optional operation).- Specified by:
removein interfaceCollection<String>- Specified by:
removein interfaceSet<String>- Overrides:
removein classSetDecorator<String>- Parameters:
o- object to be removed from the set, if present.- Returns:
trueif the set contained the specified element.
-
containsAll
public boolean containsAll(Collection<?> c)
Description copied from class:SetDecoratorReturnstrueif the set contains all of the elements of the specified collection.- Specified by:
containsAllin interfaceCollection<String>- Specified by:
containsAllin interfaceSet<String>- Overrides:
containsAllin classSetDecorator<String>- Parameters:
c- collection to be checked for containment in the set.- Returns:
trueif the set contains all of the elements of the specified collection.
-
addAll
public boolean addAll(Collection<? extends String> c)
Description copied from class:SetDecoratorAdds all of the elements in the specified collection to the set if they're not already present (optional operation).- Specified by:
addAllin interfaceCollection<String>- Specified by:
addAllin interfaceSet<String>- Overrides:
addAllin classSetDecorator<String>- Parameters:
c- collection containing elements to be added to the set.- Returns:
trueif the set changed as a result of the call.
-
retainAll
public boolean retainAll(Collection<?> c)
Description copied from class:SetDecoratorRetains only the elements in the set that are contained in the specified collection (optional operation).- Specified by:
retainAllin interfaceCollection<String>- Specified by:
retainAllin interfaceSet<String>- Overrides:
retainAllin classSetDecorator<String>- Parameters:
c- collection containing elements to be retained in the set.- Returns:
trueif the set changed as a result of the call.
-
removeAll
public boolean removeAll(Collection<?> c)
Description copied from class:SetDecoratorRemoves from the set all of its elements that are contained in the specified collection (optional operation).- Specified by:
removeAllin interfaceCollection<String>- Specified by:
removeAllin interfaceSet<String>- Overrides:
removeAllin classSetDecorator<String>- Parameters:
c- collection containing elements to be removed from the set.- Returns:
trueif the set changed as a result of the call.
-
clear
public void clear()
Description copied from class:SetDecoratorRemoves all of the elements from the set (optional operation).- Specified by:
clearin interfaceCollection<String>- Specified by:
clearin interfaceSet<String>- Overrides:
clearin classSetDecorator<String>
-
-