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 theMapthat 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 forMapbased entries.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractMapEntry(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 booleanaddAttribute(Attribute attribute, Collection<? super ByteString> duplicateValues)Ensures that this entry contains the provided attribute and values (optional operation).AttributeaddAttributeIfAbsent(Attribute attribute)Adds the provided attribute if it is not already present in this Entry and returnsnull.EntryclearAttributes()Removes all the attributes from this entry (optional operation).Iterable<Attribute>getAllAttributes()Returns anIterablecontaining all of the attributes in this entry.AttributegetAttribute(AttributeDescription attributeDescription)Returns the named attribute contained in this entry, ornullif it is not included with this entry.intgetAttributeCount()Returns the number of attributes in this entry.DngetName()Returns the distinguished name of this entry.AttributemergeAttribute(Attribute attribute, BiFunction<? super Attribute,? super Attribute,? extends Attribute> mergeFunction)Adds the provided attribute if it is not already present in this Entry.booleanremoveAttribute(Attribute attribute, Collection<? super ByteString> missingValues)Removes all of the attribute values contained inattributefrom this entry if it is present (optional operation).booleanreplaceAttribute(Attribute attribute)Adds all of the attribute values contained inattributeto this entry, replacing any existing attribute values (optional operation).EntrysetName(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:EntryEnsures 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
matchingattribute 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
matchingattribute description, then the attribute values contained inattributewill be merged with the existing attribute values.
NOTE: When
attributeis 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, ornullif duplicate values should not be saved.- Returns:
trueif 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:EntryAdds 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-nullattribute to be added if it is not already present.- Returns:
nullif the attribute was added, or the existing attribute (in which case the entry is unchanged).
-
clearAttributes
public final Entry clearAttributes()
Description copied from interface:EntryRemoves all the attributes from this entry (optional operation).- Returns:
- This entry.
-
getAllAttributes
public final Iterable<Attribute> getAllAttributes()
Description copied from interface:EntryReturns anIterablecontaining all of the attributes in this entry. The returnedIterablemay be used to remove attributes if permitted by this entry.- Returns:
- An
Iterablecontaining all of the attributes.
-
getAttribute
public final Attribute getAttribute(AttributeDescription attributeDescription)
Description copied from interface:EntryReturns the named attribute contained in this entry, ornullif it is not included with this entry.- Parameters:
attributeDescription- The name of the attribute to be returned.- Returns:
- The named attribute, or
nullif it is not included with this entry.
-
getAttributeCount
public final int getAttributeCount()
Description copied from interface:EntryReturns the number of attributes in this entry.- Returns:
- The number of attributes.
-
getName
public final Dn getName()
Description copied from interface:EntryReturns 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:EntryAdds 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-nullattribute 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
nullif the attribute was removed.
-
replaceAttribute
public boolean replaceAttribute(Attribute attribute)
Description copied from interface:EntryAdds all of the attribute values contained inattributeto this entry, replacing any existing attribute values (optional operation). Ifattributeis 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:
trueif this entry changed as a result of this call.
-
removeAttribute
public final boolean removeAttribute(Attribute attribute, Collection<? super ByteString> missingValues)
Description copied from interface:EntryRemoves all of the attribute values contained inattributefrom this entry if it is present (optional operation). Ifattributeis 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, ornullif missing values should not be saved.- Returns:
trueif this entry changed as a result of this call.
-
-