Package net.sourceforge.pmd.properties
Class AbstractPropertySource
- java.lang.Object
-
- net.sourceforge.pmd.properties.AbstractPropertySource
-
- All Implemented Interfaces:
PropertySource
- Direct Known Subclasses:
AbstractRenderer
,AbstractRule
,LanguagePropertyBundle
public abstract class AbstractPropertySource extends Object implements PropertySource
Base class forPropertySource
.- Author:
- Brian Remedios
-
-
Constructor Summary
Constructors Constructor Description AbstractPropertySource()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
definePropertyDescriptor(PropertyDescriptor<?> propertyDescriptor)
Defines a new property.boolean
equals(Object o)
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)
.int
hashCode()
boolean
isPropertyOverridden(PropertyDescriptor<?> propertyDescriptor)
Returns true if the given property has been set to a value somewhere in the XML.<T> void
setProperty(PropertyDescriptor<T> propertyDescriptor, T value)
Set the property value specified.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sourceforge.pmd.properties.PropertySource
dysfunctionReason, getName
-
-
-
-
Method Detail
-
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.
-
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
-
-