Class Attributes
- java.lang.Object
-
- org.forgerock.opendj.ldap.Attributes
-
public final class Attributes extends Object
This class contains methods for creating and manipulating attributes.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Attribute
emptyAttribute(String attributeDescription)
Returns a read-only empty attribute having the specified attribute description.static Attribute
emptyAttribute(AttributeDescription attributeDescription)
Returns a read-only empty attribute having the specified attribute description.static Attribute
renameAttribute(Attribute attribute, String attributeDescription)
Returns a view ofattribute
having a different attribute description.static Attribute
renameAttribute(Attribute attribute, AttributeDescription attributeDescription)
Returns a view ofattribute
having a different attribute description.static Attribute
singletonAttribute(String attributeDescription, Object value)
Returns a read-only single-valued attribute having the specified attribute description.static Attribute
singletonAttribute(AttributeDescription attributeDescription, Object value)
Returns a read-only single-valued attribute having the specified attribute description and value.static Attribute
unmodifiableAttribute(Attribute attribute)
Returns a read-only view ofattribute
.static Attribute
virtualAttribute(Attribute attribute)
Returns a view ofattribute
that is virtual, i.e.static Attribute
virtualAttribute(AttributeDescription attributeDescription)
Returns an empty virtual attribute.static Attribute
virtualAttribute(AttributeDescription attributeDescription, Supplier<Collection<?>> attributeValuesSupplier)
Returns a virtual attribute whose values will be supplied by providedSupplier
.
-
-
-
Method Detail
-
emptyAttribute
public static Attribute emptyAttribute(AttributeDescription attributeDescription)
Returns a read-only empty attribute having the specified attribute description. Attempts to modify the returned attribute either directly, or indirectly via an iterator, result in anUnsupportedOperationException
.- Parameters:
attributeDescription
- The attribute description.- Returns:
- The empty attribute.
- Throws:
NullPointerException
- IfattributeDescription
wasnull
.
-
emptyAttribute
public static Attribute emptyAttribute(String attributeDescription)
Returns a read-only empty attribute having the specified attribute description. The attribute description will be decoded using the default schema. Attempts to modify the returned attribute either directly, or indirectly via an iterator, result in anUnsupportedOperationException
.- Parameters:
attributeDescription
- The attribute description.- Returns:
- The empty attribute.
- Throws:
LocalizedIllegalArgumentException
- IfattributeDescription
could not be decoded using the default schema.NullPointerException
- IfattributeDescription
wasnull
.
-
renameAttribute
public static Attribute renameAttribute(Attribute attribute, AttributeDescription attributeDescription)
Returns a view ofattribute
having a different attribute description. All operations on the returned attribute "pass-through" to the underlying attribute.- Parameters:
attribute
- The attribute to be renamed.attributeDescription
- The new attribute description forattribute
.- Returns:
- A renamed view of
attribute
. - Throws:
NullPointerException
- Ifattribute
orattributeDescription
wasnull
.
-
renameAttribute
public static Attribute renameAttribute(Attribute attribute, String attributeDescription)
Returns a view ofattribute
having a different attribute description. All operations on the returned attribute "pass-through" to the underlying attribute. The attribute description will be decoded using the default schema.- Parameters:
attribute
- The attribute to be renamed.attributeDescription
- The new attribute description forattribute
.- Returns:
- A renamed view of
attribute
. - Throws:
LocalizedIllegalArgumentException
- IfattributeDescription
could not be decoded using the default schema.NullPointerException
- Ifattribute
orattributeDescription
wasnull
.
-
singletonAttribute
public static Attribute singletonAttribute(AttributeDescription attributeDescription, Object value)
Returns a read-only single-valued attribute having the specified attribute description and value. Attempts to modify the returned attribute either directly, or indirectly via an iterator, result in anUnsupportedOperationException
.If
value
is not an instance ofByteString
then it will be converted using theByteString.valueOfObject(Object)
method.- Parameters:
attributeDescription
- The attribute description.value
- The single attribute value.- Returns:
- The single-valued attribute.
- Throws:
NullPointerException
- IfattributeDescription
orvalue
wasnull
.
-
singletonAttribute
public static Attribute singletonAttribute(String attributeDescription, Object value)
Returns a read-only single-valued attribute having the specified attribute description. The attribute description will be decoded using the default schema. Attempts to modify the returned attribute either directly, or indirectly via an iterator, result in anUnsupportedOperationException
.If
value
is not an instance ofByteString
then it will be converted using theByteString.valueOfObject(Object)
method.- Parameters:
attributeDescription
- The attribute description.value
- The single attribute value.- Returns:
- The single-valued attribute.
- Throws:
LocalizedIllegalArgumentException
- IfattributeDescription
could not be decoded using the default schema.NullPointerException
- IfattributeDescription
orvalue
wasnull
.
-
unmodifiableAttribute
public static Attribute unmodifiableAttribute(Attribute attribute)
Returns a read-only view ofattribute
. Query operations on the returned attribute "read-through" to the underlying attribute, and attempts to modify the returned attribute either directly or indirectly via an iterator result in anUnsupportedOperationException
.- Parameters:
attribute
- The attribute for which a read-only view is to be returned.- Returns:
- A read-only view of
attribute
. - Throws:
NullPointerException
- Ifattribute
wasnull
.
-
virtualAttribute
public static Attribute virtualAttribute(Attribute attribute)
Returns a view ofattribute
that is virtual, i.e. implementations ofAttribute.isVirtual()
andAttribute.isReal()
match the semantics of virtual attributes.Virtual attributes a special kind of attribute whose values do not actually exist in persistent storage but rather are dynamically generated in some manner.
In particular, this method can be used to implement collective virtual attribute, which is a special kind of attribute whose values do not actually exist in persistent storage but rather are obtained dynamically from applicable collective attribute subentry.
- Parameters:
attribute
- The attribute for which a read-only view is to be returned.- Returns:
- A read-only view of
attribute
. - Throws:
NullPointerException
- Ifattribute
wasnull
.
-
virtualAttribute
public static Attribute virtualAttribute(AttributeDescription attributeDescription, Supplier<Collection<?>> attributeValuesSupplier)
Returns a virtual attribute whose values will be supplied by providedSupplier
.Virtual attributes a special kind of attribute whose values do not actually exist in persistent storage but rather are dynamically generated in some manner.
In particular, this method can be used to implement collective virtual attribute, which is a special kind of attribute whose values do not actually exist in persistent storage but rather are obtained dynamically from applicable collective attribute subentry.
Note: this method should be used when computing the attribute value operation is costly. Indeed, this method returns an attribute which lazily computes the attribute value.
- Parameters:
attributeDescription
- the attribute description of the attributeattributeValuesSupplier
- The supplier that returns the attribute values for which a read-only view is to be returned.- Returns:
- A read-only view of
attribute
. - Throws:
NullPointerException
- Ifattribute
wasnull
.
-
virtualAttribute
public static Attribute virtualAttribute(AttributeDescription attributeDescription)
Returns an empty virtual attribute.Virtual attributes a special kind of attribute whose values do not actually exist in persistent storage but rather are dynamically generated in some manner.
In particular, this method can be used to implement collective virtual attribute, which is a special kind of attribute whose values do not actually exist in persistent storage but rather are obtained dynamically from applicable collective attribute subentry.
- Parameters:
attributeDescription
- The attribute for which a read-only view is to be returned.- Returns:
- A read-only view of an empty
attribute
. - Throws:
NullPointerException
- Ifattribute
wasnull
.
-
-