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.
      • RuleReference

        public RuleReference​(Rule theRule,
                             RuleSetReference theRuleSetReference)
        Parameters:
        theRule - the referenced rule
        theRuleSetReference - the rule set, where the rule is defined
    • Method Detail

      • getOverriddenLanguage

        public Language getOverriddenLanguage()
      • getOverriddenMinimumLanguageVersion

        public LanguageVersion getOverriddenMinimumLanguageVersion()
      • getOverriddenMaximumLanguageVersion

        public LanguageVersion getOverriddenMaximumLanguageVersion()
      • isOverriddenDeprecated

        public java.lang.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 java.lang.String getOverriddenName()
      • getOriginalName

        public java.lang.String getOriginalName()
      • setName

        public void setName​(java.lang.String name)
        Description copied from interface: Rule
        Set the name of this Rule.
        Specified by:
        setName in interface Rule
        Overrides:
        setName in class AbstractDelegateRule
        Parameters:
        name - the name
      • getName

        public java.lang.String getName()
        Description copied from interface: Rule
        Get the name of this Rule.
        Specified by:
        getName in interface Rule
        Overrides:
        getName in class AbstractDelegateRule
        Returns:
        the name
      • getOverriddenMessage

        public java.lang.String getOverriddenMessage()
      • setMessage

        public void setMessage​(java.lang.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 java.lang.String getOverriddenDescription()
      • setDescription

        public void setDescription​(java.lang.String description)
        Description copied from interface: Rule
        Set the description of this Rule.
        Specified by:
        setDescription in interface Rule
        Overrides:
        setDescription in class AbstractDelegateRule
        Parameters:
        description - the description
      • getOverriddenExamples

        public java.util.List<java.lang.String> getOverriddenExamples()
      • addExample

        public void addExample​(java.lang.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 java.lang.String getOverriddenExternalInfoUrl()
      • setExternalInfoUrl

        public void setExternalInfoUrl​(java.lang.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 java.util.List<PropertyDescriptor<?>> getOverriddenPropertyDescriptors()
      • getOverriddenPropertiesByPropertyDescriptor

        public java.util.Map<PropertyDescriptor<?>,​java.lang.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.
      • setRuleSetReference

        public void setRuleSetReference​(RuleSetReference ruleSetReference)
      • 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.
        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