Class AbstractAttribute

All Implemented Interfaces:
Iterable<ByteString>, Collection<ByteString>, Set<ByteString>, Attribute
Direct Known Subclasses:
LinkedAttribute

public abstract class AbstractAttribute extends AbstractSet<ByteString> implements Attribute
This class provides a skeletal implementation of the Attribute interface, to minimize the effort required to implement this interface.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Sole constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    add(Object... values)
    Adds all of the provided attribute values to this attribute if they are not already present (optional operation).
    abstract boolean
    add(ByteString value)
    Adds value to this attribute if it is not already present (optional operation).
    boolean
    addAll(Collection<? extends ByteString> values)
    Adds all of the attribute values contained in values to this attribute if they are not already present (optional operation).
    <T> boolean
    addAll(Collection<T> values, Collection<? super T> duplicateValues)
    Adds all of the attribute values contained in values to this attribute if they are not already present (optional operation).
    abstract boolean
    Returns true if this attribute contains value.
    boolean
    Returns true if this attribute contains all of the attribute values contained in values.
    boolean
    equals(Object object)
    Returns true if object is an attribute which is equal to this attribute.
    Returns the first attribute value in this attribute.
    Returns the first attribute value in this attribute decoded as a UTF-8 string.
    Returns the attribute description of this attribute, which includes its attribute type and any options.
    Returns the string representation of the attribute description of this attribute, which includes its attribute type and any options.
    int
    Returns the hash code for this attribute.
    Returns an iterator over the attribute values in this attribute.
    Returns a parser for this attribute which can be used for decoding values as different types of object.
    abstract boolean
    remove(Object value)
    Removes value from this attribute if it is present (optional operation).
    boolean
    removeAll(Collection<?> values)
    Removes all of the attribute values contained in values from this attribute if they are present (optional operation).
    <T> boolean
    removeAll(Collection<T> values, Collection<? super T> missingValues)
    Removes all of the attribute values contained in values from this attribute if they are present (optional operation).
    boolean
    retainAll(Collection<?> values)
    Retains only the attribute values in this attribute which are contained in values (optional operation).
    <T> boolean
    retainAll(Collection<T> values, Collection<? super T> missingValues)
    Retains only the attribute values in this attribute which are contained in values (optional operation).
    abstract int
    Returns the number of attribute values in this attribute.
    Returns an array containing all of the attribute values contained in this attribute.
    Returns a string representation of this attribute.

    Methods inherited from class java.util.AbstractCollection

    clear, isEmpty, toArray

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.forgerock.opendj.ldap.Attribute

    clear, isEmpty, toArray

    Methods inherited from interface java.util.Collection

    parallelStream, removeIf, stream, toArray

    Methods inherited from interface java.lang.Iterable

    forEach

    Methods inherited from interface java.util.Set

    spliterator
  • Constructor Details

  • Method Details

    • add

      public abstract boolean add(ByteString value)
      Description copied from interface: Attribute
      Adds value to this attribute if it is not already present (optional operation). If this attribute already contains value, the call leaves the attribute unchanged and returns false.
      Specified by:
      add in interface Attribute
      Specified by:
      add in interface Collection<ByteString>
      Specified by:
      add in interface Set<ByteString>
      Overrides:
      add in class AbstractCollection<ByteString>
      Parameters:
      value - The attribute value to be added to this attribute.
      Returns:
      true if this attribute changed as a result of this call.
    • add

      public boolean add(Object... values)
      Description copied from interface: Attribute
      Adds all of the provided attribute values to this attribute if they are not already present (optional operation).

      Any attribute values which are not instances of ByteString will be converted using the ByteString.valueOfObject(Object) method.

      Specified by:
      add in interface Attribute
      Parameters:
      values - The attribute values to be added to this attribute.
      Returns:
      true if this attribute changed as a result of this call.
    • addAll

      public boolean addAll(Collection<? extends ByteString> values)
      Description copied from interface: Attribute
      Adds all of the attribute values contained in values to this attribute if they are not already present (optional operation).

      An invocation of this method is equivalent to:

       attribute.addAll(values, null);
       
      Specified by:
      addAll in interface Attribute
      Specified by:
      addAll in interface Collection<ByteString>
      Specified by:
      addAll in interface Set<ByteString>
      Overrides:
      addAll in class AbstractCollection<ByteString>
      Parameters:
      values - The attribute values to be added to this attribute.
      Returns:
      true if this attribute changed as a result of this call.
    • addAll

      public <T> boolean addAll(Collection<T> values, Collection<? super T> duplicateValues)
      Description copied from interface: Attribute
      Adds all of the attribute values contained in values to this attribute if they are not already present (optional operation). Any attribute values which are already present will be added to duplicateValues if specified.

      Any attribute values which are not instances of ByteString will be converted using the ByteString.valueOfObject(Object) method.

      Specified by:
      addAll in interface Attribute
      Type Parameters:
      T - The type of the attribute value objects being added.
      Parameters:
      values - The attribute values to be added to this attribute.
      duplicateValues - A collection into which duplicate values will be added, or null if duplicate values should not be saved.
      Returns:
      true if this attribute changed as a result of this call.
    • contains

      public abstract boolean contains(Object value)
      Description copied from interface: Attribute
      Returns true if this attribute contains value.

      If value is not an instance of ByteString then it will be converted using the ByteString.valueOfObject(Object) method.

      Specified by:
      contains in interface Attribute
      Specified by:
      contains in interface Collection<ByteString>
      Specified by:
      contains in interface Set<ByteString>
      Overrides:
      contains in class AbstractCollection<ByteString>
      Parameters:
      value - The attribute value whose presence in this attribute is to be tested.
      Returns:
      true if this attribute contains value, or false if not.
    • containsAll

      public boolean containsAll(Collection<?> values)
      Description copied from interface: Attribute
      Returns true if this attribute contains all of the attribute values contained in values.

      Any attribute values which are not instances of ByteString will be converted using the ByteString.valueOfObject(Object) method.

      Specified by:
      containsAll in interface Attribute
      Specified by:
      containsAll in interface Collection<ByteString>
      Specified by:
      containsAll in interface Set<ByteString>
      Overrides:
      containsAll in class AbstractCollection<ByteString>
      Parameters:
      values - The attribute values whose presence in this attribute is to be tested.
      Returns:
      true if this attribute contains all of the attribute values contained in values, or false if not.
    • equals

      public boolean equals(Object object)
      Description copied from interface: Attribute
      Returns true if object is an attribute which is equal to this attribute. Two attributes are considered equal if their attribute descriptions are equal, they both have the same number of attribute values, and every attribute value contained in the first attribute is also contained in the second attribute.
      Specified by:
      equals in interface Attribute
      Specified by:
      equals in interface Collection<ByteString>
      Specified by:
      equals in interface Set<ByteString>
      Overrides:
      equals in class AbstractSet<ByteString>
      Parameters:
      object - The object to be tested for equality with this attribute.
      Returns:
      true if object is an attribute which is equal to this attribute, or false if not.
    • firstValue

      Description copied from interface: Attribute
      Returns the first attribute value in this attribute.
      Specified by:
      firstValue in interface Attribute
      Returns:
      The first attribute value in this attribute.
    • firstValueAsString

      Description copied from interface: Attribute
      Returns the first attribute value in this attribute decoded as a UTF-8 string.
      Specified by:
      firstValueAsString in interface Attribute
      Returns:
      The first attribute value in this attribute decoded as a UTF-8 string.
    • getAttributeDescription

      Description copied from interface: Attribute
      Returns the attribute description of this attribute, which includes its attribute type and any options.
      Specified by:
      getAttributeDescription in interface Attribute
      Returns:
      The attribute description.
    • getAttributeDescriptionAsString

      Description copied from interface: Attribute
      Returns the string representation of the attribute description of this attribute, which includes its attribute type and any options.
      Specified by:
      getAttributeDescriptionAsString in interface Attribute
      Returns:
      The string representation of the attribute description.
    • hashCode

      public int hashCode()
      Description copied from interface: Attribute
      Returns the hash code for this attribute. It will be calculated as the sum of the hash codes of the attribute description and all of the attribute values.
      Specified by:
      hashCode in interface Attribute
      Specified by:
      hashCode in interface Collection<ByteString>
      Specified by:
      hashCode in interface Set<ByteString>
      Overrides:
      hashCode in class AbstractSet<ByteString>
      Returns:
      The hash code for this attribute.
    • parse

      Description copied from interface: Attribute
      Returns a parser for this attribute which can be used for decoding values as different types of object.
      Specified by:
      parse in interface Attribute
      Returns:
      A parser for this attribute.
    • iterator

      public abstract Iterator<ByteString> iterator()
      Description copied from interface: Attribute
      Returns 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:
      iterator in interface Attribute
      Specified by:
      iterator in interface Collection<ByteString>
      Specified by:
      iterator in interface Iterable<ByteString>
      Specified by:
      iterator in interface Set<ByteString>
      Specified by:
      iterator in class AbstractCollection<ByteString>
      Returns:
      An iterator over the attribute values in this attribute.
    • remove

      public abstract boolean remove(Object value)
      Description copied from interface: Attribute
      Removes value from this attribute if it is present (optional operation). If this attribute does not contain value, the call leaves the attribute unchanged and returns false.

      If value is not an instance of ByteString then it will be converted using the ByteString.valueOfObject(Object) method.

      Specified by:
      remove in interface Attribute
      Specified by:
      remove in interface Collection<ByteString>
      Specified by:
      remove in interface Set<ByteString>
      Overrides:
      remove in class AbstractCollection<ByteString>
      Parameters:
      value - The attribute value to be removed from this attribute.
      Returns:
      true if this attribute changed as a result of this call.
    • removeAll

      public boolean removeAll(Collection<?> values)
      Description copied from interface: Attribute
      Removes all of the attribute values contained in values from this attribute if they are present (optional operation).

      Any attribute values which are not instances of ByteString will be converted using the ByteString.valueOfObject(Object) method.

      An invocation of this method is equivalent to:

       attribute.removeAll(values, null);
       
      Specified by:
      removeAll in interface Attribute
      Specified by:
      removeAll in interface Collection<ByteString>
      Specified by:
      removeAll in interface Set<ByteString>
      Overrides:
      removeAll in class AbstractSet<ByteString>
      Parameters:
      values - The attribute values to be removed from this attribute.
      Returns:
      true if this attribute changed as a result of this call.
    • removeAll

      public <T> boolean removeAll(Collection<T> values, Collection<? super T> missingValues)
      Description copied from interface: Attribute
      Removes all of the attribute values contained in values from this attribute if they are present (optional operation). Any attribute values which are not already present will be added to missingValues if specified.

      Any attribute values which are not instances of ByteString will be converted using the ByteString.valueOfObject(Object) method.

      Specified by:
      removeAll in interface Attribute
      Type Parameters:
      T - The type of the attribute value objects being removed.
      Parameters:
      values - The attribute values to be removed from this attribute.
      missingValues - A collection into which missing values will be added, or null if missing values should not be saved.
      Returns:
      true if this attribute changed as a result of this call.
    • retainAll

      public boolean retainAll(Collection<?> values)
      Description copied from interface: Attribute
      Retains only the attribute values in this attribute which are contained in values (optional operation).

      Any attribute values which are not instances of ByteString will be converted using the ByteString.valueOfObject(Object) method.

      An invocation of this method is equivalent to:

       attribute.retainAll(values, null);
       
      Specified by:
      retainAll in interface Attribute
      Specified by:
      retainAll in interface Collection<ByteString>
      Specified by:
      retainAll in interface Set<ByteString>
      Overrides:
      retainAll in class AbstractCollection<ByteString>
      Parameters:
      values - The attribute values to be retained in this attribute.
      Returns:
      true if this attribute changed as a result of this call.
    • retainAll

      public <T> boolean retainAll(Collection<T> values, Collection<? super T> missingValues)
      Description copied from interface: Attribute
      Retains only the attribute values in this attribute which are contained in values (optional operation). Any attribute values which are not already present will be added to missingValues if specified.

      Any attribute values which are not instances of ByteString will be converted using the ByteString.valueOfObject(Object) method.

      Specified by:
      retainAll in interface Attribute
      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, or null if missing values should not be saved.
      Returns:
      true if this attribute changed as a result of this call.
    • size

      public abstract int size()
      Description copied from interface: Attribute
      Returns the number of attribute values in this attribute.
      Specified by:
      size in interface Attribute
      Specified by:
      size in interface Collection<ByteString>
      Specified by:
      size in interface Set<ByteString>
      Specified by:
      size in class AbstractCollection<ByteString>
      Returns:
      The number of attribute values in this attribute.
    • toArray

      public ByteString[] toArray()
      Description copied from interface: Attribute
      Returns an array containing all of the attribute values contained in this attribute.

      If this attribute makes any guarantees as to what order its attribute values are returned by its iterator, this method must return the attribute values in the same order.

      The returned array will be "safe" in that no references to it are maintained by this attribute. The caller is thus free to modify the returned array.

      Specified by:
      toArray in interface Attribute
      Specified by:
      toArray in interface Collection<ByteString>
      Specified by:
      toArray in interface Set<ByteString>
      Overrides:
      toArray in class AbstractCollection<ByteString>
      Returns:
      An array containing all of the attribute values contained in this attribute.
    • toString

      public String toString()
      Description copied from interface: Attribute
      Returns a string representation of this attribute.
      Specified by:
      toString in interface Attribute
      Overrides:
      toString in class AbstractCollection<ByteString>
      Returns:
      The string representation of this attribute.