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.
-
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.voidforEachNormalizedValue(BiConsumer<? super ByteString, ? super ByteString> action) Performs the provided action for each value and its associated normalized value in this attribute.Returns the attribute description of this attribute, which includes its attribute type and any options.booleanisEmpty()Returnstrueif this attribute contains no attribute values.booleanIndicates whether this is a virtual attribute (dynamically computed) rather than a real attribute (persisted).iterator()Returns an iterator over the attribute values in this attribute.booleanmatchesAnyNormalizedValue(Predicate<? super ByteString> predicate) Returnstrueif any values in this attribute match the provided predicate.booleanmatchesAnyNormalizedValue(Map<ByteString, ByteString> normalizedValues) Returnstrueif any values in this attribute match at least one of the values in the provided map.static LinkedAttributenewPreSizedLinkedAttribute(AttributeDescription attributeDescription, int expectedValues) Creates a new attribute having the specified attribute description and expected number of values.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, hashCode, normalizeValue, parse, removeAll, removeAll, retainAll, toArray, toStringMethods inherited from class java.util.AbstractCollection
toArrayMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.forgerock.opendj.ldap.Attribute
firstValueAsString, getAttributeDescriptionAsString, isReal, put, put, toArrayMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.Set
spliterator, toArray
-
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:
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:
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:
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:
LocalizedIllegalArgumentException- IfattributeDescriptioncould not be decoded using the default schema.NullPointerException- IfattributeDescriptionorvalueswasnull.
-
-
Method Details
-
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- IfattributeDescriptionwasnull.
-
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>- Overrides:
addin classAbstractCollection<ByteString>- Parameters:
value- The attribute value to be added to this attribute.- Returns:
trueif this attribute changed as a result of this call.
-
clear
public void 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>- Overrides:
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.
-
forEachNormalizedValue
Description copied from interface:AttributePerforms the provided action for each value and its associated normalized value in this attribute.- Specified by:
forEachNormalizedValuein interfaceAttribute- Overrides:
forEachNormalizedValuein 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
Description copied from interface:AttributeReturns 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:AttributeIndicates whether this is a virtual attribute (dynamically computed) rather than a real attribute (persisted).- Returns:
trueif this is a virtual attribute.
-
isEmpty
public boolean isEmpty()Description copied from interface:AttributeReturnstrueif this attribute contains no attribute values.- Specified by:
isEmptyin interfaceAttribute- Specified by:
isEmptyin interfaceCollection<ByteString>- Specified by:
isEmptyin interfaceSet<ByteString>- Overrides:
isEmptyin classAbstractAttribute- Returns:
trueif this attribute contains no attribute values.
-
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.
-
matchesAnyNormalizedValue
Description copied from interface:AttributeReturnstrueif any values in this attribute match at least one of the values in the provided map. Returnsfalseif 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
trueif the intersection of the normalized values in this attribute and the normalized values of the provided map is not empty.- Specified by:
matchesAnyNormalizedValuein interfaceAttribute- Overrides:
matchesAnyNormalizedValuein classAbstractAttribute- Parameters:
normalizedValues- The map whose elements are mappings from normalized values to their corresponding values.- Returns:
trueif any values in this attribute are contained in the provided map.
-
matchesAnyNormalizedValue
Description copied from interface:AttributeReturnstrueif any values in this attribute match the provided predicate. Returnsfalseif this attribute is empty.- Specified by:
matchesAnyNormalizedValuein interfaceAttribute- Overrides:
matchesAnyNormalizedValuein 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:
trueif any values in this attribute match the provided predicate.
-
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>- Overrides:
removein classAbstractCollection<ByteString>- 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
public int 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>- Overrides:
sizein classAbstractAttribute- Returns:
- The number of attribute values in this attribute.
-