|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opends.server.admin.PropertyDefinition<T>
T
- The data-type of values of the property.public abstract class PropertyDefinition<T>
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 | |
---|---|
protected static class |
PropertyDefinition.AbstractBuilder<T,D extends PropertyDefinition<T>>
An interface for incrementally constructing property definitions. |
Constructor Summary | |
---|---|
protected |
PropertyDefinition(AbstractManagedObjectDefinition<?,?> d,
java.lang.Class<T> theClass,
java.lang.String propertyName,
java.util.EnumSet<PropertyOption> options,
AdministratorAction adminAction,
DefaultBehaviorProvider<T> defaultBehavior)
Create a property definition. |
Method Summary | ||
---|---|---|
abstract
|
accept(PropertyDefinitionVisitor<R,P> v,
P p)
Apply a visitor to this property definition. |
|
abstract
|
accept(PropertyValueVisitor<R,P> v,
T value,
P p)
Apply a visitor to a property value associated with this property definition. |
|
T |
castValue(java.lang.Object object)
Cast the provided value to the type associated with this property definition. |
|
int |
compare(T o1,
T o2)
Compares two property values for order. |
|
int |
compareTo(PropertyDefinition<?> o)
Compares this property definition with the specified property definition for order. |
|
abstract T |
decodeValue(java.lang.String value)
Parse and validate a string representation of a property value. |
|
java.lang.String |
encodeValue(T value)
Encode the provided property value into its string representation. |
|
boolean |
equals(java.lang.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<T> |
getDefaultBehaviorProvider()
Get the default behavior provider associated with this property definition. |
|
Message |
getDescription()
Gets the optional description of this property definition in the default locale. |
|
Message |
getDescription(java.util.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. |
|
java.lang.String |
getName()
Get the name of the property. |
|
Message |
getSynopsis()
Gets the synopsis of this property definition in the default locale. |
|
Message |
getSynopsis(java.util.Locale locale)
Gets the synopsis of this property definition in the specified locale. |
|
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. |
|
java.lang.String |
normalizeValue(T value)
Get a normalized string representation of a property value. |
|
java.lang.String |
toString()
Returns a string representation of this property definition. |
|
void |
toString(java.lang.StringBuilder builder)
Append a string representation of the property definition to the provided string builder. |
|
abstract void |
validateValue(T value)
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 |
Constructor Detail |
---|
protected PropertyDefinition(AbstractManagedObjectDefinition<?,?> d, java.lang.Class<T> theClass, java.lang.String propertyName, java.util.EnumSet<PropertyOption> options, AdministratorAction adminAction, DefaultBehaviorProvider<T> defaultBehavior)
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 |
---|
public abstract <R,P> R accept(PropertyDefinitionVisitor<R,P> v, P p)
R
- The return type of the visitor's methods.P
- The type of the additional parameters to the visitor's
methods.v
- The property definition visitor.p
- Optional additional visitor parameter.
public abstract <R,P> R accept(PropertyValueVisitor<R,P> v, T value, P p)
R
- The return type of the visitor's methods.P
- The type of the additional parameters to the visitor's
methods.v
- The property value visitor.value
- The property value.p
- Optional additional visitor parameter.
public final T castValue(java.lang.Object object) throws java.lang.ClassCastException
This method only casts the object to the required type; it does
not validate the value once it has been cast. Subsequent
validation should be performed using the method
validateValue(Object)
.
This method guarantees the following expression is always
true
:
PropertyDefinition d; x == d.cast(x);
object
- The property value to be cast (can be null
).
java.lang.ClassCastException
- If the provided property value did not have the correct
type.public int compare(T o1, T o2)
This default implementation normalizes both values using
normalizeValue(Object)
and then performs a
case-sensitive string comparison.
compare
in interface java.util.Comparator<T>
o1
- the first object to be compared.o2
- the second object to be compared.
public final int compareTo(PropertyDefinition<?> o)
The ordering must be determined first from the property name and then base on the underlying value type.
compareTo
in interface java.lang.Comparable<PropertyDefinition<?>>
o
- The reference property definition with which to compare.
public abstract T decodeValue(java.lang.String value) throws IllegalPropertyValueStringException
value
- The property string value (must not be null
).
IllegalPropertyValueStringException
- If the property value string is invalid.public java.lang.String encodeValue(T value) throws IllegalPropertyValueException
This default implementation simply returns invokes the
Object.toString()
method on the provided value.
value
- The property value (must not be null
).
IllegalPropertyValueException
- If the property value is invalid.public final boolean equals(java.lang.Object o)
getName()
, 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.
equals
in interface java.util.Comparator<T>
equals
in class java.lang.Object
o
- The reference object with which to compare.
true
only if the specified object
is also a property definition and it has the same name
and is compatible with this property definition.Object.equals(java.lang.Object)
,
Object.hashCode()
public final AdministratorAction getAdministratorAction()
public final DefaultBehaviorProvider<T> getDefaultBehaviorProvider()
public final Message getDescription()
null
if there is no
description.public final Message getDescription(java.util.Locale locale)
locale
- The locale.
null
if there is
no description.public final AbstractManagedObjectDefinition<?,?> getManagedObjectDefinition()
public final java.lang.String getName()
public final Message getSynopsis()
public final Message getSynopsis(java.util.Locale locale)
locale
- The locale.
public final int hashCode()
hashCode
in class java.lang.Object
public final boolean hasOption(PropertyOption option)
option
- The option to test.
true
if the option is set, or
false
otherwise.public java.lang.String normalizeValue(T value) throws IllegalPropertyValueException
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(Object)
.
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).
value
- The property value to be normalized.
IllegalPropertyValueException
- If the property value is invalid.public final java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
public void toString(java.lang.StringBuilder builder)
This simple implementation just outputs the propertyName of the property definition. Sub-classes should override this method to provide more complete string representations.
builder
- The string builder where the string representation
should be appended.public abstract void validateValue(T value) throws IllegalPropertyValueException
value
- The property value (must not be null
).
IllegalPropertyValueException
- If the property value is invalid.protected void initialize() throws java.lang.Exception
java.lang.Exception
- If this property definition could not be initialized.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |