Package net.sourceforge.pmd.properties
Class MethodProperty
- java.lang.Object
-
- net.sourceforge.pmd.properties.MethodProperty
-
- All Implemented Interfaces:
Comparable<PropertyDescriptor<?>>
,PackagedPropertyDescriptor<Method>
,PropertyDescriptor<Method>
,SingleValuePropertyDescriptor<Method>
@Deprecated public final class MethodProperty extends Object
Deprecated.Not useful, will be remove by 7.0.0Defines a property type that can specify a single method to use as part of a rule.Rule developers can limit the rules to those within designated packages per the 'legalPackages' argument in the constructor which can be an array of partial package names, i.e., ["java.lang", "com.mycompany" ].
- Version:
- Refactored June 2017 (6.0.0)
- Author:
- Brian Remedios
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MethodProperty.MethodPBuilder
Deprecated.
-
Field Summary
Fields Modifier and Type Field Description protected PackagedPropertyModule<T>
module
Deprecated.-
Fields inherited from interface net.sourceforge.pmd.properties.PackagedPropertyDescriptor
MULTI_VALUE_DELIMITER, PACKAGE_NAME_DELIMITER
-
-
Constructor Summary
Constructors Constructor Description MethodProperty(String theName, String theDescription, Method theDefault, String[] legalPackageNames, float theUIOrder)
Deprecated.Constructor for MethodProperty.MethodProperty(String theName, String theDescription, String defaultMethodStr, String[] legalPackageNames, float theUIOrder)
Deprecated.will be removed in 7.0.0
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
addAttributesTo(Map<PropertyDescriptorField,String> attributes)
Deprecated.Adds this property's attributes to the map.String
asDelimitedString(T value)
Deprecated.Formats the object onto a string suitable for storage within the property map.protected String
asString(Method value)
Deprecated.Returns a string representation of the value, even if it's null.Map<PropertyDescriptorField,String>
attributeValuesById()
Returns a map representing all the property attributes of the receiver in string form.int
compareTo(PropertyDescriptor<?> otherProperty)
Method
createFrom(String valueString)
Deprecated.Parse a string and returns an instance of a value.protected String
defaultAsString()
Deprecated.Returns a string representation of the default value.T
defaultValue()
Deprecated.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.boolean
equals(Object obj)
String
errorFor(T value)
Deprecated.Validation function that returns a diagnostic error message for a sample property value.int
hashCode()
boolean
isDefinedExternally()
True if this descriptor was defined in the ruleset xml.boolean
isMultiValue()
Deprecated.Returns whether the property is multi-valued, i.e.String[]
legalPackageNames()
Deprecated.Returns the legal package names.String
name()
The name of the property without spaces as it serves as the key into the property map.static MethodProperty.MethodPBuilder
named(String name)
Deprecated.protected String[]
packageNamesIn(Map<PropertyDescriptorField,String> params)
Deprecated.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.String
propertyErrorFor(Rule rule)
Deprecated.A convenience method that returns an error string if the rule holds onto a property value that has a problem.String
toString()
Class<Method>
type()
Deprecated.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.protected String
valueErrorFor(T value)
Deprecated.Checks the value for an error.T
valueFrom(String valueString)
Deprecated.Returns the value represented by this string.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sourceforge.pmd.properties.PropertyDescriptor
asDelimitedString, attributeValuesById, compareTo, defaultValue, description, errorFor, isDefinedExternally, isMultiValue, name, preferredRowCount, propertyErrorFor, uiOrder, valueFrom
-
-
-
-
Field Detail
-
module
protected final PackagedPropertyModule<T> module
Deprecated.
-
-
Constructor Detail
-
MethodProperty
public MethodProperty(String theName, String theDescription, Method theDefault, String[] legalPackageNames, float theUIOrder)
Deprecated.Constructor for MethodProperty.- Parameters:
theName
- Name of the propertytheDescription
- DescriptiontheDefault
- Default valuelegalPackageNames
- Legal packagestheUIOrder
- UI order
-
MethodProperty
public MethodProperty(String theName, String theDescription, String defaultMethodStr, String[] legalPackageNames, float theUIOrder)
Deprecated.will be removed in 7.0.0Constructor for MethodProperty using a string as a default value.- Parameters:
theName
- Name of the propertytheDescription
- DescriptiondefaultMethodStr
- Default value, that will be parsed into a Method objectlegalPackageNames
- Legal packagestheUIOrder
- UI order
-
-
Method Detail
-
asString
protected String asString(Method value)
Deprecated.Returns a string representation of the value, even if it's null.- Parameters:
value
- The value to describe- Returns:
- A string representation of the value
-
type
public Class<Method> type()
Deprecated.Description copied from interface:PropertyDescriptor
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
-
createFrom
public Method createFrom(String valueString) throws IllegalArgumentException
Deprecated.Parse a string and returns an instance of a value.- Parameters:
valueString
- String to parse- Returns:
- An instance of a value
- Throws:
IllegalArgumentException
-
named
public static MethodProperty.MethodPBuilder named(String name)
Deprecated.
-
addAttributesTo
protected void addAttributesTo(Map<PropertyDescriptorField,String> attributes)
Deprecated.Adds this property's attributes to the map. Subclasses can override this to add morePropertyDescriptorField
.- Parameters:
attributes
- The map to fill
-
valueErrorFor
protected String valueErrorFor(T value)
Deprecated.Checks the value for an error.- Parameters:
value
- Value to check- Returns:
- A diagnostic error message, or null if there's no problem
-
legalPackageNames
public String[] legalPackageNames()
Deprecated.Description copied from interface:PackagedPropertyDescriptor
Returns the legal package names.- Specified by:
legalPackageNames
in interfacePackagedPropertyDescriptor<T>
- Returns:
- The legal package names
-
packageNamesIn
protected String[] packageNamesIn(Map<PropertyDescriptorField,String> params)
Deprecated.
-
defaultValue
public final T defaultValue()
Deprecated.Description copied from interface:PropertyDescriptor
Default value to use when the user hasn't specified one or when they wish to revert to a known-good state.- Specified by:
defaultValue
in interfacePropertyDescriptor<T>
- Returns:
- Object
-
isMultiValue
public final boolean isMultiValue()
Deprecated.Description copied from interface:PropertyDescriptor
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.
- Specified by:
isMultiValue
in interfacePropertyDescriptor<T>
- Returns:
- boolean
-
asDelimitedString
public String asDelimitedString(T value)
Deprecated.Description copied from interface:PropertyDescriptor
Formats the object onto a string suitable for storage within the property map.- Specified by:
asDelimitedString
in interfacePropertyDescriptor<T>
- Parameters:
value
- Object- Returns:
- String
-
propertyErrorFor
public String propertyErrorFor(Rule rule)
Deprecated.Description copied from interface:PropertyDescriptor
A convenience method that returns an error string if the rule holds onto a property value that has a problem. Returns null otherwise.- Specified by:
propertyErrorFor
in interfacePropertyDescriptor<T>
- Parameters:
rule
- Rule- Returns:
- String
-
errorFor
public String errorFor(T value)
Deprecated.Description copied from interface:PropertyDescriptor
Validation function that returns a diagnostic error message for a sample property value. Returns null if the value is acceptable.- Specified by:
errorFor
in interfacePropertyDescriptor<T>
- Parameters:
value
- The value to check.- Returns:
- A diagnostic message.
-
defaultAsString
protected final String defaultAsString()
Deprecated.Returns a string representation of the default value.- Returns:
- A string representation of the default value.
-
valueFrom
public final T valueFrom(String valueString) throws IllegalArgumentException
Deprecated.Description copied from interface:PropertyDescriptor
Returns the value represented by this string.- Specified by:
valueFrom
in interfacePropertyDescriptor<T>
- Parameters:
valueString
- The string to parse- Returns:
- The value represented by the string
- Throws:
IllegalArgumentException
- if the given string cannot be parsed
-
description
public String description()
Description copied from interface:PropertyDescriptor
Describes the property and the role it plays within the rule it is specified for. Could be used in a tooltip.- Specified by:
description
in interfacePropertyDescriptor<T>
- Returns:
- String
-
uiOrder
public float uiOrder()
Description copied from interface:PropertyDescriptor
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.- Specified by:
uiOrder
in interfacePropertyDescriptor<T>
- Returns:
- The relative order compared to other properties of the same rule
-
compareTo
public final int compareTo(PropertyDescriptor<?> otherProperty)
- Specified by:
compareTo
in interfaceComparable<T>
- Specified by:
compareTo
in interfacePropertyDescriptor<T>
-
preferredRowCount
public int preferredRowCount()
Description copied from interface:PropertyDescriptor
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.- Specified by:
preferredRowCount
in interfacePropertyDescriptor<T>
- Returns:
- int
-
name
public String name()
Description copied from interface:PropertyDescriptor
The name of the property without spaces as it serves as the key into the property map.- Specified by:
name
in interfacePropertyDescriptor<T>
- Returns:
- String
-
attributeValuesById
public final Map<PropertyDescriptorField,String> attributeValuesById()
Description copied from interface:PropertyDescriptor
Returns a map representing all the property attributes of the receiver in string form.- Specified by:
attributeValuesById
in interfacePropertyDescriptor<T>
- Returns:
- map
-
isDefinedExternally
public boolean isDefinedExternally()
Description copied from interface:PropertyDescriptor
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.- Specified by:
isDefinedExternally
in interfacePropertyDescriptor<T>
- Returns:
- True if the descriptor was defined in xml
-
-