Class AbstractAttribute
- All Implemented Interfaces:
Iterable<ByteString>
,Collection<ByteString>
,Set<ByteString>
,Attribute
- Direct Known Subclasses:
CompactAttribute
,LinkedAttribute
Attribute
interface, to minimize the effort required to
implement this interface.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Adds all of the provided attribute values to this attribute if they are not already present (optional operation).boolean
addAll
(Collection<? extends ByteString> values) Adds all of the attribute values contained invalues
to this attribute if they are not already present (optional operation).<T> boolean
addAll
(Collection<T> values, Collection<? super T> duplicateValues) Adds all of the attribute values contained invalues
to this attribute if they are not already present (optional operation).boolean
Returnstrue
if this attribute containsvalue
.boolean
containsAll
(Collection<?> values) Returnstrue
if this attribute contains all of the attribute values contained invalues
.boolean
Returnstrue
ifobject
is an attribute which is equal to this attribute.Returns the first attribute value in this attribute.void
forEachNormalizedValue
(BiConsumer<? super ByteString, ? super ByteString> action) Performs the provided action for each value and its associated normalized value in this attribute.int
hashCode()
Returns the hash code for this attribute.boolean
isEmpty()
Returnstrue
if this attribute contains no attribute values.abstract Iterator<ByteString>
iterator()
Returns an iterator over the attribute values in this attribute.boolean
matchesAnyNormalizedValue
(Predicate<? super ByteString> predicate) Returnstrue
if any values in this attribute match the provided predicate.boolean
matchesAnyNormalizedValue
(Map<ByteString, ByteString> normalizedValues) Returnstrue
if any values in this attribute match at least one of the values in the provided map.static ByteString
normalizeValue
(Attribute attribute, ByteString value) Returns the normalized form ofvalue
normalized usingattribute
's equality matching rule.parse()
Returns a parser for this attribute which can be used for decoding values as different types of object.boolean
removeAll
(Collection<?> values) Removes all of the attribute values contained invalues
from this attribute if they are present (optional operation).<T> boolean
removeAll
(Collection<T> values, Collection<? super T> missingValues) Removes all of the attribute values contained invalues
from this attribute if they are present (optional operation).boolean
retainAll
(Collection<?> values) Retains only the attribute values in this attribute which are contained invalues
(optional operation).<T> boolean
retainAll
(Collection<T> values, Collection<? super T> missingValues) Retains only the attribute values in this attribute which are contained invalues
(optional operation).int
size()
Returns the number of attribute values in this attribute.toArray()
Returns an array containing all of the attribute values contained in this attribute.toString()
Returns a string representation of this attribute.Methods inherited from class java.util.AbstractCollection
add, clear, remove, toArray
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.forgerock.opendj.ldap.Attribute
add, clear, firstValueAsString, getAttributeDescription, getAttributeDescriptionAsString, isReal, isVirtual, put, put, remove, toArray
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Constructor Details
-
AbstractAttribute
protected AbstractAttribute()Sole constructor.
-
-
Method Details
-
normalizeValue
Returns the normalized form ofvalue
normalized usingattribute
's equality matching rule.- Parameters:
attribute
- The attribute whose equality matching rule should be used for normalization.value
- The attribute value to be normalized.- Returns:
- The normalized form of
value
normalized usingattribute
's equality matching rule.
-
add
Description copied from interface:Attribute
Adds all of the provided attribute values to this attribute if they are not already present (optional operation).Any attribute values which are not instances of
ByteString
will be converted using theByteString.valueOfObject(Object)
method. -
addAll
Description copied from interface:Attribute
Adds all of the attribute values contained invalues
to this attribute if they are not already present (optional operation).An invocation of this method is equivalent to:
attribute.addAll(values, null);
- Specified by:
addAll
in interfaceAttribute
- Specified by:
addAll
in interfaceCollection<ByteString>
- Specified by:
addAll
in interfaceSet<ByteString>
- Overrides:
addAll
in classAbstractCollection<ByteString>
- Parameters:
values
- The attribute values to be added to this attribute.- Returns:
true
if this attribute changed as a result of this call.
-
addAll
Description copied from interface:Attribute
Adds all of the attribute values contained invalues
to this attribute if they are not already present (optional operation). Any attribute values which are already present will be added toduplicateValues
if specified.Any attribute values which are not instances of
ByteString
will be converted using theByteString.valueOfObject(Object)
method.- Specified by:
addAll
in interfaceAttribute
- Type Parameters:
T
- The type of the attribute value objects being added.- Parameters:
values
- The attribute values to be added to this attribute.duplicateValues
- A collection into which duplicate values will be added, ornull
if duplicate values should not be saved.- Returns:
true
if this attribute changed as a result of this call.
-
contains
Description copied from interface:Attribute
Returnstrue
if this attribute containsvalue
.If
value
is not an instance ofByteString
then it will be converted using theByteString.valueOfObject(Object)
method.- Specified by:
contains
in interfaceAttribute
- Specified by:
contains
in interfaceCollection<ByteString>
- Specified by:
contains
in interfaceSet<ByteString>
- Overrides:
contains
in classAbstractCollection<ByteString>
- Parameters:
obj
- The attribute value whose presence in this attribute is to be tested.- Returns:
true
if this attribute containsvalue
, orfalse
if not.
-
containsAll
Description copied from interface:Attribute
Returnstrue
if this attribute contains all of the attribute values contained invalues
.Any attribute values which are not instances of
ByteString
will be converted using theByteString.valueOfObject(Object)
method.- Specified by:
containsAll
in interfaceAttribute
- Specified by:
containsAll
in interfaceCollection<ByteString>
- Specified by:
containsAll
in interfaceSet<ByteString>
- Overrides:
containsAll
in classAbstractCollection<ByteString>
- Parameters:
values
- The attribute values whose presence in this attribute is to be tested.- Returns:
true
if this attribute contains all of the attribute values contained invalues
, orfalse
if not.
-
equals
Description copied from interface:Attribute
Returnstrue
ifobject
is an attribute which is equal to this attribute. Two attributes are considered equal if their attribute descriptions are equal, they both have the same number of attribute values, and every attribute value contained in the first attribute is also contained in the second attribute.- Specified by:
equals
in interfaceAttribute
- Specified by:
equals
in interfaceCollection<ByteString>
- Specified by:
equals
in interfaceSet<ByteString>
- Overrides:
equals
in classAbstractSet<ByteString>
- Parameters:
object
- The object to be tested for equality with this attribute.- Returns:
true
ifobject
is an attribute which is equal to this attribute, orfalse
if not.
-
firstValue
Description copied from interface:Attribute
Returns the first attribute value in this attribute.- Specified by:
firstValue
in interfaceAttribute
- Returns:
- The first attribute value in this attribute.
-
forEachNormalizedValue
Description copied from interface:Attribute
Performs the provided action for each value and its associated normalized value in this attribute.- Specified by:
forEachNormalizedValue
in interfaceAttribute
- Parameters:
action
- The action to perform which will be passed the normalized value as the first parameter and the user provided value as the second parameter.
-
hashCode
public int hashCode()Description copied from interface:Attribute
Returns the hash code for this attribute. It will be calculated as the sum of the hash codes of the attribute description and all of the attribute values.- Specified by:
hashCode
in interfaceAttribute
- Specified by:
hashCode
in interfaceCollection<ByteString>
- Specified by:
hashCode
in interfaceSet<ByteString>
- Overrides:
hashCode
in classAbstractSet<ByteString>
- Returns:
- The hash code for this attribute.
-
parse
Description copied from interface:Attribute
Returns a parser for this attribute which can be used for decoding values as different types of object. -
iterator
Description copied from interface:Attribute
Returns an iterator over the attribute values in this attribute. The attribute values are returned in no particular order, unless the implementation of this attribute provides such a guarantee.- Specified by:
iterator
in interfaceAttribute
- Specified by:
iterator
in interfaceCollection<ByteString>
- Specified by:
iterator
in interfaceIterable<ByteString>
- Specified by:
iterator
in interfaceSet<ByteString>
- Specified by:
iterator
in classAbstractCollection<ByteString>
- Returns:
- An iterator over the attribute values in this attribute.
-
matchesAnyNormalizedValue
Description copied from interface:Attribute
Returnstrue
if any values in this attribute match at least one of the values in the provided map. Returnsfalse
if this attribute is empty or if the provided map is empty. The map elements are mappings from normalized values to their corresponding values, where the normalized values must have been normalized according to this attribute's equality matching rule.NOTE: this method returns
true
if the intersection of the normalized values in this attribute and the normalized values of the provided map is not empty.- Specified by:
matchesAnyNormalizedValue
in interfaceAttribute
- Parameters:
normalizedValues
- The map whose elements are mappings from normalized values to their corresponding values.- Returns:
true
if any values in this attribute are contained in the provided map.
-
matchesAnyNormalizedValue
Description copied from interface:Attribute
Returnstrue
if any values in this attribute match the provided predicate. Returnsfalse
if this attribute is empty.- Specified by:
matchesAnyNormalizedValue
in interfaceAttribute
- Parameters:
predicate
- The predicate which will be passed the normalized value as the first parameter and the user provided value as the second parameter.- Returns:
true
if any values in this attribute match the provided predicate.
-
removeAll
Description copied from interface:Attribute
Removes all of the attribute values contained invalues
from this attribute if they are present (optional operation).Any attribute values which are not instances of
ByteString
will be converted using theByteString.valueOfObject(Object)
method.An invocation of this method is equivalent to:
attribute.removeAll(values, null);
- Specified by:
removeAll
in interfaceAttribute
- Specified by:
removeAll
in interfaceCollection<ByteString>
- Specified by:
removeAll
in interfaceSet<ByteString>
- Overrides:
removeAll
in classAbstractSet<ByteString>
- Parameters:
values
- The attribute values to be removed from this attribute.- Returns:
true
if this attribute changed as a result of this call.
-
removeAll
Description copied from interface:Attribute
Removes all of the attribute values contained invalues
from this attribute if they are present (optional operation). Any attribute values which are not already present will be added tomissingValues
if specified.Any attribute values which are not instances of
ByteString
will be converted using theByteString.valueOfObject(Object)
method.- Specified by:
removeAll
in interfaceAttribute
- Type Parameters:
T
- The type of the attribute value objects being removed.- Parameters:
values
- The attribute values to be removed from this attribute.missingValues
- A collection into which missing values will be added, ornull
if missing values should not be saved.- Returns:
true
if this attribute changed as a result of this call.
-
retainAll
Description copied from interface:Attribute
Retains only the attribute values in this attribute which are contained invalues
(optional operation).Any attribute values which are not instances of
ByteString
will be converted using theByteString.valueOfObject(Object)
method.An invocation of this method is equivalent to:
attribute.retainAll(values, null);
- Specified by:
retainAll
in interfaceAttribute
- Specified by:
retainAll
in interfaceCollection<ByteString>
- Specified by:
retainAll
in interfaceSet<ByteString>
- Overrides:
retainAll
in classAbstractCollection<ByteString>
- Parameters:
values
- The attribute values to be retained in this attribute.- Returns:
true
if this attribute changed as a result of this call.
-
retainAll
Description copied from interface:Attribute
Retains only the attribute values in this attribute which are contained invalues
(optional operation). Any attribute values which are not already present will be added tomissingValues
if specified.Any attribute values which are not instances of
ByteString
will be converted using theByteString.valueOfObject(Object)
method.- Specified by:
retainAll
in interfaceAttribute
- Type Parameters:
T
- The type of the attribute value objects being retained.- Parameters:
values
- The attribute values to be retained in this attribute.missingValues
- A collection into which missing values will be added, ornull
if missing values should not be saved.- Returns:
true
if this attribute changed as a result of this call.
-
isEmpty
public boolean isEmpty()Description copied from interface:Attribute
Returnstrue
if this attribute contains no attribute values.- Specified by:
isEmpty
in interfaceAttribute
- Specified by:
isEmpty
in interfaceCollection<ByteString>
- Specified by:
isEmpty
in interfaceSet<ByteString>
- Overrides:
isEmpty
in classAbstractCollection<ByteString>
- Returns:
true
if this attribute contains no attribute values.
-
size
public int size()Description copied from interface:Attribute
Returns the number of attribute values in this attribute.- Specified by:
size
in interfaceAttribute
- Specified by:
size
in interfaceCollection<ByteString>
- Specified by:
size
in interfaceSet<ByteString>
- Specified by:
size
in classAbstractCollection<ByteString>
- Returns:
- The number of attribute values in this attribute.
-
toArray
Description copied from interface:Attribute
Returns an array containing all of the attribute values contained in this attribute.If this attribute makes any guarantees as to what order its attribute values are returned by its iterator, this method must return the attribute values in the same order.
The returned array will be "safe" in that no references to it are maintained by this attribute. The caller is thus free to modify the returned array.
- Specified by:
toArray
in interfaceAttribute
- Specified by:
toArray
in interfaceCollection<ByteString>
- Specified by:
toArray
in interfaceSet<ByteString>
- Overrides:
toArray
in classAbstractCollection<ByteString>
- Returns:
- An array containing all of the attribute values contained in this attribute.
-
toString
Description copied from interface:Attribute
Returns a string representation of this attribute.- Specified by:
toString
in interfaceAttribute
- Overrides:
toString
in classAbstractCollection<ByteString>
- Returns:
- The string representation of this attribute.
-