Class LinkedAttribute
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<ByteString>
-
- org.forgerock.opendj.ldap.AbstractAttribute
-
- org.forgerock.opendj.ldap.LinkedAttribute
-
- All Implemented Interfaces:
Iterable<ByteString>
,Collection<ByteString>
,Set<ByteString>
,Attribute
public final class LinkedAttribute extends AbstractAttribute
An implementation of theAttribute
interface with predictable iteration order.Internally, attribute values are stored in a linked list and it's this list which defines the iteration ordering, which is the order in which elements were inserted into the set (insertion-order). This ordering is particularly useful in LDAP where clients generally appreciate having things returned in the same order they were presented.
All operations are supported by this implementation.
-
-
Constructor Summary
Constructors Constructor Description LinkedAttribute(String attributeDescription)
Creates a new attribute having the specified attribute description and no attribute values.LinkedAttribute(String attributeDescription, Object value)
Creates a new attribute having the specified attribute description and single attribute value.LinkedAttribute(String attributeDescription, Object... values)
Creates a new attribute having the specified attribute description and attribute values.LinkedAttribute(String attributeDescription, Collection<?> values)
Creates a new attribute having the specified attribute description and attribute values.LinkedAttribute(Attribute attribute)
Creates a new attribute having the same attribute description and attribute values asattribute
.LinkedAttribute(AttributeDescription attributeDescription)
Creates a new attribute having the specified attribute description and no attribute values.LinkedAttribute(AttributeDescription attributeDescription, Object value)
Creates a new attribute having the specified attribute description and single attribute value.LinkedAttribute(AttributeDescription attributeDescription, Object... values)
Creates a new attribute having the specified attribute description and attribute values.LinkedAttribute(AttributeDescription attributeDescription, Collection<?> values)
Creates a new attribute having the specified attribute description and attribute values.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(ByteString value)
Addsvalue
to this attribute if it is not already present (optional operation).void
clear()
Removes all of the attribute values from this attribute (optional operation).boolean
contains(Object value)
Returnstrue
if this attribute containsvalue
.boolean
containsAll(Collection<?> values)
Returnstrue
if this attribute contains all of the attribute values contained invalues
.ByteString
firstValue()
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.AttributeDescription
getAttributeDescription()
Returns the attribute description of this attribute, which includes its attribute type and any options.boolean
isEmpty()
Returnstrue
if this attribute contains no attribute values.boolean
isVirtual()
Indicates whether this is a virtual attribute (dynamically computed) rather than a real attribute (persisted).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 LinkedAttribute
newPreSizedLinkedAttribute(AttributeDescription attributeDescription, int expectedValues)
Creates a new attribute having the specified attribute description and expected number of values.boolean
remove(Object value)
Removesvalue
from this attribute if it is present (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.-
Methods inherited from class org.forgerock.opendj.ldap.AbstractAttribute
add, addAll, addAll, equals, hashCode, normalizeValue, parse, removeAll, removeAll, retainAll, toArray, toString
-
Methods inherited from class java.util.AbstractCollection
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
firstValueAsString, getAttributeDescriptionAsString, isReal, put, put, toArray
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.Set
spliterator, toArray
-
-
-
-
Constructor Detail
-
LinkedAttribute
public LinkedAttribute(Attribute attribute)
Creates a new attribute having the same attribute description and attribute values asattribute
.- Parameters:
attribute
- The attribute to be copied.- Throws:
NullPointerException
- Ifattribute
wasnull
.
-
LinkedAttribute
public LinkedAttribute(AttributeDescription attributeDescription)
Creates a new attribute having the specified attribute description and no attribute values.- Parameters:
attributeDescription
- The attribute description.- Throws:
NullPointerException
- IfattributeDescription
wasnull
.
-
LinkedAttribute
public LinkedAttribute(AttributeDescription attributeDescription, Object value)
Creates a new attribute having the specified attribute description and single attribute value.If
value
is not an instance ofByteString
then it will be converted using theByteString.valueOfObject(Object)
method.- Parameters:
attributeDescription
- The attribute description.value
- The single attribute value.- Throws:
NullPointerException
- IfattributeDescription
orvalue
wasnull
.
-
LinkedAttribute
public LinkedAttribute(AttributeDescription attributeDescription, Object... values)
Creates a new attribute having the specified attribute description and attribute values.Any attribute values which are not instances of
ByteString
will be converted using theByteString.valueOfObject(Object)
method.- Parameters:
attributeDescription
- The attribute description.values
- The attribute values.- Throws:
NullPointerException
- IfattributeDescription
orvalues
wasnull
.
-
LinkedAttribute
public LinkedAttribute(AttributeDescription attributeDescription, Collection<?> values)
Creates a new attribute having the specified attribute description and attribute values.Any attribute values which are not instances of
ByteString
will be converted using theByteString.valueOfObject(Object)
method.- Parameters:
attributeDescription
- The attribute description.values
- The attribute values.- Throws:
NullPointerException
- IfattributeDescription
orvalues
wasnull
.
-
LinkedAttribute
public LinkedAttribute(String attributeDescription)
Creates a new attribute having the specified attribute description and no attribute values. The attribute description will be decoded using the default schema.- Parameters:
attributeDescription
- The attribute description.- Throws:
LocalizedIllegalArgumentException
- IfattributeDescription
could not be decoded using the default schema.NullPointerException
- IfattributeDescription
wasnull
.
-
LinkedAttribute
public LinkedAttribute(String attributeDescription, Collection<?> values)
Creates a new attribute having the specified attribute description and attribute values. The attribute description will be decoded using the default schema.Any attribute values which are not instances of
ByteString
will be converted using theByteString.valueOfObject(Object)
method.- Parameters:
attributeDescription
- The attribute description.values
- The attribute values.- Throws:
LocalizedIllegalArgumentException
- IfattributeDescription
could not be decoded using the default schema.NullPointerException
- IfattributeDescription
orvalues
wasnull
.
-
LinkedAttribute
public LinkedAttribute(String attributeDescription, Object value)
Creates a new attribute having the specified attribute description and single attribute value. The attribute description will be decoded using the default schema.If
value
is not an instance ofByteString
then it will be converted using theByteString.valueOfObject(Object)
method.- Parameters:
attributeDescription
- The attribute description.value
- The single attribute value.- Throws:
LocalizedIllegalArgumentException
- IfattributeDescription
could not be decoded using the default schema.NullPointerException
- IfattributeDescription
orvalue
wasnull
.
-
LinkedAttribute
public LinkedAttribute(String attributeDescription, Object... values)
Creates a new attribute having the specified attribute description and attribute values. The attribute description will be decoded using the default schema.Any attribute values which are not instances of
ByteString
will be converted using theByteString.valueOfObject(Object)
method.- Parameters:
attributeDescription
- The attribute description.values
- The attribute values.- Throws:
LocalizedIllegalArgumentException
- IfattributeDescription
could not be decoded using the default schema.NullPointerException
- IfattributeDescription
orvalues
wasnull
.
-
-
Method Detail
-
newPreSizedLinkedAttribute
public static LinkedAttribute newPreSizedLinkedAttribute(AttributeDescription attributeDescription, int expectedValues)
Creates a new attribute having the specified attribute description and expected number of values.- Parameters:
attributeDescription
- The attribute description.expectedValues
- The expected number of attribute values.- Returns:
- Returns a pre-sized attribute.
- Throws:
NullPointerException
- IfattributeDescription
wasnull
.
-
add
public boolean add(ByteString value)
Description copied from interface:Attribute
Addsvalue
to this attribute if it is not already present (optional operation). If this attribute already containsvalue
, the call leaves the attribute unchanged and returnsfalse
.- Specified by:
add
in interfaceAttribute
- Specified by:
add
in interfaceCollection<ByteString>
- Specified by:
add
in interfaceSet<ByteString>
- Overrides:
add
in classAbstractCollection<ByteString>
- Parameters:
value
- The attribute value to be added to this attribute.- Returns:
true
if this attribute changed as a result of this call.
-
clear
public void clear()
Description copied from interface:Attribute
Removes all of the attribute values from this attribute (optional operation). This attribute will be empty after this call returns.- Specified by:
clear
in interfaceAttribute
- Specified by:
clear
in interfaceCollection<ByteString>
- Specified by:
clear
in interfaceSet<ByteString>
- Overrides:
clear
in classAbstractCollection<ByteString>
-
contains
public boolean contains(Object value)
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 classAbstractAttribute
- Parameters:
value
- The attribute value whose presence in this attribute is to be tested.- Returns:
true
if this attribute containsvalue
, orfalse
if not.
-
containsAll
public boolean containsAll(Collection<?> values)
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 classAbstractAttribute
- 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.
-
firstValue
public ByteString firstValue()
Description copied from interface:Attribute
Returns the first attribute value in this attribute.- Specified by:
firstValue
in interfaceAttribute
- Overrides:
firstValue
in classAbstractAttribute
- Returns:
- The first attribute value in this attribute.
-
forEachNormalizedValue
public void forEachNormalizedValue(BiConsumer<? super ByteString,? super ByteString> action)
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
- Overrides:
forEachNormalizedValue
in classAbstractAttribute
- 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.
-
getAttributeDescription
public AttributeDescription getAttributeDescription()
Description copied from interface:Attribute
Returns the attribute description of this attribute, which includes its attribute type and any options.- Returns:
- The attribute description.
-
isVirtual
public boolean isVirtual()
Description copied from interface:Attribute
Indicates whether this is a virtual attribute (dynamically computed) rather than a real attribute (persisted).- Returns:
true
if this is a virtual attribute.
-
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 classAbstractAttribute
- Returns:
true
if this attribute contains no attribute values.
-
iterator
public Iterator<ByteString> 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 classAbstractAttribute
- Returns:
- An iterator over the attribute values in this attribute.
-
matchesAnyNormalizedValue
public boolean matchesAnyNormalizedValue(Map<ByteString,ByteString> normalizedValues)
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
- Overrides:
matchesAnyNormalizedValue
in classAbstractAttribute
- 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
public boolean matchesAnyNormalizedValue(Predicate<? super ByteString> predicate)
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
- Overrides:
matchesAnyNormalizedValue
in classAbstractAttribute
- 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.
-
remove
public boolean remove(Object value)
Description copied from interface:Attribute
Removesvalue
from this attribute if it is present (optional operation). If this attribute does not containvalue
, the call leaves the attribute unchanged and returnsfalse
.If
value
is not an instance ofByteString
then it will be converted using theByteString.valueOfObject(Object)
method.- Specified by:
remove
in interfaceAttribute
- Specified by:
remove
in interfaceCollection<ByteString>
- Specified by:
remove
in interfaceSet<ByteString>
- Overrides:
remove
in classAbstractCollection<ByteString>
- Parameters:
value
- The attribute value to be removed from this attribute.- Returns:
true
if this attribute changed as a result of this call.
-
retainAll
public <T> boolean retainAll(Collection<T> values, Collection<? super T> missingValues)
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
- Overrides:
retainAll
in classAbstractAttribute
- 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.
-
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>
- Overrides:
size
in classAbstractAttribute
- Returns:
- The number of attribute values in this attribute.
-
-