Package net.sourceforge.pmd.properties
Interface PropertySource
-
- All Known Subinterfaces:
CodeClimateRule
,DFAGraphRule
,Renderer
,Rule
,StatisticalRule
- All Known Implementing Classes:
AbstractAccumulatingRenderer
,AbstractDelegateRule
,AbstractIncrementingRenderer
,AbstractPropertySource
,AbstractRenderer
,AbstractRule
,CodeClimateRenderer
,CSVRenderer
,EmacsRenderer
,EmptyRenderer
,HTMLRenderer
,IDEAJRenderer
,MockRule
,RuleReference
,SummaryHTMLRenderer
,TextColorRenderer
,TextPadRenderer
,TextRenderer
,VBHTMLRenderer
,XMLRenderer
,XPathRule
,XSLTRenderer
,YAHTMLRenderer
public interface PropertySource
Entity that manages a list of properties. Properties are described by property descriptors. A property source maintains a mapping of property descriptors to property values. The value of a property can be set bysetProperty(PropertyDescriptor, Object)
. If the property wasn't set with this method, then the property is assumed to take a default value, which is specified by the property descriptor.Bad configuration of the properties may be reported by
dysfunctionReason()
.Notable instances of this interface are rules and renderers.
- Author:
- Brian Remedios
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description void
definePropertyDescriptor(PropertyDescriptor<?> propertyDescriptor)
Defines a new property.String
dysfunctionReason()
Returns a description of why the receiver may be dysfunctional.String
getName()
Gets the name of this property source.Map<PropertyDescriptor<?>,Object>
getOverriddenPropertiesByPropertyDescriptor()
Returns a modifiable map of the property descriptors that don't use default values, to their overridden value.List<PropertyDescriptor<?>>
getOverriddenPropertyDescriptors()
Returns a modifiable list of the property descriptors that don't use default values.Map<PropertyDescriptor<?>,Object>
getPropertiesByPropertyDescriptor()
Returns an unmodifiable map of descriptors to property values for the current receiver.<T> T
getProperty(PropertyDescriptor<T> propertyDescriptor)
Get the typed value for the given property.PropertyDescriptor<?>
getPropertyDescriptor(String name)
Get the PropertyDescriptor for the given property name.List<PropertyDescriptor<?>>
getPropertyDescriptors()
Get the descriptors of all defined properties.boolean
hasDescriptor(PropertyDescriptor<?> descriptor)
Returns whether the specified property is defined on this property source, in which case it can be set or retrieved withgetProperty(PropertyDescriptor)
andsetProperty(PropertyDescriptor, Object)
.Set<PropertyDescriptor<?>>
ignoredProperties()
Deprecated.Has no real utility, will be removed by 7.0.0boolean
isPropertyOverridden(PropertyDescriptor<?> propertyDescriptor)
Returns true if the given property has been set to a value somewhere in the XML.<V> void
setProperty(MultiValuePropertyDescriptor<V> propertyDescriptor, V... values)
Deprecated.MultiValuePropertyDescriptor
is deprecated<T> void
setProperty(PropertyDescriptor<T> propertyDescriptor, T value)
Set the property value specified.void
useDefaultValueFor(PropertyDescriptor<?> desc)
Deprecated.Has no real utility, and the name is confusing, will be removed by 7.0.0boolean
usesDefaultValues()
Deprecated.Has no real utility, will be removed by 7.0.0
-
-
-
Method Detail
-
definePropertyDescriptor
void definePropertyDescriptor(PropertyDescriptor<?> propertyDescriptor) throws IllegalArgumentException
Defines a new property. Properties must be defined before they can be set a value.- Parameters:
propertyDescriptor
- The property descriptor.- Throws:
IllegalArgumentException
- If there is already a property defined the same name.
-
getName
String getName()
Gets the name of this property source. This is e.g. the name of the rule or renderer.- Returns:
- The name
-
getPropertyDescriptor
PropertyDescriptor<?> getPropertyDescriptor(String name)
Get the PropertyDescriptor for the given property name.- Parameters:
name
- The name of the property.- Returns:
- The PropertyDescriptor for the named property,
null
if there is no such property defined.
-
getPropertyDescriptors
List<PropertyDescriptor<?>> getPropertyDescriptors()
Get the descriptors of all defined properties. The properties are returned sorted by UI order.- Returns:
- The PropertyDescriptors in UI order.
-
getOverriddenPropertyDescriptors
List<PropertyDescriptor<?>> getOverriddenPropertyDescriptors()
Returns a modifiable list of the property descriptors that don't use default values.- Returns:
- The descriptors that don't use default values
-
getProperty
<T> T getProperty(PropertyDescriptor<T> propertyDescriptor)
Get the typed value for the given property. Multi valued properties return immutable lists.- Type Parameters:
T
- The underlying type of the property descriptor.- Parameters:
propertyDescriptor
- The property descriptor.- Returns:
- The property value.
-
isPropertyOverridden
boolean isPropertyOverridden(PropertyDescriptor<?> propertyDescriptor)
Returns true if the given property has been set to a value somewhere in the XML.- Parameters:
propertyDescriptor
- The descriptor- Returns:
- True if the property has been set
-
setProperty
<T> void setProperty(PropertyDescriptor<T> propertyDescriptor, T value)
Set the property value specified. This is also referred to as "overriding" the (default) value of a property.- Type Parameters:
T
- The underlying type of the property descriptor.- Parameters:
propertyDescriptor
- The property descriptor.value
- The value to set.
-
setProperty
@Deprecated <V> void setProperty(MultiValuePropertyDescriptor<V> propertyDescriptor, V... values)
Deprecated.MultiValuePropertyDescriptor
is deprecatedSets the value of a multi value property descriptor with a variable number of arguments. This is also referred to as "overriding" the (default) value of a property.- Type Parameters:
V
- The type of the values- Parameters:
propertyDescriptor
- The property descriptor for which to add a valuevalues
- Values
-
getPropertiesByPropertyDescriptor
Map<PropertyDescriptor<?>,Object> getPropertiesByPropertyDescriptor()
Returns an unmodifiable map of descriptors to property values for the current receiver. The returned map has an entry for every defined descriptor (getPropertyDescriptors()
), if they were not specified explicitly, then default values are used.- Returns:
- An unmodifiable map of descriptors to property values
-
getOverriddenPropertiesByPropertyDescriptor
Map<PropertyDescriptor<?>,Object> getOverriddenPropertiesByPropertyDescriptor()
Returns a modifiable map of the property descriptors that don't use default values, to their overridden value. Modifications on the returned map don't affect this property source.- Returns:
- The descriptors that don't use default values
-
hasDescriptor
boolean hasDescriptor(PropertyDescriptor<?> descriptor)
Returns whether the specified property is defined on this property source, in which case it can be set or retrieved withgetProperty(PropertyDescriptor)
andsetProperty(PropertyDescriptor, Object)
.- Parameters:
descriptor
- The descriptor to look for- Returns:
true
if the descriptor is defined,false
otherwise.
-
usesDefaultValues
@Deprecated boolean usesDefaultValues()
Deprecated.Has no real utility, will be removed by 7.0.0Returns whether this Rule uses default values for properties.- Returns:
- boolean
true
if the properties all have default values,false
otherwise.
-
useDefaultValueFor
@Deprecated void useDefaultValueFor(PropertyDescriptor<?> desc)
Deprecated.Has no real utility, and the name is confusing, will be removed by 7.0.0Clears out any user-specified value for the property allowing it to use the default value in the descriptor.- Parameters:
desc
- the property to clear out
-
ignoredProperties
@Deprecated Set<PropertyDescriptor<?>> ignoredProperties()
Deprecated.Has no real utility, will be removed by 7.0.0Return the properties that are effectively ignored due to the configuration of the rule and values held by other properties. This can be used to disable corresponding widgets in a UI.- Returns:
- the properties that are ignored
-
dysfunctionReason
String dysfunctionReason()
Returns a description of why the receiver may be dysfunctional. Usually due to missing property values or some kind of conflict between values. Returns null if the receiver is ok.- Returns:
- String
-
-