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:
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 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.Upcoming API changes to the properties framework
see pmd/pmd#1432- Version:
- Refactored June 2017 (6.0.0)
- Author:
- Brian Remedios, Clément Fournier
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description String
asDelimitedString(T value)
Deprecated.PMD 7.0.0 will use a more powerful scheme to represent values than simple strings, this method won't be general enoughMap<PropertyDescriptorField,String>
attributeValuesById()
Deprecated.Will be removed with 7.0.0int
compareTo(PropertyDescriptor<?> o)
Deprecated.Comparing property descriptors is not useful within PMDT
defaultValue()
Default value to use when the user hasn't specified one or when they wish to revert to a known-good state.String
description()
Describes the property and the role it plays within the rule it is specified for.String
errorFor(T value)
Deprecated.PMD 7.0.0 will change the return type toOptional<String>
boolean
isDefinedExternally()
Deprecated.May be removed with 7.0.0boolean
isMultiValue()
Deprecated.The hard divide between multi- and single-value properties will be removed with 7.0.0String
name()
The name of the property without spaces as it serves as the key into the property map.int
preferredRowCount()
Deprecated.Was never implemented, and is none of the descriptor's concern.String
propertyErrorFor(Rule rule)
Deprecated.Used nowhere, and fails if the rule doesn't define the property descriptor A better solution will be added on property sourceClass<?>
type()
Deprecated.This method is mainly used for documentation, but will not prove general enough to support PMD 7.0.0's improved property types.float
uiOrder()
Deprecated.This method confuses the presentation layer and the business logic.T
valueFrom(String propertyString)
Deprecated.PMD 7.0.0 will use a more powerful scheme to represent values than simple strings, this method won't be general enough
-
-
-
Method Detail
-
name
String name()
The name of the property without spaces as it serves as the key into the property map.- Returns:
- String
-
description
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
-
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
@Deprecated String errorFor(T value)
Deprecated.PMD 7.0.0 will change the return type toOptional<String>
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.
-
type
@Deprecated Class<?> type()
Deprecated.This method is mainly used for documentation, but will not prove general enough to support PMD 7.0.0's improved property types.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
@Deprecated boolean isMultiValue()
Deprecated.The hard divide between multi- and single-value properties will be removed with 7.0.0Returns 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
-
uiOrder
@Deprecated float uiOrder()
Deprecated.This method confuses the presentation layer and the business logic. The order of the property in a UI is irrelevant to the functioning of the property in PMD. With PMD 7.0.0, this method will be removed. UI and documentation tools will decide on their own convention.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.- Returns:
- The relative order compared to other properties of the same rule
-
compareTo
@Deprecated int compareTo(PropertyDescriptor<?> o)
Deprecated.Comparing property descriptors is not useful within PMD- Specified by:
compareTo
in interfaceComparable<T>
-
valueFrom
@Deprecated T valueFrom(String propertyString) throws IllegalArgumentException
Deprecated.PMD 7.0.0 will use a more powerful scheme to represent values than simple strings, this method won't be general enoughReturns the value represented by this string.- Parameters:
propertyString
- The string to parse- Returns:
- The value represented by the string
- Throws:
IllegalArgumentException
- if the given string cannot be parsed
-
asDelimitedString
@Deprecated String asDelimitedString(T value)
Deprecated.PMD 7.0.0 will use a more powerful scheme to represent values than simple strings, this method won't be general enoughFormats the object onto a string suitable for storage within the property map.- Parameters:
value
- Object- Returns:
- String
-
propertyErrorFor
@Deprecated String propertyErrorFor(Rule rule)
Deprecated.Used nowhere, and fails if the rule doesn't define the property descriptor A better solution will be added on property sourceA 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
@Deprecated int preferredRowCount()
Deprecated.Was never implemented, and is none of the descriptor's concern. Will be removed with 7.0.0If 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
@Deprecated Map<PropertyDescriptorField,String> attributeValuesById()
Deprecated.Will be removed with 7.0.0Returns a map representing all the property attributes of the receiver in string form.- Returns:
- map
-
isDefinedExternally
@Deprecated @InternalApi boolean isDefinedExternally()
Deprecated.May be removed with 7.0.0True 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
-
-