Package org.forgerock.opendj.ldap
Class AbstractMapEntry<M extends Map<AttributeDescription,Attribute>>
java.lang.Object
org.forgerock.opendj.ldap.AbstractEntry
org.forgerock.opendj.ldap.AbstractMapEntry<M>
- Type Parameters:
M
- The type of theMap
that will store the entry's attributes.
- All Implemented Interfaces:
Entry
- Direct Known Subclasses:
LinkedHashMapEntry
,TreeMapEntry
public abstract class AbstractMapEntry<M extends Map<AttributeDescription,Attribute>>
extends AbstractEntry
Abstract implementation for
Map
based entries.-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractMapEntry
(Dn name, M attributes) Creates an empty entry using the provided distinguished name andMap
. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
addAttribute
(Attribute attribute, Collection<? super ByteString> duplicateValues) Ensures that this entry contains the provided attribute and values (optional operation).addAttributeIfAbsent
(Attribute attribute) Adds the provided attribute if it is not already present in this Entry and returnsnull
.final Entry
Removes all the attributes from this entry (optional operation).Returns anIterable
containing all of the attributes in this entry.final Attribute
getAttribute
(AttributeDescription attributeDescription) Returns the named attribute contained in this entry, ornull
if it is not included with this entry.final int
Returns the number of attributes in this entry.final Dn
getName()
Returns the distinguished name of this entry.mergeAttribute
(Attribute attribute, BiFunction<? super Attribute, ? super Attribute, ? extends Attribute> mergeFunction) Adds the provided attribute if it is not already present in this Entry.final boolean
removeAttribute
(Attribute attribute, Collection<? super ByteString> missingValues) Removes all of the attribute values contained inattribute
from this entry if it is present (optional operation).boolean
replaceAttribute
(Attribute attribute) Adds all of the attribute values contained inattribute
to this entry, replacing any existing attribute values (optional operation).final Entry
Sets the distinguished name of this entry (optional operation).Methods inherited from class org.forgerock.opendj.ldap.AbstractEntry
equals, hashCode, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.forgerock.opendj.ldap.Entry
addAttribute, addAttribute, containsAnyAttributes, containsAnyAttributes, containsAttribute, containsAttribute, containsAttribute, getAllAttributes, getAllAttributes, getAttribute, parseAttribute, parseAttribute, removeAttribute, removeAttribute, replaceAttribute, setName
-
Constructor Details
-
AbstractMapEntry
Creates an empty entry using the provided distinguished name andMap
.- Parameters:
name
- The distinguished name of this entry.attributes
- The attribute map.
-
-
Method Details
-
addAttribute
public final boolean addAttribute(Attribute attribute, Collection<? super ByteString> duplicateValues) Description copied from interface:Entry
Ensures that this entry contains the provided attribute and values (optional operation). This method has the following semantics:- If this entry does not already contain an attribute with a
matching
attribute description, then this entry will be modified such that it containsattribute
, even if it is empty. - If this entry already contains an attribute with a
matching
attribute description, then the attribute values contained inattribute
will be merged with the existing attribute values.
NOTE: When
attribute
is non-empty, this method implements LDAP Modify add semantics.- Parameters:
attribute
- The attribute values to be added to this entry, merging with any existing attribute values.duplicateValues
- A collection into which duplicate values will be added, ornull
if duplicate values should not be saved.- Returns:
true
if this entry changed as a result of this call.
- If this entry does not already contain an attribute with a
-
addAttributeIfAbsent
Description copied from interface:Entry
Adds the provided attribute if it is not already present in this Entry and returnsnull
. Otherwise returns the existing attribute.NOTE: this method is equivalent to
Map.putIfAbsent(Object, Object)
.- Parameters:
attribute
- The non-null
attribute to be added if it is not already present.- Returns:
null
if the attribute was added, or the existing attribute (in which case the entry is unchanged).
-
clearAttributes
Description copied from interface:Entry
Removes all the attributes from this entry (optional operation).- Returns:
- This entry.
-
getAllAttributes
Description copied from interface:Entry
Returns anIterable
containing all of the attributes in this entry. The returnedIterable
may be used to remove attributes if permitted by this entry.- Returns:
- An
Iterable
containing all of the attributes.
-
getAttribute
Description copied from interface:Entry
Returns the named attribute contained in this entry, ornull
if it is not included with this entry.- Parameters:
attributeDescription
- The name of the attribute to be returned.- Returns:
- The named attribute, or
null
if it is not included with this entry.
-
getAttributeCount
public final int getAttributeCount()Description copied from interface:Entry
Returns the number of attributes in this entry.- Returns:
- The number of attributes.
-
getName
Description copied from interface:Entry
Returns the distinguished name of this entry.- Returns:
- The distinguished name of this entry.
-
mergeAttribute
public Attribute mergeAttribute(Attribute attribute, BiFunction<? super Attribute, ? super Attribute, ? extends Attribute> mergeFunction) Description copied from interface:Entry
Adds the provided attribute if it is not already present in this Entry. Otherwise, replaces the existing attribute with the results of the remapping function, or removes it if the result isnull
.NOTE: this method is equivalent to
Map.merge(Object, Object, BiFunction)
.- Parameters:
attribute
- The non-null
attribute to be added or merged with the existing attribute.mergeFunction
- The function to recompute the attribute if it is already present in this Entry.- Returns:
- The attribute that was added or merged, or
null
if the attribute was removed.
-
replaceAttribute
Description copied from interface:Entry
Adds all of the attribute values contained inattribute
to this entry, replacing any existing attribute values (optional operation). Ifattribute
is empty then the entire attribute will be removed if it is present.NOTE: This method implements LDAP Modify replace semantics as described in RFC 4511 - Section 4.6. Modify Operation.
- Parameters:
attribute
- The attribute values to be added to this entry, replacing any existing attribute values, and which may be empty if the entire attribute is to be removed.- Returns:
true
if this entry changed as a result of this call.
-
removeAttribute
public final boolean removeAttribute(Attribute attribute, Collection<? super ByteString> missingValues) Description copied from interface:Entry
Removes all of the attribute values contained inattribute
from this entry if it is present (optional operation). Ifattribute
is empty then the entire attribute will be removed if it is present.NOTE: This method implements LDAP Modify delete semantics.
- Parameters:
attribute
- The attribute values to be removed from this entry, which may be empty if the entire attribute is to be removed.missingValues
- A collection into which missing values will be added, ornull
if missing values should not be saved.- Returns:
true
if this entry changed as a result of this call.
-
setName
Description copied from interface:Entry
Sets the distinguished name of this entry (optional operation).- Parameters:
dn
- The distinguished name.- Returns:
- This entry.
-