Package net.sourceforge.pmd.properties
Interface PropertyDescriptor<T>
-
- Type Parameters:
T
- type of the property's value. This is a list type for multi-valued properties.
- All Superinterfaces:
java.lang.Comparable<PropertyDescriptor<?>>
- All Known Subinterfaces:
EnumeratedPropertyDescriptor<E,T>
,MultiValuePropertyDescriptor<V>
,NumericPropertyDescriptor<T>
,PackagedPropertyDescriptor<T>
,SingleValuePropertyDescriptor<T>
- All Known Implementing Classes:
BooleanMultiProperty
,BooleanProperty
,CharacterMultiProperty
,CharacterProperty
,DoubleMultiProperty
,DoubleProperty
,EnumeratedMultiProperty
,EnumeratedProperty
,FileProperty
,FloatMultiProperty
,FloatProperty
,IntegerMultiProperty
,IntegerProperty
,LongMultiProperty
,LongProperty
,MethodMultiProperty
,MethodProperty
,RegexProperty
,StringMultiProperty
,StringProperty
,TypeMultiProperty
,TypeProperty
public interface PropertyDescriptor<T> extends java.lang.Comparable<PropertyDescriptor<?>>
Property value descriptor that defines the use & requirements for setting property values for use within PMD and any associated GUIs. While concrete descriptor instances are static and immutable they provide validation, serialization, and default values for any specific datatypes.This interface is primarily specialized according to whether the property is multi-valued or single-valued, see
SingleValuePropertyDescriptor
andMultiValuePropertyDescriptor
.Several interfaces further specialize the behaviour of descriptors to accommodate specific types of descriptors, see
NumericPropertyDescriptor
andEnumeratedPropertyDescriptor
.- Version:
- Refactored June 2017 (6.0.0)
- Author:
- Brian Remedios, Clément Fournier
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.String
asDelimitedString(T value)
Formats the object onto a string suitable for storage within the property map.java.util.Map<PropertyDescriptorField,java.lang.String>
attributeValuesById()
Returns a map representing all the property attributes of the receiver in string form.T
defaultValue()
Default value to use when the user hasn't specified one or when they wish to revert to a known-good state.java.lang.String
description()
Describes the property and the role it plays within the rule it is specified for.java.lang.String
errorFor(T value)
Validation function that returns a diagnostic error message for a sample property value.boolean
isDefinedExternally()
True if this descriptor was defined in the ruleset xml.boolean
isMultiValue()
Returns whether the property is multi-valued, i.e.java.lang.String
name()
The name of the property without spaces as it serves as the key into the property map.int
preferredRowCount()
If the datatype is a String then return the preferred number of rows to allocate in the text widget, returns a value of one for all other types.java.lang.String
propertyErrorFor(Rule rule)
A convenience method that returns an error string if the rule holds onto a property value that has a problem.java.lang.Class<?>
type()
Denotes the value datatype.float
uiOrder()
Denotes the relative order the property field should occupy if we are using an auto-generated UI to display and edit property values.T
valueFrom(java.lang.String propertyString)
Returns the value represented by this string.
-
-
-
Method Detail
-
name
java.lang.String name()
The name of the property without spaces as it serves as the key into the property map.- Returns:
- String
-
description
java.lang.String description()
Describes the property and the role it plays within the rule it is specified for. Could be used in a tooltip.- Returns:
- String
-
type
java.lang.Class<?> type()
Denotes the value datatype. For multi value properties, this is not the List class but the list's component class.- Returns:
- Class literal of the value type
-
isMultiValue
boolean isMultiValue()
Returns whether the property is multi-valued, i.e. an array of strings,As unary property rule properties will return a value of one, you must use the get/setProperty accessors when working with the actual values. When working with multi-value properties then the get/setProperties accessors must be used.
- Returns:
- boolean
-
defaultValue
T defaultValue()
Default value to use when the user hasn't specified one or when they wish to revert to a known-good state.- Returns:
- Object
-
errorFor
java.lang.String errorFor(T value)
Validation function that returns a diagnostic error message for a sample property value. Returns null if the value is acceptable.- Parameters:
value
- The value to check.- Returns:
- A diagnostic message.
-
uiOrder
float uiOrder()
Denotes the relative order the property field should occupy if we are using an auto-generated UI to display and edit property values. If the value returned has a non-zero fractional part then this is can be used to place adjacent fields on the same row.Example:
..would have their fields placed like:
name -> 0.0 description 1.0 minValue -> 2.0 maxValue -> 2.1
name: [ ] description: [ ] minimum: [ ] maximum: [ ]
- Returns:
- float
-
valueFrom
T valueFrom(java.lang.String propertyString) throws java.lang.IllegalArgumentException
Returns the value represented by this string.- Parameters:
propertyString
- The string to parse- Returns:
- The value represented by the string
- Throws:
java.lang.IllegalArgumentException
- if the given string cannot be parsed
-
asDelimitedString
java.lang.String asDelimitedString(T value)
Formats the object onto a string suitable for storage within the property map.- Parameters:
value
- Object- Returns:
- String
-
propertyErrorFor
java.lang.String propertyErrorFor(Rule rule)
A convenience method that returns an error string if the rule holds onto a property value that has a problem. Returns null otherwise.- Parameters:
rule
- Rule- Returns:
- String
-
preferredRowCount
int preferredRowCount()
If the datatype is a String then return the preferred number of rows to allocate in the text widget, returns a value of one for all other types. Useful for multi-line XPATH editors.- Returns:
- int
-
attributeValuesById
java.util.Map<PropertyDescriptorField,java.lang.String> attributeValuesById()
Returns a map representing all the property attributes of the receiver in string form.- Returns:
- map
-
isDefinedExternally
boolean isDefinedExternally()
True if this descriptor was defined in the ruleset xml. This precision is necessary for theRuleSetWriter
to write out the property correctly: if it was defined externally, then its definition must be written out, otherwise only its value.- Returns:
- True if the descriptor was defined in xml
-
-