/*
 * Copyright 2017, TeamDev Ltd. All rights reserved.
 *
 * Redistribution and use in source and/or binary forms, with or without
 * modification, must retain the above copyright notice and the following
 * disclaimer.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package org.spine3.tools.codestyle;

import org.gradle.api.Project;
import org.gradle.api.plugins.ExtensionAware;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spine3.gradle.SpinePlugin;
import org.spine3.tools.codestyle.javadoc.JavadocLinkCheckerPlugin;

/**
 * The plugin that verifies code style.
 *
 * <p>The plugin verifies the few code style aspects.
 *
 * <p>Every verification starts one by one during a build process and
 * has {@linkplain Threshold "threshold"} and {@linkplain ReportType "reportType"} parameters.
 *
 * <p>The configuration may look like:
 * <pre>{@code
 * codestyleChecker {
 *
 *      javadocLinkChecker {
 *
 *          threshold = 0
 *          reportType = "warn"
 *      }
 *
 *      anotherCodestyleChecker {
 *
 *          threshold = 5
 *          reportType = "error"
 *      }
 * }
 * }</pre>
 *
 * @author Alexander Aleksandrov
 * @see Threshold
 * @see ReportType
 */
public class CodestyleCheckerPlugin extends SpinePlugin {

    public static final String CODESTYLE_CHECKER_EXTENSION_NAME = "codestyleChecker";

    @Override
    public void apply(final Project project) {
        project.getExtensions()
               .create(CODESTYLE_CHECKER_EXTENSION_NAME, CodestylePluginConfiguration.class);

        log().debug("Applying Spine Javadoc link checker plugin");
        new JavadocLinkCheckerPlugin().apply(project);
    }

    /**
     * Creates {@linkplain StepConfiguration step extension}
     * with the specified name in the specified project.
     *
     * @param extensionName the extension name to create
     * @param project       the project in which to create extensions
     * @return the created extension
     */
    public static StepConfiguration createStepExtension(String extensionName, Project project) {
        final ExtensionAware codestyleExtension =
                (ExtensionAware) project.getExtensions()
                                        .getByName(CODESTYLE_CHECKER_EXTENSION_NAME);
        return codestyleExtension.getExtensions()
                                 .create(extensionName, StepConfiguration.class);
    }

    private static Logger log() {
        return LogSingleton.INSTANCE.value;
    }

    private enum LogSingleton {
        INSTANCE;
        @SuppressWarnings("NonSerializableFieldInSerializableClass")
        private final Logger value = LoggerFactory.getLogger(CodestyleCheckerPlugin.class);
    }
}

@@ -1348,105 +1348,75 @@
 The 
-plugin verifies the few code style aspects.%0A *%0A * %3Cp%3EEvery verification starts one by one
+verification consists of several steps, executed in a chain
  during 
 a bu
@@ -1411,17 +1411,19 @@
  during 
-a
+the
  build p
@@ -1432,355 +1432,827 @@
 cess
- and%0A * has %7B@linkplain Threshold %22threshold%22%7D and %7B@linkplain ReportType %22reportType%22%7D parameters.%0A *%0A * %3Cp%3EThe configuration may look like:%0A * %3Cpre%3E%7B@code%0A * codestyleChecker %7B%0A *%0A *      javadocLinkChecker %7B%0A *%0A *          threshold = 0%0A *          reportType = %22warn%22%0A *      %7D%0A *%0A *      anotherCodestyleChecker %7B%0A *%0A *          threshold = 5
+.%0A *%0A * %3Cp%3EEach step is configured with the parameters as follows:%0A * %3Cul%3E%0A *     %3Cli%3E%7B@linkplain Threshold %22threshold%22%7D is a number of code style violations%0A *     to consider check passed;%3C/li%3E%0A *     %3Cli%3E%7B@linkplain ReportType %22reportType%22%7D if a check is not passed.%3C/li%3E%0A * %3C/ul%3E%0A *%0A * %3Cp%3EExample:%0A * %3Cpre%3E%7B@code%0A * codestyleChecker %7B%0A *%0A *      javadocLinkChecker %7B%0A *%0A *          // Will report the violations if a number of broken FQN links is exceed zero.%0A *          threshold = 0%0A *%0A *          // Report represents a logged violations.%0A *          reportType = %22warn%22%0A *      %7D%0A *%0A *      anotherCodestyleChecker %7B%0A *%0A *          // Will report the code style violations if a number of them is exceed five.%0A *          threshold = 5%0A *%0A *          // Report represents a logged violations and a failed build.
 %0A * 
@@ -2343,16 +2343,42 @@
 sandrov%0A
+ * @author Dmytro Grankin%0A
  * @see 

Fix Javadoc