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 forMap
based entries.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractMapEntry(Dn name, M attributes)
Creates an empty entry using the provided distinguished name andMap
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addAttribute(Attribute attribute, Collection<? super ByteString> duplicateValues)
Ensures that this entry contains the provided attribute and values (optional operation).Attribute
addAttributeIfAbsent(Attribute attribute)
Adds the provided attribute if it is not already present in this Entry and returnsnull
.Entry
clearAttributes()
Removes all the attributes from this entry (optional operation).Iterable<Attribute>
getAllAttributes()
Returns anIterable
containing all of the attributes in this entry.Attribute
getAttribute(AttributeDescription attributeDescription)
Returns the named attribute contained in this entry, ornull
if it is not included with this entry.int
getAttributeCount()
Returns the number of attributes in this entry.Dn
getName()
Returns the distinguished name of this entry.Attribute
mergeAttribute(Attribute attribute, BiFunction<? super Attribute,? super Attribute,? extends Attribute> mergeFunction)
Adds the provided attribute if it is not already present in this Entry.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).Entry
setName(Dn dn)
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
-
-
-
-
Method Detail
-
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
public Attribute addAttributeIfAbsent(Attribute attribute)
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
public final Entry clearAttributes()
Description copied from interface:Entry
Removes all the attributes from this entry (optional operation).- Returns:
- This entry.
-
getAllAttributes
public final Iterable<Attribute> 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
public final Attribute getAttribute(AttributeDescription attributeDescription)
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
public final Dn 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
public boolean replaceAttribute(Attribute attribute)
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.
-
-