Class LinkedAttribute
- All Implemented Interfaces:
Iterable<ByteString>,Collection<ByteString>,Set<ByteString>,Attribute
Attribute 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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final AttributeFactoryAn attribute factory which can be used to create new linked attributes. -
Constructor Summary
ConstructorsConstructorDescriptionLinkedAttribute(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
Modifier and TypeMethodDescriptionbooleanadd(ByteString value) Addsvalueto this attribute if it is not already present (optional operation).voidclear()Removes all of the attribute values from this attribute (optional operation).booleanReturnstrueif this attribute containsvalue.booleancontainsAll(Collection<?> values) Returnstrueif this attribute contains all of the attribute values contained invalues.Returns the first attribute value in this attribute.Returns the attribute description of this attribute, which includes its attribute type and any options.iterator()Returns an iterator over the attribute values in this attribute.booleanRemovesvaluefrom this attribute if it is present (optional operation).<T> booleanretainAll(Collection<T> values, Collection<? super T> missingValues) Retains only the attribute values in this attribute which are contained invalues(optional operation).intsize()Returns the number of attribute values in this attribute.Methods inherited from class org.forgerock.opendj.ldap.AbstractAttribute
add, addAll, addAll, equals, firstValueAsString, getAttributeDescriptionAsString, hashCode, parse, removeAll, removeAll, retainAll, toArray, toStringMethods inherited from class java.util.AbstractCollection
isEmpty, toArrayMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.Set
spliterator
-
Field Details
-
FACTORY
An attribute factory which can be used to create new linked attributes.
-
-
Constructor Details
-
LinkedAttribute
Creates a new attribute having the same attribute description and attribute values asattribute.- Parameters:
attribute- The attribute to be copied.- Throws:
NullPointerException- Ifattributewasnull.
-
LinkedAttribute
Creates a new attribute having the specified attribute description and no attribute values.- Parameters:
attributeDescription- The attribute description.- Throws:
NullPointerException- IfattributeDescriptionwasnull.
-
LinkedAttribute
Creates a new attribute having the specified attribute description and single attribute value.If
valueis not an instance ofByteStringthen it will be converted using theByteString.valueOfObject(Object)method.- Parameters:
attributeDescription- The attribute description.value- The single attribute value.- Throws:
NullPointerException- IfattributeDescriptionorvaluewasnull.
-
LinkedAttribute
Creates a new attribute having the specified attribute description and attribute values.Any attribute values which are not instances of
ByteStringwill be converted using theByteString.valueOfObject(Object)method.- Parameters:
attributeDescription- The attribute description.values- The attribute values.- Throws:
NullPointerException- IfattributeDescriptionorvalueswasnull.
-
LinkedAttribute
Creates a new attribute having the specified attribute description and attribute values.Any attribute values which are not instances of
ByteStringwill be converted using theByteString.valueOfObject(Object)method.- Parameters:
attributeDescription- The attribute description.values- The attribute values.- Throws:
NullPointerException- IfattributeDescriptionorvalueswasnull.
-
LinkedAttribute
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:
org.forgerock.i18n.LocalizedIllegalArgumentException- IfattributeDescriptioncould not be decoded using the default schema.NullPointerException- IfattributeDescriptionwasnull.
-
LinkedAttribute
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
ByteStringwill be converted using theByteString.valueOfObject(Object)method.- Parameters:
attributeDescription- The attribute description.values- The attribute values.- Throws:
org.forgerock.i18n.LocalizedIllegalArgumentException- IfattributeDescriptioncould not be decoded using the default schema.NullPointerException- IfattributeDescriptionorvalueswasnull.
-
LinkedAttribute
Creates a new attribute having the specified attribute description and single attribute value. The attribute description will be decoded using the default schema.If
valueis not an instance ofByteStringthen it will be converted using theByteString.valueOfObject(Object)method.- Parameters:
attributeDescription- The attribute description.value- The single attribute value.- Throws:
org.forgerock.i18n.LocalizedIllegalArgumentException- IfattributeDescriptioncould not be decoded using the default schema.NullPointerException- IfattributeDescriptionorvaluewasnull.
-
LinkedAttribute
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
ByteStringwill be converted using theByteString.valueOfObject(Object)method.- Parameters:
attributeDescription- The attribute description.values- The attribute values.- Throws:
org.forgerock.i18n.LocalizedIllegalArgumentException- IfattributeDescriptioncould not be decoded using the default schema.NullPointerException- IfattributeDescriptionorvalueswasnull.
-
-
Method Details
-
add
Description copied from interface:AttributeAddsvalueto 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:
addin interfaceAttribute- Specified by:
addin interfaceCollection<ByteString>- Specified by:
addin interfaceSet<ByteString>- Specified by:
addin classAbstractAttribute- Parameters:
value- The attribute value to be added to this attribute.- Returns:
trueif this attribute changed as a result of this call.
-
clear
Description copied from interface:AttributeRemoves all of the attribute values from this attribute (optional operation). This attribute will be empty after this call returns.- Specified by:
clearin interfaceAttribute- Specified by:
clearin interfaceCollection<ByteString>- Specified by:
clearin interfaceSet<ByteString>- Overrides:
clearin classAbstractCollection<ByteString>
-
contains
Description copied from interface:AttributeReturnstrueif this attribute containsvalue.If
valueis not an instance ofByteStringthen it will be converted using theByteString.valueOfObject(Object)method.- Specified by:
containsin interfaceAttribute- Specified by:
containsin interfaceCollection<ByteString>- Specified by:
containsin interfaceSet<ByteString>- Specified by:
containsin classAbstractAttribute- Parameters:
value- The attribute value whose presence in this attribute is to be tested.- Returns:
trueif this attribute containsvalue, orfalseif not.
-
containsAll
Description copied from interface:AttributeReturnstrueif this attribute contains all of the attribute values contained invalues.Any attribute values which are not instances of
ByteStringwill be converted using theByteString.valueOfObject(Object)method.- Specified by:
containsAllin interfaceAttribute- Specified by:
containsAllin interfaceCollection<ByteString>- Specified by:
containsAllin interfaceSet<ByteString>- Overrides:
containsAllin classAbstractAttribute- Parameters:
values- The attribute values whose presence in this attribute is to be tested.- Returns:
trueif this attribute contains all of the attribute values contained invalues, orfalseif not.
-
firstValue
Description copied from interface:AttributeReturns the first attribute value in this attribute.- Specified by:
firstValuein interfaceAttribute- Overrides:
firstValuein classAbstractAttribute- Returns:
- The first attribute value in this attribute.
-
getAttributeDescription
Description copied from interface:AttributeReturns the attribute description of this attribute, which includes its attribute type and any options.- Specified by:
getAttributeDescriptionin interfaceAttribute- Specified by:
getAttributeDescriptionin classAbstractAttribute- Returns:
- The attribute description.
-
iterator
Description copied from interface:AttributeReturns 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:
iteratorin interfaceAttribute- Specified by:
iteratorin interfaceCollection<ByteString>- Specified by:
iteratorin interfaceIterable<ByteString>- Specified by:
iteratorin interfaceSet<ByteString>- Specified by:
iteratorin classAbstractAttribute- Returns:
- An iterator over the attribute values in this attribute.
-
remove
Description copied from interface:AttributeRemovesvaluefrom this attribute if it is present (optional operation). If this attribute does not containvalue, the call leaves the attribute unchanged and returnsfalse.If
valueis not an instance ofByteStringthen it will be converted using theByteString.valueOfObject(Object)method.- Specified by:
removein interfaceAttribute- Specified by:
removein interfaceCollection<ByteString>- Specified by:
removein interfaceSet<ByteString>- Specified by:
removein classAbstractAttribute- Parameters:
value- The attribute value to be removed from this attribute.- Returns:
trueif this attribute changed as a result of this call.
-
retainAll
Description copied from interface:AttributeRetains only the attribute values in this attribute which are contained invalues(optional operation). Any attribute values which are not already present will be added tomissingValuesif specified.Any attribute values which are not instances of
ByteStringwill be converted using theByteString.valueOfObject(Object)method.- Specified by:
retainAllin interfaceAttribute- Overrides:
retainAllin 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, ornullif missing values should not be saved.- Returns:
trueif this attribute changed as a result of this call.
-
size
Description copied from interface:AttributeReturns the number of attribute values in this attribute.- Specified by:
sizein interfaceAttribute- Specified by:
sizein interfaceCollection<ByteString>- Specified by:
sizein interfaceSet<ByteString>- Specified by:
sizein classAbstractAttribute- Returns:
- The number of attribute values in this attribute.
-