You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2021/08/22 19:55:50 UTC

[maven-doxia-converter] branch DOXIATOOLS-71 created (now 5200109)

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

slachiewicz pushed a change to branch DOXIATOOLS-71
in repository https://gitbox.apache.org/repos/asf/maven-doxia-converter.git.


      at 5200109  [DOXIATOOLS-71] Require Java 8

This branch includes the following new commits:

     new 5200109  [DOXIATOOLS-71] Require Java 8

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[maven-doxia-converter] 01/01: [DOXIATOOLS-71] Require Java 8

Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch DOXIATOOLS-71
in repository https://gitbox.apache.org/repos/asf/maven-doxia-converter.git

commit 5200109b5a1304bc6a902a044483df9150cfbddc
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Sun Aug 22 21:55:44 2021 +0200

    [DOXIATOOLS-71] Require Java 8
---
 pom.xml                                            |  2 +-
 .../org/apache/maven/doxia/DefaultConverter.java   |  5 +--
 .../org/apache/maven/doxia/cli/ConverterCli.java   |  2 +-
 .../org/apache/maven/doxia/util/ConverterUtil.java | 36 +++++-----------------
 .../maven/doxia/wrapper/AbstractFileWrapper.java   |  7 ++---
 .../maven/doxia/wrapper/InputFileWrapper.java      |  2 +-
 .../maven/doxia/wrapper/InputReaderWrapper.java    |  2 +-
 .../maven/doxia/wrapper/OutputStreamWrapper.java   | 10 +++---
 .../java/org/apache/maven/doxia/ConverterTest.java | 10 ------
 9 files changed, 22 insertions(+), 54 deletions(-)

diff --git a/pom.xml b/pom.xml
index ea4a7cd..3ca51f6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -58,7 +58,7 @@ under the License.
 
   <properties>
     <doxiaVersion>1.10</doxiaVersion>
-    <javaVersion>7</javaVersion>
+    <javaVersion>8</javaVersion>
     <project.build.outputTimestamp>2020-03-14T00:00:00Z</project.build.outputTimestamp>
   </properties>
   <dependencyManagement>
diff --git a/src/main/java/org/apache/maven/doxia/DefaultConverter.java b/src/main/java/org/apache/maven/doxia/DefaultConverter.java
index f4b5ef7..e6b7223 100644
--- a/src/main/java/org/apache/maven/doxia/DefaultConverter.java
+++ b/src/main/java/org/apache/maven/doxia/DefaultConverter.java
@@ -528,8 +528,8 @@ public class DefaultConverter
      * @return the detected encoding for f or <code>null</code> if not able to detect it.
      * @throws IllegalArgumentException if f is not a file.
      * @throws UnsupportedOperationException if could not detect the file encoding.
-     * @see {@link XmlStreamReader#getEncoding()} for xml files
-     * @see {@link CharsetDetector#detect()} for text files
+     * @see XmlStreamReader#getEncoding() for xml files
+     * @see CharsetDetector#detect() for text files
      */
     static String autoDetectEncoding( File f )
     {
@@ -608,6 +608,7 @@ public class DefaultConverter
             String firstTag = getFirstTag( f );
             if ( firstTag == null )
             {
+                //noinspection UnnecessaryContinue
                 continue;
             }
             else if ( "article".equals( firstTag ) && DOCBOOK_PARSER.equalsIgnoreCase( supportedFromFormat ) )
diff --git a/src/main/java/org/apache/maven/doxia/cli/ConverterCli.java b/src/main/java/org/apache/maven/doxia/cli/ConverterCli.java
index a0d8224..27a169b 100644
--- a/src/main/java/org/apache/maven/doxia/cli/ConverterCli.java
+++ b/src/main/java/org/apache/maven/doxia/cli/ConverterCli.java
@@ -63,7 +63,7 @@ public class ConverterCli
     }
 
     /**
-     * @param args
+     * @param args The args
      */
     private static int doMain( String[] args )
     {
diff --git a/src/main/java/org/apache/maven/doxia/util/ConverterUtil.java b/src/main/java/org/apache/maven/doxia/util/ConverterUtil.java
index 6877a85..18983d6 100644
--- a/src/main/java/org/apache/maven/doxia/util/ConverterUtil.java
+++ b/src/main/java/org/apache/maven/doxia/util/ConverterUtil.java
@@ -25,6 +25,8 @@ import org.apache.maven.doxia.sink.SinkFactory;
 import org.codehaus.plexus.PlexusContainer;
 import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
 
+import java.util.Objects;
+
 /**
  * Utility class to play with Doxia objects.
  *
@@ -44,20 +46,9 @@ public class ConverterUtil
     public static Parser getParser( PlexusContainer plexus, String format, String[] supportedFormats )
         throws ComponentLookupException, UnsupportedFormatException
     {
-        if ( plexus == null )
-        {
-            throw new IllegalArgumentException( "plexus is required" );
-        }
-
-        if ( format == null )
-        {
-            throw new IllegalArgumentException( "format is required" );
-        }
-
-        if ( supportedFormats == null )
-        {
-            throw new IllegalArgumentException( "supportedFormats is required" );
-        }
+        Objects.requireNonNull( plexus, "plexus is required" );
+        Objects.requireNonNull( format, "format is required" );
+        Objects.requireNonNull( supportedFormats, "supportedFormats is required" );
 
         Parser parser = null;
 
@@ -89,20 +80,9 @@ public class ConverterUtil
     public static SinkFactory getSinkFactory( PlexusContainer plexus, String format, String[] supportedFormats )
         throws ComponentLookupException, UnsupportedFormatException
     {
-        if ( plexus == null )
-        {
-            throw new IllegalArgumentException( "plexus is required" );
-        }
-
-        if ( format == null )
-        {
-            throw new IllegalArgumentException( "format is required" );
-        }
-
-        if ( supportedFormats == null )
-        {
-            throw new IllegalArgumentException( "supportedFormats is required" );
-        }
+        Objects.requireNonNull( plexus, "plexus is required" );
+        Objects.requireNonNull( format, "format is required" );
+        Objects.requireNonNull( supportedFormats, "supportedFormats is required" );
 
         SinkFactory factory = null;
 
diff --git a/src/main/java/org/apache/maven/doxia/wrapper/AbstractFileWrapper.java b/src/main/java/org/apache/maven/doxia/wrapper/AbstractFileWrapper.java
index 814037a..9936d91 100644
--- a/src/main/java/org/apache/maven/doxia/wrapper/AbstractFileWrapper.java
+++ b/src/main/java/org/apache/maven/doxia/wrapper/AbstractFileWrapper.java
@@ -74,10 +74,9 @@ abstract class AbstractFileWrapper
         if ( isNotEmpty( encoding ) && !encoding.equalsIgnoreCase( encoding )
             && !Charset.isSupported( encoding ) )
         {
-            StringBuilder msg = new StringBuilder();
-            msg.append( "The encoding '" + encoding + "' is not a valid one. The supported charsets are: " );
-            msg.append( StringUtils.join( CharsetDetector.getAllDetectableCharsets(), ", " ) );
-            throw new UnsupportedEncodingException( msg.toString() );
+            throw new UnsupportedEncodingException( "The encoding '" + encoding
+                    + "' is not a valid one. The supported charsets are: "
+                    + StringUtils.join( CharsetDetector.getAllDetectableCharsets(), ", " ) );
         }
         this.encoding = ( isNotEmpty( encoding ) ? encoding : AUTO_ENCODING );
     }
diff --git a/src/main/java/org/apache/maven/doxia/wrapper/InputFileWrapper.java b/src/main/java/org/apache/maven/doxia/wrapper/InputFileWrapper.java
index 586cc9d..fdedd88 100644
--- a/src/main/java/org/apache/maven/doxia/wrapper/InputFileWrapper.java
+++ b/src/main/java/org/apache/maven/doxia/wrapper/InputFileWrapper.java
@@ -36,7 +36,7 @@ public class InputFileWrapper
     /**
      * Private constructor.
      *
-     * @param file not null
+     * @param absolutePath not null
      * @param format could be null
      * @param charsetName could be null
      * @param supportedFormat not null
diff --git a/src/main/java/org/apache/maven/doxia/wrapper/InputReaderWrapper.java b/src/main/java/org/apache/maven/doxia/wrapper/InputReaderWrapper.java
index 6aedafe..d74004f 100644
--- a/src/main/java/org/apache/maven/doxia/wrapper/InputReaderWrapper.java
+++ b/src/main/java/org/apache/maven/doxia/wrapper/InputReaderWrapper.java
@@ -32,7 +32,7 @@ public class InputReaderWrapper
     /** serialVersionUID */
     static final long serialVersionUID = 3260213754615748766L;
 
-    private Reader reader;
+    private final Reader reader;
 
     /**
      * Private constructor.
diff --git a/src/main/java/org/apache/maven/doxia/wrapper/OutputStreamWrapper.java b/src/main/java/org/apache/maven/doxia/wrapper/OutputStreamWrapper.java
index 0ae064c..2357504 100644
--- a/src/main/java/org/apache/maven/doxia/wrapper/OutputStreamWrapper.java
+++ b/src/main/java/org/apache/maven/doxia/wrapper/OutputStreamWrapper.java
@@ -20,6 +20,7 @@ package org.apache.maven.doxia.wrapper;
  */
 
 import java.io.OutputStream;
+import java.util.Objects;
 
 import static org.codehaus.plexus.util.StringUtils.isEmpty;
 
@@ -34,9 +35,9 @@ public class OutputStreamWrapper
     /** serialVersionUID */
     static final long serialVersionUID = 3329037527245430610L;
 
-    private OutputStream out;
+    private final OutputStream out;
 
-    private String encoding;
+    private final String encoding;
 
     /**
      * Private constructor.
@@ -84,10 +85,7 @@ public class OutputStreamWrapper
     public static OutputStreamWrapper valueOf( OutputStream out, String format, String encoding,
             String[] supportedFormat )
     {
-        if ( out == null )
-        {
-            throw new IllegalArgumentException( "output writer is required" );
-        }
+        Objects.requireNonNull( out, "output writer is required" );
         if ( isEmpty( format ) )
         {
             throw new IllegalArgumentException( "output format is required" );
diff --git a/src/test/java/org/apache/maven/doxia/ConverterTest.java b/src/test/java/org/apache/maven/doxia/ConverterTest.java
index f4000e3..f448e32 100644
--- a/src/test/java/org/apache/maven/doxia/ConverterTest.java
+++ b/src/test/java/org/apache/maven/doxia/ConverterTest.java
@@ -41,7 +41,6 @@ import org.codehaus.plexus.util.WriterFactory;
  * Tests Doxia converter.
  *
  * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
- * @version $Id$
  */
 public class ConverterTest
     extends PlexusTestCase
@@ -648,24 +647,19 @@ public class ConverterTest
     }
 
     private String autoDetectEncoding( File f )
-        throws Throwable
     {
         return DefaultConverter.autoDetectEncoding( f );
     }
 
     private String autoDetectEncoding( String filename )
-        throws Throwable
     {
         return autoDetectEncoding( new File( getBasedir() + "/src/test/resources/unit/" + filename ) );
     }
 
     /**
      * Test {@link DefaultConverter#autoDetectEncoding(File)}
-     *
-     * @throws Throwable
      */
     public void testAutodetectEncoding()
-        throws Throwable
     {
         assertEquals( autoDetectEncoding( "apt/test.apt" ), "ISO-8859-1" );
         assertEquals( autoDetectEncoding( "confluence/test.confluence" ), "ISO-8859-1" );
@@ -676,13 +670,11 @@ public class ConverterTest
     }
 
     private String autoDetectFormat( File f, String encoding )
-        throws Throwable
     {
         return DefaultConverter.autoDetectFormat( f, encoding );
     }
 
     private String autoDetectFormat( String filename, String encoding )
-        throws Throwable
     {
         return autoDetectFormat( new File( getBasedir() + "/src/test/resources/unit/" + filename ), encoding );
     }
@@ -690,10 +682,8 @@ public class ConverterTest
     /**
      * Test {@link DefaultConverter#autoDetectFormat(File,String)}
      *
-     * @throws Throwable
      */
     public void testAutodetectFormat()
-        throws Throwable
     {
         assertEquals( autoDetectFormat( "apt/test.apt", "UTF-8" ), "apt" );