T
- The actual data-type of values of the property.public abstract class PropertyDefinition<T> extends Object implements Comparator<ValueOrExpression<T>>, Comparable<PropertyDefinition<?>>
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.
Modifier and Type | Class and Description |
---|---|
protected static class |
PropertyDefinition.AbstractBuilder<T,D extends PropertyDefinition<T>>
An interface for incrementally constructing property definitions.
|
Modifier | Constructor and Description |
---|---|
protected |
PropertyDefinition(AbstractManagedObjectDefinition<?,?> d,
Class<T> theClass,
String propertyName,
EnumSet<PropertyOption> options,
AdministratorAction adminAction,
DefaultBehaviorProvider<ValueOrExpression<T>> defaultBehavior)
Create a property definition.
|
Modifier and Type | Method and Description |
---|---|
abstract <R,P> R |
accept(PropertyDefinitionVisitor<R,P> v,
P p)
Apply a visitor to this property definition.
|
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.
|
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.
|
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.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
comparing, comparing, comparingDouble, comparingInt, comparingLong, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
protected PropertyDefinition(AbstractManagedObjectDefinition<?,?> d, Class<T> theClass, String propertyName, EnumSet<PropertyOption> options, AdministratorAction adminAction, DefaultBehaviorProvider<ValueOrExpression<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.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, ValueOrExpression<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 int compare(ValueOrExpression<T> o1, ValueOrExpression<T> o2)
compare
in interface Comparator<ValueOrExpression<T>>
o1
- the first object to be compared.o2
- the second object to be compared.public final Comparator<T> getValueComparator()
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 Comparable<PropertyDefinition<?>>
o
- The reference property definition with which to compare.public final ValueOrExpression<T> decodeValue(String value)
value
- The property string value (must not be null
).PropertyException
- If the property value string is invalid.public final String encodeValue(ValueOrExpression<T> value)
This default implementation simply returns invokes the
Object.toString()
method on the provided value.
value
- The property value (must not be null
).PropertyException
- If the property value is invalid.public final boolean equals(Object o)
equals(Object)
. Additionally, this method can return
true
only if the specified Object is also a property
definition and it has the same name, as returned by 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 Comparator<ValueOrExpression<T>>
equals
in class 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<ValueOrExpression<T>> getDefaultBehaviorProvider()
public final LocalizableMessage getDescription()
null
if there is no description.public final LocalizableMessage getDescription(Locale locale)
locale
- The locale.null
if there is no
description.public final AbstractManagedObjectDefinition<?,?> getManagedObjectDefinition()
public final String getName()
public final LocalizableMessage getSynopsis()
public final LocalizableMessage getSynopsis(Locale locale)
locale
- The locale.public final int hashCode()
public final boolean hasOption(PropertyOption option)
option
- The option to test.true
if the option is set, or
false
otherwise.public final String normalizeValue(ValueOrExpression<T> valueOrExpression)
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).
valueOrExpression
- The property value to be normalized.PropertyException
- If the property value is invalid.public final String toString()
toString
in class Object
Object.toString()
public void toString(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 final void validateValue(ValueOrExpression<T> valueOrExpression)
valueOrExpression
- The property value (must not be null
).PropertyException
- If the property value is invalid.Copyright 2010-2022 ForgeRock AS.