net.sourceforge.pmd.lang.rule

## Class RuleReference

- java.lang.Object
- - net.sourceforge.pmd.lang.rule.AbstractDelegateRule
  - - net.sourceforge.pmd.lang.rule.RuleReference

All Implemented Interfaces:
  PropertySource, Rule

    public class RuleReference
    extends AbstractDelegateRule

This class represents a Rule which is a reference to Rule defined in another RuleSet. All details of the Rule are delegated to the underlying referenced Rule, but those operations which modify overridden aspects of the rule are explicitly tracked. Modification operations which set a value to the current underlying value do not override.

### Field Summary

### Fields inherited from interface net.sourceforge.pmd.Rule

`VIOLATION_SUPPRESS_REGEX_DESCRIPTOR, VIOLATION_SUPPRESS_XPATH_DESCRIPTOR`

### Constructor Summary

Constructors
Constructor and Description
`RuleReference()`
`RuleReference(Rule theRule, RuleSetReference theRuleSetReference)`

### Method Summary

Methods
`void` `addExample(String example)` Add a single example for this Rule.
`void` `definePropertyDescriptor(PropertyDescriptor<?> propertyDescriptor)` Define a new property via a PropertyDescriptor.
`String` `getOverriddenDescription()`
`List<String>` `getOverriddenExamples()`
`String` `getOverriddenExternalInfoUrl()`
`Language` `getOverriddenLanguage()`
`LanguageVersion` `getOverriddenMaximumLanguageVersion()`
`String` `getOverriddenMessage()`
`LanguageVersion` `getOverriddenMinimumLanguageVersion()`
`String` `getOverriddenName()`
`RulePriority` `getOverriddenPriority()`
`Map<PropertyDescriptor<?>,Object>` `getOverriddenPropertiesByPropertyDescriptor()`
`List<PropertyDescriptor<?>>` `getOverriddenPropertyDescriptors()`
`RuleSetReference` `getRuleSetReference()`
`boolean` `hasDescriptor(PropertyDescriptor<?> descriptor)` Returns whether this Rule has the specified PropertyDescriptor.
`boolean` `hasOverriddenProperty(PropertyDescriptor<?> descriptor)`
`boolean` `isDeprecated()` Gets whether this Rule is deprecated.
`Boolean` `isOverriddenDeprecated()`
`void` `setDeprecated(boolean deprecated)` Sets whether this Rule is deprecated.
`void` `setDescription(String description)` Set the description of this Rule.
`void` `setExternalInfoUrl(String externalInfoUrl)` Set a URL for external information about this Rule.
`void` `setLanguage(Language language)` Set the Language of this Rule.
`void` `setMaximumLanguageVersion(LanguageVersion maximumLanguageVersion)` Set the maximum LanguageVersion to which this Rule applies.
`void` `setMessage(String message)` Set the message to show when this Rule identifies a violation.
`void` `setMinimumLanguageVersion(LanguageVersion minimumLanguageVersion)` Set the minimum LanguageVersion to which this Rule applies.
`void` `setName(String name)` Set the name of this Rule.
`void` `setPriority(RulePriority priority)` Set the priority of this Rule.
`<T> void` `setProperty(PropertyDescriptor<T> propertyDescriptor, T value)` Set the property value specified (will be type-checked)
`void` `setRuleSetReference(RuleSetReference ruleSetReference)`
`void` `useDefaultValueFor(PropertyDescriptor<?> desc)` Clears out any user-specified value for the property allowing it to use the default value in the descriptor.
`boolean` `usesDefaultValues()` Returns whether this Rule uses default values for properties.

### Methods inherited from class net.sourceforge.pmd.lang.rule.AbstractDelegateRule

`addRuleChainVisit, addRuleChainVisit, apply, dysfunctionReason, end, getDescription, getExamples, getExternalInfoUrl, getLanguage, getMaximumLanguageVersion, getMessage, getMinimumLanguageVersion, getName, getParserOptions, getPriority, getPropertiesByPropertyDescriptor, getProperty, getPropertyDescriptor, getPropertyDescriptors, getRule, getRuleChainVisits, getRuleClass, getRuleSetName, getSince, ignoredProperties, setRule, setRuleClass, setRuleSetName, setSince, setUsesDFA, setUsesTypeResolution, start, usesDFA, usesRuleChain, usesTypeResolution`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### RuleReference

    public RuleReference()

#### RuleReference

    public RuleReference(Rule theRule,
                 RuleSetReference theRuleSetReference)

### Method Detail

#### getOverriddenLanguage

    public Language getOverriddenLanguage()

#### setLanguage

    public void setLanguage(Language language)

Description copied from interface: `Rule`
Set the Language of this Rule.

Specified by:
  `setLanguage` in interface `Rule`
Overrides:
  `setLanguage` in class `AbstractDelegateRule`

#### getOverriddenMinimumLanguageVersion

    public LanguageVersion getOverriddenMinimumLanguageVersion()

#### setMinimumLanguageVersion

    public void setMinimumLanguageVersion(LanguageVersion minimumLanguageVersion)

Description copied from interface: `Rule`
Set the minimum LanguageVersion to which this Rule applies.

Specified by:
  `setMinimumLanguageVersion` in interface `Rule`
Overrides:
  `setMinimumLanguageVersion` in class `AbstractDelegateRule`

#### getOverriddenMaximumLanguageVersion

    public LanguageVersion getOverriddenMaximumLanguageVersion()

#### setMaximumLanguageVersion

    public void setMaximumLanguageVersion(LanguageVersion maximumLanguageVersion)

Description copied from interface: `Rule`
Set the maximum LanguageVersion to which this Rule applies.

Specified by:
  `setMaximumLanguageVersion` in interface `Rule`
Overrides:
  `setMaximumLanguageVersion` in class `AbstractDelegateRule`

#### isOverriddenDeprecated

    public Boolean isOverriddenDeprecated()

#### isDeprecated

    public boolean isDeprecated()

Description copied from interface: `Rule`
Gets whether this Rule is deprecated. A deprecated Rule is one which:

- is scheduled for removal in a future version of PMD
- or, has been removed and replaced with a non-functioning place-holder and will be completely removed in a future version of PMD
- or, has been renamed/moved and the old name will be completely removed in a future version of PMD

Specified by:
  `isDeprecated` in interface `Rule`
Overrides:
  `isDeprecated` in class `AbstractDelegateRule`

#### setDeprecated

    public void setDeprecated(boolean deprecated)

Description copied from interface: `Rule`
Sets whether this Rule is deprecated.

Specified by:
  `setDeprecated` in interface `Rule`
Overrides:
  `setDeprecated` in class `AbstractDelegateRule`

#### getOverriddenName

    public String getOverriddenName()

#### setName

    public void setName(String name)

Description copied from interface: `Rule`
Set the name of this Rule.

Specified by:
  `setName` in interface `Rule`
Overrides:
  `setName` in class `AbstractDelegateRule`

#### getOverriddenMessage

    public String getOverriddenMessage()

#### setMessage

    public void setMessage(String message)

Description copied from interface: `Rule`
Set the message to show when this Rule identifies a violation.

Specified by:
  `setMessage` in interface `Rule`
Overrides:
  `setMessage` in class `AbstractDelegateRule`

#### getOverriddenDescription

    public String getOverriddenDescription()

#### setDescription

    public void setDescription(String description)

Description copied from interface: `Rule`
Set the description of this Rule.

Specified by:
  `setDescription` in interface `Rule`
Overrides:
  `setDescription` in class `AbstractDelegateRule`

#### getOverriddenExamples

    public List<String> getOverriddenExamples()

#### addExample

    public void addExample(String example)

Description copied from interface: `Rule`
Add a single example for this Rule.

Specified by:
  `addExample` in interface `Rule`
Overrides:
  `addExample` in class `AbstractDelegateRule`

#### getOverriddenExternalInfoUrl

    public String getOverriddenExternalInfoUrl()

#### setExternalInfoUrl

    public void setExternalInfoUrl(String externalInfoUrl)

Description copied from interface: `Rule`
Set a URL for external information about this Rule.

Specified by:
  `setExternalInfoUrl` in interface `Rule`
Overrides:
  `setExternalInfoUrl` in class `AbstractDelegateRule`

#### getOverriddenPriority

    public RulePriority getOverriddenPriority()

#### setPriority

    public void setPriority(RulePriority priority)

Description copied from interface: `Rule`
Set the priority of this Rule.

Specified by:
  `setPriority` in interface `Rule`
Overrides:
  `setPriority` in class `AbstractDelegateRule`

#### getOverriddenPropertyDescriptors

    public List<PropertyDescriptor<?>> getOverriddenPropertyDescriptors()

#### definePropertyDescriptor

    public void definePropertyDescriptor(PropertyDescriptor<?> propertyDescriptor)
                                  throws IllegalArgumentException

Description copied from interface: `PropertySource`
Define a new property via a PropertyDescriptor.

Specified by:
  `definePropertyDescriptor` in interface `PropertySource`
Overrides:
  `definePropertyDescriptor` in class `AbstractDelegateRule`
Parameters:
  `propertyDescriptor` - The property descriptor.
Throws:
  `IllegalArgumentException` - If there is already a property defined the same name.

#### getOverriddenPropertiesByPropertyDescriptor

    public Map<PropertyDescriptor<?>,Object> getOverriddenPropertiesByPropertyDescriptor()

#### setProperty

    public <T> void setProperty(PropertyDescriptor<T> propertyDescriptor,
                       T value)

Description copied from interface: `PropertySource`
Set the property value specified (will be type-checked)

Specified by:
  `setProperty` in interface `PropertySource`
Overrides:
  `setProperty` in class `AbstractDelegateRule`
Type Parameters:
  `T` - The underlying type of the property descriptor.
Parameters:
  `propertyDescriptor` - The property descriptor.
  `value` - The value to set.

#### getRuleSetReference

    public RuleSetReference getRuleSetReference()

#### setRuleSetReference

    public void setRuleSetReference(RuleSetReference ruleSetReference)

#### hasDescriptor

    public boolean hasDescriptor(PropertyDescriptor<?> descriptor)

Description copied from interface: `PropertySource`
Returns whether this Rule has the specified PropertyDescriptor.

Specified by:
  `hasDescriptor` in interface `PropertySource`
Overrides:
  `hasDescriptor` in class `AbstractDelegateRule`
Parameters:
  `descriptor` - The PropertyDescriptor for which to check.
Returns:
  boolean `true` if the descriptor is present, `false` otherwise.
See Also:
  `PropertySource.hasDescriptor(PropertyDescriptor)`

#### hasOverriddenProperty

    public boolean hasOverriddenProperty(PropertyDescriptor<?> descriptor)

#### usesDefaultValues

    public boolean usesDefaultValues()

Description copied from interface: `PropertySource`
Returns whether this Rule uses default values for properties.

Returns:
  boolean `true` if the properties all have default values, `false` otherwise.

#### useDefaultValueFor

    public void useDefaultValueFor(PropertyDescriptor<?> desc)

Description copied from interface: `PropertySource`
Clears out any user-specified value for the property allowing it to use the default value in the descriptor.