org.thewonderlemming.c4plantuml.mojo.linting.rules.builtin

## Class AbstractRuleParametersFactory<P>

- java.lang.Object
- - org.thewonderlemming.c4plantuml.mojo.linting.rules.builtin.AbstractRuleParametersFactory<P>

- Direct Known Subclasses:
    AliasesShouldBeListedInDictionaryRuleParametersFactory, AliasesShouldBeUniqueRuleParametersFactory, AliasesShouldFollowStandardConventionRuleParametersFactory, NoDuplicateRelationshipsRuleParametersFactory, NoOrphanAliasInBoundariesRuleParametersFactory, NoOrphanAliasInLayoutsRuleParametersFactory, NoOrphanAliasInRelationshipsRuleParametersFactory

      public abstract class AbstractRuleParametersFactory<P>
      extends Object

  A base implementation of a factory pattern to build `RuleParameters` for any `AbstractLintingRule`.
  Author:
    thewonderlemming

    the type of POJO embedded within the `BuiltInRules` object to configure the current rule.

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractRuleParametersFactory(BuiltInRules mojoParameters)` Default constructor.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract boolean` | `getActivatedParameter(P pojoParameters)` Extracts and returns the value of the `isActivated` parameter from a POJO in the `BuiltInRules` POJO.
    `protected abstract P` | `getPojoFromBuiltInRules(BuiltInRules mojoParameters)` Retrieves the rule configuration POJO from the `BuiltInRules` POJO.
    `RuleParameters` | `getRuleParameters()` Returns the built `RuleParameters` instance.
    `protected abstract Set<String>` | `getRuleParametersKeys()` Returns the parameters names for the current `AbstractLintingRule`.
    `protected abstract Optional<String>` | `getValueForParameter(String key, P pojoParameters)` Extracts and returns the value of the given parameter `key` from a POJO in the `BuiltInRules` POJO.
    `boolean` | `isActivated()` Tells whether or not the current `AbstractLintingRule` is enabled or disabled.

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

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

- - ### Constructor Detail

    - #### AbstractRuleParametersFactory

          protected AbstractRuleParametersFactory(BuiltInRules mojoParameters)

      Default constructor.
      Parameters:
        `mojoParameters` - the PJO containing the configuration from the `pom.xml` file.

  - ### Method Detail

    - #### getRuleParameters

          public RuleParameters getRuleParameters()

      Returns the built `RuleParameters` instance.
      Returns:
        the built `RuleParameters`.

    - #### isActivated

          public boolean isActivated()

      Tells whether or not the current `AbstractLintingRule` is enabled or disabled.
      Returns:
        `true` is the rule is enabled, `false` else.

    - #### getActivatedParameter

          protected abstract boolean getActivatedParameter(P pojoParameters)

      Extracts and returns the value of the `isActivated` parameter from a POJO in the `BuiltInRules` POJO.
      Parameters:
        `pojoParameters` - the POJO that holds the `pom.xml` plugin configuration.
      Returns:
        the value of the `isActivated` parameter.

    - #### getPojoFromBuiltInRules

          protected abstract P getPojoFromBuiltInRules(BuiltInRules mojoParameters)

      Retrieves the rule configuration POJO from the `BuiltInRules` POJO.
      Parameters:
        `mojoParameters` - the POJO that hosts the rule configuration object.
      Returns:
        the rule configuration object.

    - #### getRuleParametersKeys

          protected abstract Set<String> getRuleParametersKeys()

      Returns the parameters names for the current `AbstractLintingRule`.
      Returns:
        the parameters names for the rule.

    - #### getValueForParameter

          protected abstract Optional<String> getValueForParameter(String key,
                                                                   P pojoParameters)

      Extracts and returns the value of the given parameter `key` from a POJO in the `BuiltInRules` POJO.
      Parameters:
        `key` - the name of the parameter to retrieves the value from.
        `pojoParameters` - the POJO that holds the `pom.xml` plugin configuration.
      Returns:
        the value of the `key` parameter.

Copyright © 2020. All rights reserved.