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 the Map 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 Details

    • AbstractMapEntry

      protected AbstractMapEntry(Dn name, M attributes)
      Creates an empty entry using the provided distinguished name and Map.
      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 contains attribute, even if it is empty.
      • If this entry already contains an attribute with a matching attribute description, then the attribute values contained in attribute 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, or null if duplicate values should not be saved.
      Returns:
      true if this entry changed as a result of this call.
    • 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 returns null. 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 an Iterable containing all of the attributes in this entry. The returned Iterable 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, or null 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 is null.

      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 in attribute to this entry, replacing any existing attribute values (optional operation). If attribute 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 in attribute from this entry if it is present (optional operation). If attribute 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, or null if missing values should not be saved.
      Returns:
      true if this entry changed as a result of this call.
    • setName

      public final Entry setName(Dn dn)
      Description copied from interface: Entry
      Sets the distinguished name of this entry (optional operation).
      Parameters:
      dn - The distinguished name.
      Returns:
      This entry.