Package net.sourceforge.pmd.properties
Class AbstractPropertySource
- java.lang.Object
-
- net.sourceforge.pmd.properties.AbstractPropertySource
-
- All Implemented Interfaces:
PropertySource
- Direct Known Subclasses:
AbstractRenderer
,AbstractRule
public abstract class AbstractPropertySource extends Object implements PropertySource
Base class forPropertySource
.- Author:
- Brian Remedios
-
-
Field Summary
Fields Modifier and Type Field Description protected List<PropertyDescriptor<?>>
propertyDescriptors
Deprecated.Will be made private finalprotected Map<PropertyDescriptor<?>,Object>
propertyValuesByDescriptor
Deprecated.Will be made private final
-
Constructor Summary
Constructors Constructor Description AbstractPropertySource()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected List<PropertyDescriptor<?>>
copyPropertyDescriptors()
Deprecated.Just usegetPropertyDescriptors()
protected Map<PropertyDescriptor<?>,Object>
copyPropertyValues()
Deprecated.void
definePropertyDescriptor(PropertyDescriptor<?> propertyDescriptor)
Defines a new property.String
dysfunctionReason()
Returns a description of why the receiver may be dysfunctional.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.protected abstract String
getPropertySourceType()
boolean
hasDescriptor(PropertyDescriptor<?> descriptor)
Returns whether the specified property is defined on this property source, in which case it can be set or retrieved withPropertySource.getProperty(PropertyDescriptor)
andPropertySource.setProperty(PropertyDescriptor, Object)
.Set<PropertyDescriptor<?>>
ignoredProperties()
Deprecated.boolean
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.<T> void
setProperty(PropertyDescriptor<T> propertyDescriptor, T value)
Set the property value specified.void
useDefaultValueFor(PropertyDescriptor<?> desc)
Deprecated.boolean
usesDefaultValues()
Deprecated.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sourceforge.pmd.properties.PropertySource
getName
-
-
-
-
Field Detail
-
propertyDescriptors
@Deprecated protected List<PropertyDescriptor<?>> propertyDescriptors
Deprecated.Will be made private finalThe list of known properties that can be configured.
-
propertyValuesByDescriptor
@Deprecated protected Map<PropertyDescriptor<?>,Object> propertyValuesByDescriptor
Deprecated.Will be made private finalThe values for each property that were overridden here. Default property values are not contained in this map. In other words, if this map doesn't contain a descriptor which is inpropertyDescriptors
, then it's assumed to have a default value.
-
-
Method Detail
-
copyPropertyDescriptors
@Deprecated protected List<PropertyDescriptor<?>> copyPropertyDescriptors()
Deprecated.Just usegetPropertyDescriptors()
Creates a copied list of the property descriptors and returns it.- Returns:
- a copy of the property descriptors.
-
copyPropertyValues
@Deprecated protected Map<PropertyDescriptor<?>,Object> copyPropertyValues()
Deprecated.Creates a copied map of the values of the properties and returns it.- Returns:
- a copy of the values
-
ignoredProperties
@Deprecated public Set<PropertyDescriptor<?>> ignoredProperties()
Deprecated.Description copied from interface:PropertySource
Return 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.- Specified by:
ignoredProperties
in interfacePropertySource
- Returns:
- the properties that are ignored
-
definePropertyDescriptor
public void definePropertyDescriptor(PropertyDescriptor<?> propertyDescriptor)
Description copied from interface:PropertySource
Defines a new property. Properties must be defined before they can be set a value.- Specified by:
definePropertyDescriptor
in interfacePropertySource
- Parameters:
propertyDescriptor
- The property descriptor.
-
getPropertySourceType
protected abstract String getPropertySourceType()
-
getPropertyDescriptor
public PropertyDescriptor<?> getPropertyDescriptor(String name)
Description copied from interface:PropertySource
Get the PropertyDescriptor for the given property name.- Specified by:
getPropertyDescriptor
in interfacePropertySource
- Parameters:
name
- The name of the property.- Returns:
- The PropertyDescriptor for the named property,
null
if there is no such property defined.
-
hasDescriptor
public boolean hasDescriptor(PropertyDescriptor<?> descriptor)
Description copied from interface:PropertySource
Returns whether the specified property is defined on this property source, in which case it can be set or retrieved withPropertySource.getProperty(PropertyDescriptor)
andPropertySource.setProperty(PropertyDescriptor, Object)
.- Specified by:
hasDescriptor
in interfacePropertySource
- Parameters:
descriptor
- The descriptor to look for- Returns:
true
if the descriptor is defined,false
otherwise.
-
getOverriddenPropertyDescriptors
public final List<PropertyDescriptor<?>> getOverriddenPropertyDescriptors()
Description copied from interface:PropertySource
Returns a modifiable list of the property descriptors that don't use default values.- Specified by:
getOverriddenPropertyDescriptors
in interfacePropertySource
- Returns:
- The descriptors that don't use default values
-
getPropertyDescriptors
public List<PropertyDescriptor<?>> getPropertyDescriptors()
Description copied from interface:PropertySource
Get the descriptors of all defined properties. The properties are returned sorted by UI order.- Specified by:
getPropertyDescriptors
in interfacePropertySource
- Returns:
- The PropertyDescriptors in UI order.
-
getProperty
public <T> T getProperty(PropertyDescriptor<T> propertyDescriptor)
Description copied from interface:PropertySource
Get the typed value for the given property. Multi valued properties return immutable lists.- Specified by:
getProperty
in interfacePropertySource
- Type Parameters:
T
- The underlying type of the property descriptor.- Parameters:
propertyDescriptor
- The property descriptor.- Returns:
- The property value.
-
isPropertyOverridden
public boolean isPropertyOverridden(PropertyDescriptor<?> propertyDescriptor)
Description copied from interface:PropertySource
Returns true if the given property has been set to a value somewhere in the XML.- Specified by:
isPropertyOverridden
in interfacePropertySource
- Parameters:
propertyDescriptor
- The descriptor- Returns:
- True if the property has been set
-
setProperty
public <T> void setProperty(PropertyDescriptor<T> propertyDescriptor, T value)
Description copied from interface:PropertySource
Set the property value specified. This is also referred to as "overriding" the (default) value of a property.- Specified by:
setProperty
in interfacePropertySource
- Type Parameters:
T
- The underlying type of the property descriptor.- Parameters:
propertyDescriptor
- The property descriptor.value
- The value to set.
-
setProperty
@Deprecated public <V> void setProperty(MultiValuePropertyDescriptor<V> propertyDescriptor, V... values)
Deprecated.Description copied from interface:PropertySource
Sets 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.- Specified by:
setProperty
in interfacePropertySource
- Type Parameters:
V
- The type of the values- Parameters:
propertyDescriptor
- The property descriptor for which to add a valuevalues
- Values
-
getOverriddenPropertiesByPropertyDescriptor
public final Map<PropertyDescriptor<?>,Object> getOverriddenPropertiesByPropertyDescriptor()
Description copied from interface:PropertySource
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.- Specified by:
getOverriddenPropertiesByPropertyDescriptor
in interfacePropertySource
- Returns:
- The descriptors that don't use default values
-
getPropertiesByPropertyDescriptor
public Map<PropertyDescriptor<?>,Object> getPropertiesByPropertyDescriptor()
Description copied from interface:PropertySource
Returns an unmodifiable map of descriptors to property values for the current receiver. The returned map has an entry for every defined descriptor (PropertySource.getPropertyDescriptors()
), if they were not specified explicitly, then default values are used.- Specified by:
getPropertiesByPropertyDescriptor
in interfacePropertySource
- Returns:
- An unmodifiable map of descriptors to property values
-
usesDefaultValues
@Deprecated public boolean usesDefaultValues()
Deprecated.Description copied from interface:PropertySource
Returns whether this Rule uses default values for properties.- Specified by:
usesDefaultValues
in interfacePropertySource
- Returns:
- boolean
true
if the properties all have default values,false
otherwise.
-
useDefaultValueFor
@Deprecated public void useDefaultValueFor(PropertyDescriptor<?> desc)
Deprecated.Description copied from interface:PropertySource
Clears out any user-specified value for the property allowing it to use the default value in the descriptor.- Specified by:
useDefaultValueFor
in interfacePropertySource
- Parameters:
desc
- the property to clear out
-
dysfunctionReason
public String dysfunctionReason()
Description copied from interface:PropertySource
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.- Specified by:
dysfunctionReason
in interfacePropertySource
- Returns:
- String
-
-