Class 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.
    • Constructor Detail

      • RuleReference

        @Deprecated
        public RuleReference()
        Deprecated.
        to be removed with PMD 7.0.0. when creating a rule reference, always provide the rule and the ruleset, see the constructor RuleReference(Rule, RuleSetReference)
      • RuleReference

        public RuleReference​(Rule theRule,
                             RuleSetReference theRuleSetReference)
        Create a new reference to the given rule.
        Parameters:
        theRule - the referenced rule
        theRuleSetReference - the rule set, where the rule is defined
    • Method Detail

      • getOverriddenLanguage

        @Deprecated
        public Language getOverriddenLanguage()
        Deprecated.
        overriding the language of a rule is not supported.
      • setLanguage

        @Deprecated
        public void setLanguage​(Language language)
        Deprecated.
        overriding the language of a rule is not supported.
        Description copied from interface: Rule
        Set the Language of this Rule.
        Specified by:
        setLanguage in interface Rule
        Overrides:
        setLanguage in class AbstractDelegateRule
        Parameters:
        language - the language
      • getOverriddenMinimumLanguageVersion

        public LanguageVersion getOverriddenMinimumLanguageVersion()
      • getOverriddenMaximumLanguageVersion

        public LanguageVersion getOverriddenMaximumLanguageVersion()
      • 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
        Returns:
        true if this rule is deprecated
      • 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
        Parameters:
        deprecated - whether this rule is deprecated
      • getOverriddenName

        public String getOverriddenName()
      • getOriginalName

        public String getOriginalName()
      • 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
        Parameters:
        message - the message to show for a violation.
      • getOverriddenDescription

        public String getOverriddenDescription()
      • 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
        Parameters:
        example - a single example to add
      • 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
        Parameters:
        externalInfoUrl - the URL for external information about this rule.
      • getOverriddenPriority

        public RulePriority getOverriddenPriority()
      • getOverriddenPropertyDescriptors

        public List<PropertyDescriptor<?>> getOverriddenPropertyDescriptors()
        Description copied from interface: PropertySource
        Returns a modifiable list of the property descriptors that don't use default values.
        Returns:
        The descriptors that don't use default values
      • getOverriddenPropertiesByPropertyDescriptor

        public 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.
        Returns:
        The descriptors that don't use default values
      • 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
        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.
      • setRuleSetReference

        @Deprecated
        public void setRuleSetReference​(RuleSetReference ruleSetReference)
        Deprecated.
        There's no use in setting the ruleset reference after construction
      • usesDefaultValues

        @Deprecated
        public boolean usesDefaultValues()
        Deprecated.
        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

        @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.
        Parameters:
        desc - the property to clear out
      • deepCopy

        public Rule deepCopy()
        Description copied from interface: Rule
        Creates a new copy of this rule.
        Returns:
        A new exact copy of this rule
      • hasOverriddenAttributes

        public boolean hasOverriddenAttributes()
        Checks whether this rule reference explicitly overrides any of the possible attributes of the referenced rule.
        Returns:
        true if there is at least one attribute overridden. false if the referenced rule is referenced without any change.