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 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.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.ConditionResult
matchesEqualityAssertion(Assertion assertion, ByteSequence rawAssertion)
NOTE: it is only possible to optimize for the equality matching rule because the other matching rules may not be compatible with the equality matching rule's normalized representation.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, matchesApproximateAssertion, matchesGreaterOrEqualAssertion, matchesLessOrEqualAssertion, matchesSubstringAssertion, 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
-
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.
-
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.
-
matchesEqualityAssertion
public ConditionResult matchesEqualityAssertion(Assertion assertion, ByteSequence rawAssertion)
NOTE: it is only possible to optimize for the equality matching rule because the other matching rules may not be compatible with the equality matching rule's normalized representation. For example, DN syntax uses DN matching for equality and case ignore string matching for substring matching.- Specified by:
matchesEqualityAssertion
in interfaceAttribute
- Overrides:
matchesEqualityAssertion
in classAbstractAttribute
- Parameters:
assertion
- The attribute value assertion compiled using the attribute's default equality matching rule.rawAssertion
- The raw assertion value whose syntax is compatible with the attribute's default equality matching rule.- Returns:
ConditionResult.FALSE
if the assertion does not match any values in this attribute,ConditionResult.TRUE
if the assertion matches at least one value in this attribute, orConditionResult.UNDEFINED
if the assertion does not match any values in this attribute, but one or more values could not be compared because they are incompatible with the matching rule.
-
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.
-
-