Class PropertyDefinition<T>
- java.lang.Object
-
- org.forgerock.opendj.config.PropertyDefinition<T>
-
- Type Parameters:
T
- The actual data-type of values of the property.
- All Implemented Interfaces:
Comparable<PropertyDefinition<?>>
,Comparator<ValueOrExpression<T>>
- Direct Known Subclasses:
AciPropertyDefinition
,AggregationPropertyDefinition
,AttributeTypePropertyDefinition
,BooleanPropertyDefinition
,ClassPropertyDefinition
,DnPropertyDefinition
,DurationPropertyDefinition
,EnumPropertyDefinition
,HostPortPropertyDefinition
,HostPropertyDefinition
,IntegerPropertyDefinition
,IpAddressMaskPropertyDefinition
,SizePropertyDefinition
,StringPropertyDefinition
public abstract class PropertyDefinition<T> extends Object implements Comparator<ValueOrExpression<T>>, Comparable<PropertyDefinition<?>>
An interface for querying generic property definition features.Property definitions are analogous to ConfigAttributes in the current model and will play a similar role. Eventually these will replace them.
Implementations must take care to implement the various comparison methods.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
PropertyDefinition.AbstractBuilder<T,D extends PropertyDefinition<T>>
An interface for incrementally constructing property definitions.
-
Constructor Summary
Constructors Modifier Constructor Description protected
PropertyDefinition(AbstractManagedObjectDefinition<?,?> d, Class<T> theClass, String propertyName, EnumSet<PropertyOption> options, AdministratorAction adminAction, DefaultBehaviorProvider<ValueOrExpression<T>> defaultBehavior)
Create a property definition.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract <R,P>
Raccept(PropertyDefinitionVisitor<R,P> v, P p)
Apply a visitor to this property definition.abstract <R,P>
Raccept(PropertyValueVisitor<R,P> v, ValueOrExpression<T> value, P p)
Apply a visitor to a property value associated with this property definition.int
compare(ValueOrExpression<T> o1, ValueOrExpression<T> o2)
Compares two property values for order.int
compareTo(PropertyDefinition<?> o)
Compares this property definition with the specified property definition for order.ValueOrExpression<T>
decodeValue(String value)
Parse and validate a string representation of a property value.ValueOrExpression<T>
decodeValueOrExpression(String value)
Parse and validate a string representation of a property value ot expression.String
encodeValue(ValueOrExpression<T> value)
Encode the provided property value into its string representation.boolean
equals(Object o)
Indicates whether some other object is "equal to" this property definition.AdministratorAction
getAdministratorAction()
Get the administrator action associated with this property definition.DefaultBehaviorProvider<ValueOrExpression<T>>
getDefaultBehaviorProvider()
Get the default behavior provider associated with this property definition.LocalizableMessage
getDescription()
Gets the optional description of this property definition in the default locale.LocalizableMessage
getDescription(Locale locale)
Gets the optional description of this property definition in the specified locale.AbstractManagedObjectDefinition<?,?>
getManagedObjectDefinition()
Gets the managed object definition associated with this property definition.String
getName()
Get the name of the property.LocalizableMessage
getSynopsis()
Gets the synopsis of this property definition in the default locale.LocalizableMessage
getSynopsis(Locale locale)
Gets the synopsis of this property definition in the specified locale.Comparator<T>
getValueComparator()
Returns a comparator for the value type.int
hashCode()
Returns a hash code value for this property definition.boolean
hasOption(PropertyOption option)
Check if the specified option is set for this property definition.protected void
initialize()
Performs any run-time initialization required by this property definition.String
normalizeValue(ValueOrExpression<T> valueOrExpression)
Get a normalized string representation of a property value.String
toString()
Returns a string representation of this property definition.void
toString(StringBuilder builder)
Append a string representation of the property definition to the provided string builder.void
validateValue(ValueOrExpression<T> valueOrExpression)
Determine if the provided property value is valid according to this property definition.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
-
-
-
Constructor Detail
-
PropertyDefinition
protected PropertyDefinition(AbstractManagedObjectDefinition<?,?> d, Class<T> theClass, String propertyName, EnumSet<PropertyOption> options, AdministratorAction adminAction, DefaultBehaviorProvider<ValueOrExpression<T>> defaultBehavior)
Create a property definition.- Parameters:
d
- The managed object definition associated with this property definition.theClass
- The property value class.propertyName
- The property name.options
- Options applicable to this definition.adminAction
- The administrator action.defaultBehavior
- The default behavior provider.
-
-
Method Detail
-
accept
public abstract <R,P> R accept(PropertyDefinitionVisitor<R,P> v, P p)
Apply a visitor to this property definition.- Type Parameters:
R
- The return type of the visitor's methods.P
- The type of the additional parameters to the visitor's methods.- Parameters:
v
- The property definition visitor.p
- Optional additional visitor parameter.- Returns:
- Returns a result as specified by the visitor.
-
accept
public abstract <R,P> R accept(PropertyValueVisitor<R,P> v, ValueOrExpression<T> value, P p)
Apply a visitor to a property value associated with this property definition.- Type Parameters:
R
- The return type of the visitor's methods.P
- The type of the additional parameters to the visitor's methods.- Parameters:
v
- The property value visitor.value
- The property value.p
- Optional additional visitor parameter.- Returns:
- Returns a result as specified by the visitor.
-
compare
public final int compare(ValueOrExpression<T> o1, ValueOrExpression<T> o2)
Compares two property values for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.- Specified by:
compare
in interfaceComparator<T>
- Parameters:
o1
- the first object to be compared.o2
- the second object to be compared.- Returns:
- a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
-
getValueComparator
public final Comparator<T> getValueComparator()
Returns a comparator for the value type.- Returns:
- a comparator
-
compareTo
public final int compareTo(PropertyDefinition<?> o)
Compares this property definition with the specified property definition for order. Returns a negative integer, zero, or a positive integer if this property definition is less than, equal to, or greater than the specified property definition.The ordering must be determined first from the property name and then base on the underlying value type.
- Specified by:
compareTo
in interfaceComparable<T>
- Parameters:
o
- The reference property definition with which to compare.- Returns:
- Returns a negative integer, zero, or a positive integer if this property definition is less than, equal to, or greater than the specified property definition.
-
decodeValueOrExpression
public final ValueOrExpression<T> decodeValueOrExpression(String value)
Parse and validate a string representation of a property value ot expression.- Parameters:
value
- The property string value or expression (must not benull
).- Returns:
- Returns the decoded property value or expression.
- Throws:
PropertyException
- If the property value or expression string is invalid.
-
decodeValue
public final ValueOrExpression<T> decodeValue(String value)
Parse and validate a string representation of a property value.- Parameters:
value
- The property string value (must not benull
).- Returns:
- Returns the decoded property value.
- Throws:
PropertyException
- If the property value string is invalid.
-
encodeValue
public final String encodeValue(ValueOrExpression<T> value)
Encode the provided property value into its string representation.This default implementation simply returns invokes the
Object.toString()
method on the provided value.- Parameters:
value
- The property value (must not benull
).- Returns:
- Returns the encoded property string value.
- Throws:
PropertyException
- If the property value is invalid.
-
equals
public final boolean equals(Object o)
Indicates whether some other object is "equal to" this property definition. This method must obey the general contract ofObject.equals(Object)
. Additionally, this method can returntrue
only if the specified Object is also a property definition and it has the same name, as returned bygetName()
, and also is deemed to be "compatible" with this property definition. Compatibility means that the two property definitions share the same underlying value type and provide similar comparator implementations.- Specified by:
equals
in interfaceComparator<T>
- Overrides:
equals
in classObject
- Parameters:
o
- The reference object with which to compare.- Returns:
- Returns
true
only if the specified object is also a property definition and it has the same name and is compatible with this property definition. - See Also:
Object.equals(java.lang.Object)
,Object.hashCode()
-
getAdministratorAction
public final AdministratorAction getAdministratorAction()
Get the administrator action associated with this property definition. The administrator action describes any action which the administrator must perform in order for changes to this property to take effect.- Returns:
- Returns the administrator action associated with this property definition.
-
getDefaultBehaviorProvider
public final DefaultBehaviorProvider<ValueOrExpression<T>> getDefaultBehaviorProvider()
Get the default behavior provider associated with this property definition.- Returns:
- Returns the default behavior provider associated with this property definition.
-
getDescription
public final LocalizableMessage getDescription()
Gets the optional description of this property definition in the default locale.- Returns:
- Returns the description of this property definition in the
default locale, or
null
if there is no description.
-
getDescription
public final LocalizableMessage getDescription(Locale locale)
Gets the optional description of this property definition in the specified locale.- Parameters:
locale
- The locale.- Returns:
- Returns the description of this property definition in the
specified locale, or
null
if there is no description.
-
getManagedObjectDefinition
public final AbstractManagedObjectDefinition<?,?> getManagedObjectDefinition()
Gets the managed object definition associated with this property definition.- Returns:
- Returns the managed object definition associated with this property definition.
-
getName
public final String getName()
Get the name of the property.- Returns:
- Returns the name of the property.
-
getSynopsis
public final LocalizableMessage getSynopsis()
Gets the synopsis of this property definition in the default locale.- Returns:
- Returns the synopsis of this property definition in the default locale.
-
getSynopsis
public final LocalizableMessage getSynopsis(Locale locale)
Gets the synopsis of this property definition in the specified locale.- Parameters:
locale
- The locale.- Returns:
- Returns the synopsis of this property definition in the specified locale.
-
hashCode
public final int hashCode()
Returns a hash code value for this property definition. The hash code should be derived from the property name and the type of values handled by this property definition.
-
hasOption
public final boolean hasOption(PropertyOption option)
Check if the specified option is set for this property definition.- Parameters:
option
- The option to test.- Returns:
- Returns
true
if the option is set, orfalse
otherwise.
-
normalizeValue
public final String normalizeValue(ValueOrExpression<T> valueOrExpression)
Get a normalized string representation of a property value. This can then be used for comparisons and for generating hash-codes.This method may throw an exception if the provided value is invalid. However, applications should not assume that implementations of this method will always validate a value. This task is the responsibility of
validateValue(ValueOrExpression)
.This default implementation simply returns the string representation of the provided value. Sub-classes might want to override this method if this behavior is insufficient (for example, a string property definition might strip white-space and convert characters to lower-case).
- Parameters:
valueOrExpression
- The property value to be normalized.- Returns:
- Returns the normalized property value.
- Throws:
PropertyException
- If the property value is invalid.
-
toString
public final String toString()
Returns a string representation of this property definition.- Overrides:
toString
in classObject
- Returns:
- Returns a string representation of this property definition.
- See Also:
Object.toString()
-
toString
public void toString(StringBuilder builder)
Append a string representation of the property definition to the provided string builder.This simple implementation just outputs the propertyName of the property definition. Sub-classes should override this method to provide more complete string representations.
- Parameters:
builder
- The string builder where the string representation should be appended.
-
validateValue
public final void validateValue(ValueOrExpression<T> valueOrExpression)
Determine if the provided property value is valid according to this property definition.- Parameters:
valueOrExpression
- The property value (must not benull
).- Throws:
PropertyException
- If the property value is invalid.
-
-