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 java.lang.Object implements PropertySource
Base class forPropertySource.- Author:
- Brian Remedios
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<PropertyDescriptor<?>>propertyDescriptorsDeprecated.Will be made private finalprotected java.util.Map<PropertyDescriptor<?>,java.lang.Object>propertyValuesByDescriptorDeprecated.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 java.util.List<PropertyDescriptor<?>>copyPropertyDescriptors()Deprecated.Just usegetPropertyDescriptors()protected java.util.Map<PropertyDescriptor<?>,java.lang.Object>copyPropertyValues()Deprecated.voiddefinePropertyDescriptor(PropertyDescriptor<?> propertyDescriptor)Defines a new property.java.lang.StringdysfunctionReason()Returns a description of why the receiver may be dysfunctional.java.util.Map<PropertyDescriptor<?>,java.lang.Object>getOverriddenPropertiesByPropertyDescriptor()Returns a modifiable map of the property descriptors that don't use default values, to their overridden value.java.util.List<PropertyDescriptor<?>>getOverriddenPropertyDescriptors()Returns a modifiable list of the property descriptors that don't use default values.java.util.Map<PropertyDescriptor<?>,java.lang.Object>getPropertiesByPropertyDescriptor()Returns an unmodifiable map of descriptors to property values for the current receiver.<T> TgetProperty(PropertyDescriptor<T> propertyDescriptor)Get the typed value for the given property.PropertyDescriptor<?>getPropertyDescriptor(java.lang.String name)Get the PropertyDescriptor for the given property name.java.util.List<PropertyDescriptor<?>>getPropertyDescriptors()Get the descriptors of all defined properties.protected abstract java.lang.StringgetPropertySourceType()booleanhasDescriptor(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).java.util.Set<PropertyDescriptor<?>>ignoredProperties()Deprecated.booleanisPropertyOverridden(PropertyDescriptor<?> propertyDescriptor)Returns true if the given property has been set to a value somewhere in the XML.<V> voidsetProperty(MultiValuePropertyDescriptor<V> propertyDescriptor, V... values)Deprecated.<T> voidsetProperty(PropertyDescriptor<T> propertyDescriptor, T value)Set the property value specified.voiduseDefaultValueFor(PropertyDescriptor<?> desc)Deprecated.booleanusesDefaultValues()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 java.util.List<PropertyDescriptor<?>> propertyDescriptors
Deprecated.Will be made private finalThe list of known properties that can be configured.
-
propertyValuesByDescriptor
@Deprecated protected java.util.Map<PropertyDescriptor<?>,java.lang.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 java.util.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 java.util.Map<PropertyDescriptor<?>,java.lang.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 java.util.Set<PropertyDescriptor<?>> ignoredProperties()
Deprecated.Description copied from interface:PropertySourceReturn 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:
ignoredPropertiesin interfacePropertySource- Returns:
- the properties that are ignored
-
definePropertyDescriptor
public void definePropertyDescriptor(PropertyDescriptor<?> propertyDescriptor)
Description copied from interface:PropertySourceDefines a new property. Properties must be defined before they can be set a value.- Specified by:
definePropertyDescriptorin interfacePropertySource- Parameters:
propertyDescriptor- The property descriptor.
-
getPropertySourceType
protected abstract java.lang.String getPropertySourceType()
-
getPropertyDescriptor
public PropertyDescriptor<?> getPropertyDescriptor(java.lang.String name)
Description copied from interface:PropertySourceGet the PropertyDescriptor for the given property name.- Specified by:
getPropertyDescriptorin interfacePropertySource- Parameters:
name- The name of the property.- Returns:
- The PropertyDescriptor for the named property,
nullif there is no such property defined.
-
hasDescriptor
public boolean hasDescriptor(PropertyDescriptor<?> descriptor)
Description copied from interface:PropertySourceReturns 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:
hasDescriptorin interfacePropertySource- Parameters:
descriptor- The descriptor to look for- Returns:
trueif the descriptor is defined,falseotherwise.
-
getOverriddenPropertyDescriptors
public final java.util.List<PropertyDescriptor<?>> getOverriddenPropertyDescriptors()
Description copied from interface:PropertySourceReturns a modifiable list of the property descriptors that don't use default values.- Specified by:
getOverriddenPropertyDescriptorsin interfacePropertySource- Returns:
- The descriptors that don't use default values
-
getPropertyDescriptors
public java.util.List<PropertyDescriptor<?>> getPropertyDescriptors()
Description copied from interface:PropertySourceGet the descriptors of all defined properties. The properties are returned sorted by UI order.- Specified by:
getPropertyDescriptorsin interfacePropertySource- Returns:
- The PropertyDescriptors in UI order.
-
getProperty
public <T> T getProperty(PropertyDescriptor<T> propertyDescriptor)
Description copied from interface:PropertySourceGet the typed value for the given property. Multi valued properties return immutable lists.- Specified by:
getPropertyin 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:PropertySourceReturns true if the given property has been set to a value somewhere in the XML.- Specified by:
isPropertyOverriddenin 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:PropertySourceSet the property value specified. This is also referred to as "overriding" the (default) value of a property.- Specified by:
setPropertyin 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:PropertySourceSets 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:
setPropertyin interfacePropertySource- Type Parameters:
V- The type of the values- Parameters:
propertyDescriptor- The property descriptor for which to add a valuevalues- Values
-
getOverriddenPropertiesByPropertyDescriptor
public final java.util.Map<PropertyDescriptor<?>,java.lang.Object> getOverriddenPropertiesByPropertyDescriptor()
Description copied from interface:PropertySourceReturns 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:
getOverriddenPropertiesByPropertyDescriptorin interfacePropertySource- Returns:
- The descriptors that don't use default values
-
getPropertiesByPropertyDescriptor
public java.util.Map<PropertyDescriptor<?>,java.lang.Object> getPropertiesByPropertyDescriptor()
Description copied from interface:PropertySourceReturns 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:
getPropertiesByPropertyDescriptorin interfacePropertySource- Returns:
- An unmodifiable map of descriptors to property values
-
usesDefaultValues
@Deprecated public boolean usesDefaultValues()
Deprecated.Description copied from interface:PropertySourceReturns whether this Rule uses default values for properties.- Specified by:
usesDefaultValuesin interfacePropertySource- Returns:
- boolean
trueif the properties all have default values,falseotherwise.
-
useDefaultValueFor
@Deprecated public void useDefaultValueFor(PropertyDescriptor<?> desc)
Deprecated.Description copied from interface:PropertySourceClears out any user-specified value for the property allowing it to use the default value in the descriptor.- Specified by:
useDefaultValueForin interfacePropertySource- Parameters:
desc- the property to clear out
-
dysfunctionReason
public java.lang.String dysfunctionReason()
Description copied from interface:PropertySourceReturns 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:
dysfunctionReasonin interfacePropertySource- Returns:
- String
-
-