Class LinkedAttribute

  • All Implemented Interfaces:
    Iterable<ByteString>, Collection<ByteString>, Set<ByteString>, Attribute

    public final class LinkedAttribute
    extends AbstractAttribute
    An implementation of the Attribute interface with predictable iteration order.

    Internally, attribute values are stored in a linked list and it's this list which defines the iteration ordering, which is the order in which elements were inserted into the set (insertion-order). This ordering is particularly useful in LDAP where clients generally appreciate having things returned in the same order they were presented.

    All operations are supported by this implementation.

    • Constructor Detail

      • LinkedAttribute

        public LinkedAttribute​(Attribute attribute)
        Creates a new attribute having the same attribute description and attribute values as attribute.
        Parameters:
        attribute - The attribute to be copied.
        Throws:
        NullPointerException - If attribute was null.
      • LinkedAttribute

        public LinkedAttribute​(AttributeDescription attributeDescription)
        Creates a new attribute having the specified attribute description and no attribute values.
        Parameters:
        attributeDescription - The attribute description.
        Throws:
        NullPointerException - If attributeDescription was null.
      • LinkedAttribute

        public LinkedAttribute​(AttributeDescription attributeDescription,
                               Object value)
        Creates a new attribute having the specified attribute description and single attribute value.

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

        Parameters:
        attributeDescription - The attribute description.
        value - The single attribute value.
        Throws:
        NullPointerException - If attributeDescription or value was null .
      • LinkedAttribute

        public LinkedAttribute​(AttributeDescription attributeDescription,
                               Object... values)
        Creates a new attribute having the specified attribute description and attribute values.

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

        Parameters:
        attributeDescription - The attribute description.
        values - The attribute values.
        Throws:
        NullPointerException - If attributeDescription or values was null.
      • LinkedAttribute

        public LinkedAttribute​(AttributeDescription attributeDescription,
                               Collection<?> values)
        Creates a new attribute having the specified attribute description and attribute values.

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

        Parameters:
        attributeDescription - The attribute description.
        values - The attribute values.
        Throws:
        NullPointerException - If attributeDescription or values was null.
      • LinkedAttribute

        public LinkedAttribute​(String attributeDescription)
        Creates a new attribute having the specified attribute description and no attribute values. The attribute description will be decoded using the default schema.
        Parameters:
        attributeDescription - The attribute description.
        Throws:
        LocalizedIllegalArgumentException - If attributeDescription could not be decoded using the default schema.
        NullPointerException - If attributeDescription was null.
      • LinkedAttribute

        public LinkedAttribute​(String attributeDescription,
                               Collection<?> values)
        Creates a new attribute having the specified attribute description and attribute values. The attribute description will be decoded using the default schema.

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

        Parameters:
        attributeDescription - The attribute description.
        values - The attribute values.
        Throws:
        LocalizedIllegalArgumentException - If attributeDescription could not be decoded using the default schema.
        NullPointerException - If attributeDescription or values was null.
      • LinkedAttribute

        public LinkedAttribute​(String attributeDescription,
                               Object value)
        Creates a new attribute having the specified attribute description and single attribute value. The attribute description will be decoded using the default schema.

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

        Parameters:
        attributeDescription - The attribute description.
        value - The single attribute value.
        Throws:
        LocalizedIllegalArgumentException - If attributeDescription could not be decoded using the default schema.
        NullPointerException - If attributeDescription or value was null .
      • LinkedAttribute

        public LinkedAttribute​(String attributeDescription,
                               Object... values)
        Creates a new attribute having the specified attribute description and attribute values. The attribute description will be decoded using the default schema.

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

        Parameters:
        attributeDescription - The attribute description.
        values - The attribute values.
        Throws:
        LocalizedIllegalArgumentException - If attributeDescription could not be decoded using the default schema.
        NullPointerException - If attributeDescription or values was null.
    • Method Detail

      • add

        public 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.
      • getAttributeDescription

        public AttributeDescription getAttributeDescription()
        Description copied from interface: Attribute
        Returns the attribute description of this attribute, which includes its attribute type and any options.
        Returns:
        The attribute description.
      • isVirtual

        public boolean isVirtual()
        Description copied from interface: Attribute
        Indicates whether this is a virtual attribute (dynamically computed) rather than a real attribute (persisted).
        Returns:
        true if this is a virtual attribute.
      • matchesEqualityAssertion

        public ConditionResult matchesEqualityAssertion​(Assertion assertion,
                                                        ByteSequence rawAssertion)
        NOTE: it is only possible to optimize for the equality matching rule because the other matching rules may not be compatible with the equality matching rule's normalized representation. For example, DN syntax uses DN matching for equality and case ignore string matching for substring matching.
        Specified by:
        matchesEqualityAssertion in interface Attribute
        Overrides:
        matchesEqualityAssertion in class AbstractAttribute
        Parameters:
        assertion - The attribute value assertion compiled using the attribute's default equality matching rule.
        rawAssertion - The raw assertion value whose syntax is compatible with the attribute's default equality matching rule.
        Returns:
        ConditionResult.FALSE if the assertion does not match any values in this attribute, ConditionResult.TRUE if the assertion matches at least one value in this attribute, or ConditionResult.UNDEFINED if the assertion does not match any values in this attribute, but one or more values could not be compared because they are incompatible with the matching rule.
      • remove

        public 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.
      • 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
        Overrides:
        retainAll in class AbstractAttribute
        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.