org.thewonderlemming.c4plantuml.mojo

## Class AbstractParentMojo

- java.lang.Object
- - org.apache.maven.plugin.AbstractMojo
  - - org.thewonderlemming.c4plantuml.mojo.AbstractParentMojo

- All Implemented Interfaces:
    org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
  Direct Known Subclasses:
    LintingMojo, ReportingMojo, SyntaxCheckingMojo, WatermarkingMojo

      public abstract class AbstractParentMojo
      extends org.apache.maven.plugin.AbstractMojo

  A base implementation of a MOJO that handles shared parameters such as `Charset`, `MavenProject`, and so on.
  Author:
    thewonderlemming

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `DEFAULT_SOURCE_FILE_EXTENSION` Default value for the C4 PlantUML files extension.

    - ### Fields inherited from interface org.apache.maven.plugin.Mojo

      `ROLE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractParentMojo()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract void` | `doExecute()` An abstract method to hold the children classes execution logic.
    `void` | `execute()` The default implementation of `Mojo.execute()`, that sets and validates shared parameters, then calls the abstract method `doExecute()`, that needs to be implemented by children classes.
    `protected Charset` | `getCurrentCharset()` Returns the current `Charset` value.
    `protected String` | `getOutputDirectory()` Returns the project output directory path.
    `protected org.apache.maven.project.MavenProject` | `getProject()` Returns the current `MavenProject` instance.
    `protected String` | `getSourceFileExtension()` Returns the current sources filename extension.
    `protected void` | `processOutputDirectoryFiles(Consumer<Path> pumlFileProcessor)` An utility method that enables the processing of the C4 PlantUML sources in the output directory.
    `protected void` | `validateSourceFileExtension()` Validates that the current `sourceFileExtension` property has a correct value, or sets it to the default value and displays an error message.

    - ### Methods inherited from class org.apache.maven.plugin.AbstractMojo

      `getLog, getPluginContext, setLog, setPluginContext`

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

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

- - ### Field Detail

    - #### DEFAULT_SOURCE_FILE_EXTENSION

          public static final String DEFAULT_SOURCE_FILE_EXTENSION

      Default value for the C4 PlantUML files extension.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### AbstractParentMojo

          public AbstractParentMojo()

  - ### Method Detail

    - #### execute

          public final void execute()
                             throws org.apache.maven.plugin.MojoExecutionException,
                                    org.apache.maven.plugin.MojoFailureException

      The default implementation of `Mojo.execute()`, that sets and validates shared parameters, then calls the abstract method `doExecute()`, that needs to be implemented by children classes.

      Throws:
        `org.apache.maven.plugin.MojoExecutionException`
        `org.apache.maven.plugin.MojoFailureException`

    - #### doExecute

          protected abstract void doExecute()
                                     throws org.apache.maven.plugin.MojoExecutionException,
                                            org.apache.maven.plugin.MojoFailureException

      An abstract method to hold the children classes execution logic.
      Throws:
        `org.apache.maven.plugin.MojoExecutionException` - if there is an issue with the build that makes it impossible to continue.
        `org.apache.maven.plugin.MojoFailureException` - if there is any other kind of failures.

    - #### getCurrentCharset

          protected Charset getCurrentCharset()

      Returns the current `Charset` value.
      Returns:
        the current `Charset`.

    - #### getOutputDirectory

          protected String getOutputDirectory()

      Returns the project output directory path.
      Returns:
        the project output directory.

    - #### getProject

          protected org.apache.maven.project.MavenProject getProject()

      Returns the current `MavenProject` instance.
      Returns:
        the `MavenProject` instance.

    - #### getSourceFileExtension

          protected String getSourceFileExtension()

      Returns the current sources filename extension.

      This is how the plugin will determine which files it should process.

      Returns:
        the sources filename extension.

    - #### processOutputDirectoryFiles

          protected void processOutputDirectoryFiles(Consumer<Path> pumlFileProcessor)
                                              throws IOException

      An utility method that enables the processing of the C4 PlantUML sources in the output directory.
      Parameters:
        `pumlFileProcessor` - the source file consumer method.
      Throws:
        `IOException` - if any I/O error happens while accessing a source file.

    - #### validateSourceFileExtension

          protected void validateSourceFileExtension()

      Validates that the current `sourceFileExtension` property has a correct value, or sets it to the default value and displays an error message.

Copyright © 2020. All rights reserved.