You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2020/09/28 15:45:16 UTC

[camel] 01/02: sourcecheck reformat

This is an automated email from the ASF dual-hosted git repository.

janbednar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit ce83e9dbde05f4e4cfb07a0e5ba8468c4d2cfbdc
Author: Jan Bednář <ma...@janbednar.eu>
AuthorDate: Mon Sep 28 15:19:56 2020 +0200

    sourcecheck reformat
---
 .../org/apache/camel/spi/SendDynamicAware.java     |   5 +-
 .../component/seda/SedaWireTapOnCompleteTest.java  |  14 +--
 .../apache/camel/main/xml/MainXmlRestsTest.java    |   7 +-
 .../org/apache/camel/maven/bundle/CamelPlugin.java |  19 ++--
 .../apache/felix/bundleplugin/ManifestPlugin.java  |  45 ++++-----
 .../net/revelc/code/formatter/FormatterMojo.java   | 103 +++++++++++++--------
 .../net/revelc/code/formatter/ValidateMojo.java    |   5 +-
 7 files changed, 115 insertions(+), 83 deletions(-)

diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/SendDynamicAware.java b/core/camel-api/src/main/java/org/apache/camel/spi/SendDynamicAware.java
index c07ec4a..d51872d 100644
--- a/core/camel-api/src/main/java/org/apache/camel/spi/SendDynamicAware.java
+++ b/core/camel-api/src/main/java/org/apache/camel/spi/SendDynamicAware.java
@@ -47,9 +47,8 @@ public interface SendDynamicAware extends Service, CamelContextAware {
     /**
      * Whether only the query parameters can be dynamic and the context-path must be static.
      *
-     * If true then Camel can restructure endpoint uri using a simple and faster parser.
-     * On the other hand if the context-path and authority part of the URI can be dynamic
-     * then Camel has to use a more complex and slower parser.
+     * If true then Camel can restructure endpoint uri using a simple and faster parser. On the other hand if the
+     * context-path and authority part of the URI can be dynamic then Camel has to use a more complex and slower parser.
      */
     boolean isOnlyDynamicQueryParameters();
 
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaWireTapOnCompleteTest.java b/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaWireTapOnCompleteTest.java
index 97a9803..1fcbaee 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaWireTapOnCompleteTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/seda/SedaWireTapOnCompleteTest.java
@@ -41,15 +41,15 @@ public class SedaWireTapOnCompleteTest extends ContextTestSupport {
                 onCompletion().log("Done ${header.foo}").to("mock:done");
 
                 from("direct:start")
-                    .setHeader("foo", constant("123"))
-                    .log("First ${header.foo}")
-                    .wireTap("seda:cheese")
-                    .to("mock:first");
+                        .setHeader("foo", constant("123"))
+                        .log("First ${header.foo}")
+                        .wireTap("seda:cheese")
+                        .to("mock:first");
 
                 from("seda:cheese")
-                    .setHeader("foo", constant("456"))
-                    .log("Second ${header.foo}")
-                    .to("mock:second");
+                        .setHeader("foo", constant("456"))
+                        .log("Second ${header.foo}")
+                        .to("mock:second");
             }
         };
     }
diff --git a/core/camel-main/src/test/java/org/apache/camel/main/xml/MainXmlRestsTest.java b/core/camel-main/src/test/java/org/apache/camel/main/xml/MainXmlRestsTest.java
index 35d70eb..998f139 100644
--- a/core/camel-main/src/test/java/org/apache/camel/main/xml/MainXmlRestsTest.java
+++ b/core/camel-main/src/test/java/org/apache/camel/main/xml/MainXmlRestsTest.java
@@ -105,8 +105,11 @@ public class MainXmlRestsTest {
 
     private static final class MockRestConsumerFactory implements RestConsumerFactory {
         @Override
-        public Consumer createConsumer(CamelContext camelContext, Processor processor, String verb, String basePath, String uriTemplate, String consumes,
-                String produces, RestConfiguration configuration, Map<String, Object> parameters) throws Exception {
+        public Consumer createConsumer(
+                CamelContext camelContext, Processor processor, String verb, String basePath, String uriTemplate,
+                String consumes,
+                String produces, RestConfiguration configuration, Map<String, Object> parameters)
+                throws Exception {
             return null;
         }
     }
diff --git a/init/camel-bundle-plugin/src/main/java/org/apache/camel/maven/bundle/CamelPlugin.java b/init/camel-bundle-plugin/src/main/java/org/apache/camel/maven/bundle/CamelPlugin.java
index 28d421b..38ca8f5 100644
--- a/init/camel-bundle-plugin/src/main/java/org/apache/camel/maven/bundle/CamelPlugin.java
+++ b/init/camel-bundle-plugin/src/main/java/org/apache/camel/maven/bundle/CamelPlugin.java
@@ -35,20 +35,21 @@ public class CamelPlugin implements AnalyzerPlugin {
         Jar jar = analyzer.getJar();
         Map<String, Map<String, Resource>> dir = jar.getDirectories();
 
-        Stream<String> components = dir.getOrDefault("META-INF/services/org/apache/camel/component", Collections.emptyMap())
-                .keySet().stream()
+        Stream<String> components = dir
+                .getOrDefault("META-INF/services/org/apache/camel/component", Collections.emptyMap()).keySet().stream()
                 .map(s -> s.substring(s.lastIndexOf('/') + 1))
                 .map(s -> "osgi.service;effective:=active;objectClass=\"org.apache.camel.spi.ComponentResolver\";component="
-                          + s);
-        Stream<String> languages = dir.getOrDefault("META-INF/services/org/apache/camel/language", Collections.emptyMap())
-                .keySet().stream()
+                        + s);
+        Stream<String> languages = dir
+                .getOrDefault("META-INF/services/org/apache/camel/language", Collections.emptyMap()).keySet().stream()
                 .map(s -> s.substring(s.lastIndexOf('/') + 1))
-                .map(s -> "osgi.service;effective:=active;objectClass=\"org.apache.camel.spi.LanguageResolver\";language=" + s);
-        Stream<String> dataformats = dir.getOrDefault("META-INF/services/org/apache/camel/dataformat", Collections.emptyMap())
-                .keySet().stream()
+                .map(s -> "osgi.service;effective:=active;objectClass=\"org.apache.camel.spi.LanguageResolver\";language="
+                        + s);
+        Stream<String> dataformats = dir
+                .getOrDefault("META-INF/services/org/apache/camel/dataformat", Collections.emptyMap()).keySet().stream()
                 .map(s -> s.substring(s.lastIndexOf('/') + 1))
                 .map(s -> "osgi.service;effective:=active;objectClass=\"org.apache.camel.spi.DataformatResolver\";dataformat="
-                          + s);
+                        + s);
         String header = analyzer.getProperty("Provide-Capability");
 
         header = Stream
diff --git a/init/camel-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java b/init/camel-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
index a29aea3..303ba1e 100644
--- a/init/camel-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
+++ b/init/camel-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
@@ -66,8 +66,7 @@ import org.sonatype.plexus.build.incremental.BuildContext;
 /**
  * Generate an OSGi manifest for this project
  */
-@Mojo(name = "manifest", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true,
-      defaultPhase = LifecyclePhase.PROCESS_CLASSES)
+@Mojo(name = "manifest", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true, defaultPhase = LifecyclePhase.PROCESS_CLASSES)
 public class ManifestPlugin extends BundlePlugin {
     /**
      * When true, generate the manifest by rebuilding the full bundle in memory
@@ -168,9 +167,8 @@ public class ManifestPlugin extends BundlePlugin {
         return getManifest(project, new LinkedHashMap<String, String>(), classpath, buildContext);
     }
 
-    public Manifest getManifest(
-            MavenProject project, Map<String, String> instructions, ClassPathItem[] classpath, BuildContext buildContext)
-            throws IOException, MojoFailureException, MojoExecutionException, Exception {
+    public Manifest getManifest(MavenProject project, Map<String, String> instructions, ClassPathItem[] classpath,
+            BuildContext buildContext) throws IOException, MojoFailureException, MojoExecutionException, Exception {
         Analyzer analyzer = getAnalyzer(project, instructions, classpath);
 
         Jar jar = analyzer.getJar();
@@ -213,7 +211,8 @@ public class ManifestPlugin extends BundlePlugin {
 
     }
 
-    private static void writeSCR(Resource resource, File destination, BuildContext buildContext, Log log) throws Exception {
+    private static void writeSCR(Resource resource, File destination, BuildContext buildContext, Log log)
+            throws Exception {
         log.debug("Write SCR file: " + destination.getPath());
         destination.getParentFile().mkdirs();
         OutputStream os = buildContext.newFileOutputStream(destination);
@@ -260,7 +259,8 @@ public class ManifestPlugin extends BundlePlugin {
 
         boolean isOutputDirectory = file.equals(getOutputDirectory());
 
-        if (analyzer.getProperty(Analyzer.EXPORT_PACKAGE) == null && analyzer.getProperty(Analyzer.EXPORT_CONTENTS) == null
+        if (analyzer.getProperty(Analyzer.EXPORT_PACKAGE) == null
+                && analyzer.getProperty(Analyzer.EXPORT_CONTENTS) == null
                 && analyzer.getProperty(Analyzer.PRIVATE_PACKAGE) == null && !isOutputDirectory) {
             String export = calculateExportsFromContents(analyzer.getJar());
             analyzer.setProperty(Analyzer.EXPORT_PACKAGE, export);
@@ -388,7 +388,8 @@ public class ManifestPlugin extends BundlePlugin {
                         try (ZipFile zf = new ZipFile(file)) {
                             return zf.stream().filter(ze -> !ze.isDirectory())
                                     .filter(ze -> ze.getLastModifiedTime().toMillis() > lastmod)
-                                    .map(ze -> file.toString() + "!" + ze.getName()).collect(Collectors.toList()).stream();
+                                    .map(ze -> file.toString() + "!" + ze.getName()).collect(Collectors.toList())
+                                    .stream();
                         }
                     } else {
                         return Stream.of(file.toString());
@@ -404,10 +405,8 @@ public class ManifestPlugin extends BundlePlugin {
         }
     }
 
-    public static void writeManifest(
-            Analyzer analyzer, File outputFile, boolean niceManifest, boolean exportScr, File scrLocation,
-            BuildContext buildContext, Log log)
-            throws Exception {
+    public static void writeManifest(Analyzer analyzer, File outputFile, boolean niceManifest, boolean exportScr,
+            File scrLocation, BuildContext buildContext, Log log) throws Exception {
         Properties properties = analyzer.getProperties();
         Jar jar = analyzer.getJar();
         Manifest manifest = jar.getManifest();
@@ -433,9 +432,8 @@ public class ManifestPlugin extends BundlePlugin {
         }
     }
 
-    public static void writeManifest(
-            Manifest manifest, File outputFile, boolean niceManifest, BuildContext buildContext, Log log)
-            throws IOException {
+    public static void writeManifest(Manifest manifest, File outputFile, boolean niceManifest,
+            BuildContext buildContext, Log log) throws IOException {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         try {
             ManifestWriter.outputManifest(manifest, baos, niceManifest);
@@ -457,10 +455,15 @@ public class ManifestPlugin extends BundlePlugin {
      * Update a file with the given binary content if neeed. The file won't be modified if the content is already the
      * same.
      *
-     * @param  path        the path of the file to update
-     * @param  newdata     the new binary data, <code>null</code> to delete the file
-     * @return             <code>true</code> if the file was modified, <code>false</code> otherwise
-     * @throws IOException if an exception occurs
+     * @param path
+     *            the path of the file to update
+     * @param newdata
+     *            the new binary data, <code>null</code> to delete the file
+     * 
+     * @return <code>true</code> if the file was modified, <code>false</code> otherwise
+     * 
+     * @throws IOException
+     *             if an exception occurs
      */
     public static boolean updateFile(Path path, byte[] newdata) throws IOException {
         if (newdata == null) {
@@ -478,8 +481,8 @@ public class ManifestPlugin extends BundlePlugin {
                 return false;
             }
             Files.createDirectories(path.getParent());
-            Files.write(path, newdata, StandardOpenOption.WRITE,
-                    StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
+            Files.write(path, newdata, StandardOpenOption.WRITE, StandardOpenOption.CREATE,
+                    StandardOpenOption.TRUNCATE_EXISTING);
             return true;
         }
     }
diff --git a/init/camel-format-plugin/src/main/java/net/revelc/code/formatter/FormatterMojo.java b/init/camel-format-plugin/src/main/java/net/revelc/code/formatter/FormatterMojo.java
index 8873b8d..d394222 100644
--- a/init/camel-format-plugin/src/main/java/net/revelc/code/formatter/FormatterMojo.java
+++ b/init/camel-format-plugin/src/main/java/net/revelc/code/formatter/FormatterMojo.java
@@ -82,8 +82,7 @@ public class FormatterMojo extends AbstractMojo implements ConfigurationSource {
     private static final String CACHE_PROPERTIES_FILENAME = "formatter-maven-cache.properties";
 
     /** The Constant DEFAULT_INCLUDES. */
-    private static final String[] DEFAULT_INCLUDES = new String[] {
-            "**/*.css", "**/*.json", "**/*.html", "**/*.java",
+    private static final String[] DEFAULT_INCLUDES = new String[] { "**/*.css", "**/*.json", "**/*.html", "**/*.java",
             "**/*.js", "**/*.xml" };
 
     /**
@@ -311,10 +310,12 @@ public class FormatterMojo extends AbstractMojo implements ConfigurationSource {
     /**
      * Execute.
      *
-     * @throws MojoExecutionException the mojo execution exception
-     * @throws MojoFailureException   the mojo failure exception
+     * @throws MojoExecutionException
+     *             the mojo execution exception
+     * @throws MojoFailureException
+     *             the mojo failure exception
      * 
-     * @see                           AbstractMojo#execute()
+     * @see AbstractMojo#execute()
      */
     @Override
     public void execute() throws MojoExecutionException, MojoFailureException {
@@ -328,7 +329,7 @@ public class FormatterMojo extends AbstractMojo implements ConfigurationSource {
         if (StringUtils.isEmpty(this.encoding)) {
             this.encoding = ReaderFactory.FILE_ENCODING;
             getLog().warn("File encoding has not been set, using platform encoding (" + this.encoding
-                          + ") to format source files, i.e. build is platform dependent!");
+                    + ") to format source files, i.e. build is platform dependent!");
         } else {
             if (!Charset.isSupported(this.encoding)) {
                 throw new MojoExecutionException("Encoding '" + this.encoding + "' is not supported");
@@ -436,7 +437,8 @@ public class FormatterMojo extends AbstractMojo implements ConfigurationSource {
     /**
      * Store file hash cache.
      *
-     * @param props the props
+     * @param props
+     *            the props
      */
     private void storeFileHashCache(Properties props) {
         File cacheFile = new File(this.cachedir, CACHE_PROPERTIES_FILENAME);
@@ -459,7 +461,7 @@ public class FormatterMojo extends AbstractMojo implements ConfigurationSource {
             this.cachedir.mkdirs();
         } else if (!this.cachedir.isDirectory()) {
             log.warn("Something strange here as the '" + this.cachedir.getPath()
-                     + "' supposedly cache directory is not a directory.");
+                    + "' supposedly cache directory is not a directory.");
             return props;
         }
 
@@ -479,13 +481,19 @@ public class FormatterMojo extends AbstractMojo implements ConfigurationSource {
     /**
      * Format file.
      *
-     * @param  file                   the file
-     * @param  rc                     the rc
-     * @param  hashCache              the hash cache
-     * @param  basedirPath            the basedir path
+     * @param file
+     *            the file
+     * @param rc
+     *            the rc
+     * @param hashCache
+     *            the hash cache
+     * @param basedirPath
+     *            the basedir path
      * 
-     * @throws MojoFailureException   the mojo failure exception
-     * @throws MojoExecutionException the mojo execution exception
+     * @throws MojoFailureException
+     *             the mojo failure exception
+     * @throws MojoExecutionException
+     *             the mojo execution exception
      */
     private void formatFile(File file, ResultCollector rc, Properties hashCache, String basedirPath)
             throws MojoFailureException, MojoExecutionException {
@@ -500,16 +508,25 @@ public class FormatterMojo extends AbstractMojo implements ConfigurationSource {
     /**
      * Format individual file.
      *
-     * @param  file                   the file
-     * @param  rc                     the rc
-     * @param  hashCache              the hash cache
-     * @param  basedirPath            the basedir path
-     * @param  dryRun                 the dry run
+     * @param file
+     *            the file
+     * @param rc
+     *            the rc
+     * @param hashCache
+     *            the hash cache
+     * @param basedirPath
+     *            the basedir path
+     * @param dryRun
+     *            the dry run
      * 
-     * @throws IOException            Signals that an I/O exception has occurred.
-     * @throws BadLocationException   the bad location exception
-     * @throws MojoFailureException   the mojo failure exception
-     * @throws MojoExecutionException the mojo execution exception
+     * @throws IOException
+     *             Signals that an I/O exception has occurred.
+     * @throws BadLocationException
+     *             the bad location exception
+     * @throws MojoFailureException
+     *             the mojo failure exception
+     * @throws MojoExecutionException
+     *             the mojo execution exception
      */
     protected void doFormatFile(File file, ResultCollector rc, Properties hashCache, String basedirPath, boolean dryRun)
             throws IOException, BadLocationException, MojoFailureException, MojoExecutionException {
@@ -629,9 +646,10 @@ public class FormatterMojo extends AbstractMojo implements ConfigurationSource {
     /**
      * sha512hash.
      *
-     * @param  str the str
+     * @param str
+     *            the str
      * 
-     * @return     the string
+     * @return the string
      */
     private String sha512hash(String str) {
         return Hashing.sha512().hashBytes(str.getBytes(getEncoding())).toString();
@@ -640,11 +658,13 @@ public class FormatterMojo extends AbstractMojo implements ConfigurationSource {
     /**
      * Read the given file and return the content as a string.
      *
-     * @param  file        the file
+     * @param file
+     *            the file
      * 
-     * @return             the string
+     * @return the string
      * 
-     * @throws IOException Signals that an I/O exception has occurred.
+     * @throws IOException
+     *             Signals that an I/O exception has occurred.
      */
     private String readFileAsString(File file) throws IOException {
         StringBuilder fileData = new StringBuilder(1000);
@@ -663,10 +683,13 @@ public class FormatterMojo extends AbstractMojo implements ConfigurationSource {
     /**
      * Write the given string to a file.
      *
-     * @param  str         the str
-     * @param  file        the file
+     * @param str
+     *            the str
+     * @param file
+     *            the file
      * 
-     * @throws IOException Signals that an I/O exception has occurred.
+     * @throws IOException
+     *             Signals that an I/O exception has occurred.
      */
     private void writeStringToFile(String str, File file) throws IOException {
         if (!file.exists() && file.isDirectory()) {
@@ -681,7 +704,8 @@ public class FormatterMojo extends AbstractMojo implements ConfigurationSource {
     /**
      * Create a {@link CodeFormatter} instance to be used by this mojo.
      *
-     * @throws MojoExecutionException the mojo execution exception
+     * @throws MojoExecutionException
+     *             the mojo execution exception
      */
     private void createCodeFormatter() throws MojoExecutionException {
         // Java Setup
@@ -725,9 +749,10 @@ public class FormatterMojo extends AbstractMojo implements ConfigurationSource {
     /**
      * Return the options to be passed when creating {@link CodeFormatter} instance.
      *
-     * @return                        the formatting options or null if not config file found
+     * @return the formatting options or null if not config file found
      * 
-     * @throws MojoExecutionException the mojo execution exception
+     * @throws MojoExecutionException
+     *             the mojo execution exception
      */
     private Map<String, String> getFormattingOptions(String newConfigFile) throws MojoExecutionException {
         if (this.useEclipseDefaults) {
@@ -746,9 +771,10 @@ public class FormatterMojo extends AbstractMojo implements ConfigurationSource {
     /**
      * Read config file and return the config as {@link Map}.
      *
-     * @return                        the options from config file
+     * @return the options from config file
      * 
-     * @throws MojoExecutionException the mojo execution exception
+     * @throws MojoExecutionException
+     *             the mojo execution exception
      */
     private Map<String, String> getOptionsFromConfigFile(String newConfigFile) throws MojoExecutionException {
 
@@ -771,9 +797,10 @@ public class FormatterMojo extends AbstractMojo implements ConfigurationSource {
     /**
      * Read properties file and return the properties as {@link Map}.
      *
-     * @return                        the options from properties file or null if not properties file found
+     * @return the options from properties file or null if not properties file found
      * 
-     * @throws MojoExecutionException the mojo execution exception
+     * @throws MojoExecutionException
+     *             the mojo execution exception
      */
     private Map<String, String> getOptionsFromPropertiesFile(String newPropertiesFile) throws MojoExecutionException {
 
diff --git a/init/camel-format-plugin/src/main/java/net/revelc/code/formatter/ValidateMojo.java b/init/camel-format-plugin/src/main/java/net/revelc/code/formatter/ValidateMojo.java
index 628f3e5..9ecf0f8 100755
--- a/init/camel-format-plugin/src/main/java/net/revelc/code/formatter/ValidateMojo.java
+++ b/init/camel-format-plugin/src/main/java/net/revelc/code/formatter/ValidateMojo.java
@@ -55,9 +55,8 @@ public class ValidateMojo extends FormatterMojo {
         super.doFormatFile(file, rc, hashCache, basedirPath, true);
 
         if (rc.successCount != 0) {
-            throw new MojoFailureException(
-                    "File '" + file
-                                           + "' has not been previously formatted.  Please format file and commit before running validation!");
+            throw new MojoFailureException("File '" + file
+                    + "' has not been previously formatted.  Please format file and commit before running validation!");
         }
         if (rc.failCount != 0) {
             throw new MojoExecutionException("Error formating '" + file + "' ");