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 for PropertySource.
Author:
Brian Remedios
  • Constructor Details

    • AbstractPropertySource

      public AbstractPropertySource()
  • Method Details

    • 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 interface PropertySource
      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 interface PropertySource
      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 with PropertySource.getProperty(PropertyDescriptor) and PropertySource.setProperty(PropertyDescriptor, Object).
      Specified by:
      hasDescriptor in interface PropertySource
      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 interface PropertySource
      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 interface PropertySource
      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 interface PropertySource
      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 interface PropertySource
      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 interface PropertySource
      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 interface PropertySource
      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 interface PropertySource
      Returns:
      An unmodifiable map of descriptors to property values
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object