Class 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
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
Modifier and TypeClassDescriptionprotected static class
PropertyDefinition.AbstractBuilder<T,
D extends PropertyDefinition<T>> An interface for incrementally constructing property definitions. -
Constructor Summary
ModifierConstructorDescriptionprotected
PropertyDefinition
(AbstractManagedObjectDefinition<?, ?> d, Class<T> theClass, String propertyName, EnumSet<PropertyOption> options, AdministratorAction adminAction, DefaultBehaviorProvider<ValueOrExpression<T>> defaultBehavior, Deprecated deprecated) Create a property definition. -
Method Summary
Modifier and TypeMethodDescriptionabstract <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.final int
compare
(ValueOrExpression<T> o1, ValueOrExpression<T> o2) Compares two property values for order.final int
compareTo
(PropertyDefinition<?> o) Compares this property definition with the specified property definition for order.final ValueOrExpression<T>
decodeValue
(String value) Parse and validate a string representation of a property value.final ValueOrExpression<T>
decodeValueOrExpression
(String value) Parse and validate a string representation of a property value ot expression.final String
encodeValue
(ValueOrExpression<T> value) Encode the provided property value into its string representation.final boolean
Indicates whether some other object is "equal to" this property definition.final AdministratorAction
Get the administrator action associated with this property definition.Get the default behavior provider associated with this property definition.final Deprecated
Get deprecation definition of property definition.final LocalizableMessage
Gets the optional description of this property definition in the default locale.final LocalizableMessage
getDescription
(Locale locale) Gets the optional description of this property definition in the specified locale.final AbstractManagedObjectDefinition<?,
?> Gets the managed object definition associated with this property definition.final String
getName()
Get the name of the property.final LocalizableMessage
Gets the synopsis of this property definition in the default locale.final LocalizableMessage
getSynopsis
(Locale locale) Gets the synopsis of this property definition in the specified locale.final Comparator<T>
Returns a comparator for the value type.final int
hashCode()
Returns a hash code value for this property definition.final boolean
hasOption
(PropertyOption option) Check if the specified option is set for this property definition.protected void
Performs any run-time initialization required by this property definition.final String
normalizeValue
(ValueOrExpression<T> valueOrExpression) Get a normalized string representation of a property value.final 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.final 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 Details
-
PropertyDefinition
protected PropertyDefinition(AbstractManagedObjectDefinition<?, ?> d, Class<T> theClass, String propertyName, EnumSet<PropertyOption> options, AdministratorAction adminAction, DefaultBehaviorProvider<ValueOrExpression<T>> defaultBehavior, Deprecated deprecated) 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.deprecated
- The deprecation description.
-
-
Method Details
-
accept
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
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
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
Returns a comparator for the value type.- Returns:
- a comparator
-
compareTo
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
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
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
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
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:
-
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
Get the default behavior provider associated with this property definition.- Returns:
- Returns the default behavior provider associated with this property definition.
-
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
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
Gets the managed object definition associated with this property definition.- Returns:
- Returns the managed object definition associated with this property definition.
-
getName
Get the name of the property.- Returns:
- Returns the name of the property.
-
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
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.
-
getDeprecated
Get deprecation definition of property definition.- Returns:
- Returns a deprecated definition of this managed object definition.
-
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
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
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
Returns a string representation of this property definition. -
toString
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
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.
-
initialize
Performs any run-time initialization required by this property definition. This may include resolving managed object paths and property names.- Throws:
Exception
- If this property definition could not be initialized.
-