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 2026/02/01 14:23:28 UTC
(maven-shared-utils) 01/01: Remove jsr305 based javax.annotation annotations
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch jsr305
in repository https://gitbox.apache.org/repos/asf/maven-shared-utils.git
commit af375e919f312d837fe21eb5482949f9bc46a7d2
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Sun Feb 1 15:09:49 2026 +0100
Remove jsr305 based javax.annotation annotations
---
pom.xml | 24 ---
.../org/apache/maven/shared/utils/PathTool.java | 14 +-
.../apache/maven/shared/utils/PropertyUtils.java | 18 +-
.../apache/maven/shared/utils/ReaderFactory.java | 17 +-
.../org/apache/maven/shared/utils/StringUtils.java | 179 +++++++-----------
.../apache/maven/shared/utils/WriterFactory.java | 15 +-
.../maven/shared/utils/cli/CommandLineUtils.java | 35 ++--
.../maven/shared/utils/cli/StreamPumper.java | 4 +-
.../introspection/ReflectionValueExtractor.java | 8 +-
.../maven/shared/utils/io/DirectoryScanner.java | 15 +-
.../apache/maven/shared/utils/io/FileUtils.java | 206 +++++++--------------
.../org/apache/maven/shared/utils/io/IOUtil.java | 119 ++++--------
.../apache/maven/shared/utils/io/Java7Support.java | 14 +-
.../apache/maven/shared/utils/io/MatchPattern.java | 8 +-
.../maven/shared/utils/io/MatchPatterns.java | 10 +-
.../maven/shared/utils/io/SelectorUtils.java | 18 +-
.../org/apache/maven/shared/utils/xml/Xpp3Dom.java | 9 +-
.../maven/shared/utils/xml/Xpp3DomBuilder.java | 14 +-
.../maven/shared/utils/io/FileUtilsTest.java | 6 +-
19 files changed, 255 insertions(+), 478 deletions(-)
diff --git a/pom.xml b/pom.xml
index e09ce3d..41843b2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -63,7 +63,6 @@
<checkstyle.violation.ignore>RedundantThrows,NewlineAtEndOfFile,ParameterNumber,MethodLength,FileLength,ModifierOrder</checkstyle.violation.ignore>
<project.build.outputTimestamp>2023-05-11T20:50:20Z</project.build.outputTimestamp>
<javaVersion>8</javaVersion>
- <mavenVersion>3.2.5</mavenVersion>
</properties>
<dependencies>
@@ -72,14 +71,12 @@
<artifactId>slf4j-api</artifactId>
<version>1.7.36</version>
</dependency>
-
<dependency>
<groupId>org.fusesource.jansi</groupId>
<artifactId>jansi</artifactId>
<version>2.4.2</version>
<optional>true</optional>
</dependency>
-
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
@@ -90,30 +87,9 @@
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>com.google.code.findbugs</groupId>
- <artifactId>jsr305</artifactId>
- <version>3.0.2</version>
- <scope>provided</scope>
- </dependency>
</dependencies>
<build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-resources-plugin</artifactId>
- <version>3.4.0</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-assembly-plugin</artifactId>
- <version>3.8.0</version>
- </plugin>
- </plugins>
- </pluginManagement>
-
<plugins>
<plugin>
<groupId>org.apache.rat</groupId>
diff --git a/src/main/java/org/apache/maven/shared/utils/PathTool.java b/src/main/java/org/apache/maven/shared/utils/PathTool.java
index 6338a93..c8e973b 100644
--- a/src/main/java/org/apache/maven/shared/utils/PathTool.java
+++ b/src/main/java/org/apache/maven/shared/utils/PathTool.java
@@ -18,9 +18,6 @@
*/
package org.apache.maven.shared.utils;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
import java.io.File;
import java.util.StringTokenizer;
@@ -76,7 +73,7 @@ public class PathTool {
* @deprecated use java.nio.file.Path.relativize() instead
*/
@Deprecated
- public static String getRelativePath(@Nullable String basedir, @Nullable String filename) {
+ public static String getRelativePath(String basedir, String filename) {
basedir = uppercaseDrive(basedir);
filename = uppercaseDrive(filename);
@@ -198,8 +195,7 @@ public class PathTool {
* terminated with a forward slash. A zero-length string is
* returned if: the filename is zero-length.
*/
- @Nonnull
- private static String determineRelativePath(@Nonnull String filename, @Nonnull String separator) {
+ private static String determineRelativePath(String filename, String separator) {
if (filename.length() == 0) {
return "";
}
@@ -254,7 +250,7 @@ public class PathTool {
* @param path old path
* @return String
*/
- static String uppercaseDrive(@Nullable String path) {
+ static String uppercaseDrive(String path) {
if (path == null) {
return null;
}
@@ -264,9 +260,7 @@ public class PathTool {
return path;
}
- @Nonnull
- private static String buildRelativePath(
- @Nonnull String toPath, @Nonnull String fromPath, final char separatorChar) {
+ private static String buildRelativePath(String toPath, String fromPath, final char separatorChar) {
// use tokeniser to traverse paths and for lazy checking
StringTokenizer toTokeniser = new StringTokenizer(toPath, String.valueOf(separatorChar));
StringTokenizer fromTokeniser = new StringTokenizer(fromPath, String.valueOf(separatorChar));
diff --git a/src/main/java/org/apache/maven/shared/utils/PropertyUtils.java b/src/main/java/org/apache/maven/shared/utils/PropertyUtils.java
index 0730828..84fd53a 100644
--- a/src/main/java/org/apache/maven/shared/utils/PropertyUtils.java
+++ b/src/main/java/org/apache/maven/shared/utils/PropertyUtils.java
@@ -18,9 +18,6 @@
*/
package org.apache.maven.shared.utils;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -49,7 +46,7 @@ public class PropertyUtils {
* instead of an empty {@code Properties} instance when the given {@code URL} is {@code null}.
*/
@Deprecated
- public static java.util.Properties loadProperties(@Nonnull URL url) {
+ public static java.util.Properties loadProperties(URL url) {
try (InputStream in = url.openStream()) {
return loadProperties(in);
} catch (Exception e) {
@@ -66,7 +63,7 @@ public class PropertyUtils {
* instead of an empty {@code Properties} instance when the given {@code File} is {@code null}.
*/
@Deprecated
- public static Properties loadProperties(@Nonnull File file) {
+ public static Properties loadProperties(File file) {
try (InputStream in = new FileInputStream(file)) {
return loadProperties(in);
} catch (Exception e) {
@@ -86,7 +83,7 @@ public class PropertyUtils {
* should not be used as it suppresses exceptions silently when loading properties fails.
*/
@Deprecated
- public static Properties loadProperties(@Nullable InputStream is) {
+ public static Properties loadProperties(InputStream is) {
try {
Properties result = new Properties();
if (is != null) {
@@ -113,8 +110,7 @@ public class PropertyUtils {
* @return the loaded properties or an empty {@code Properties} instance if properties fail to load
* @since 3.1.0
*/
- @Nonnull
- public static Properties loadOptionalProperties(final @Nullable URL url) {
+ public static Properties loadOptionalProperties(final URL url) {
Properties properties = new Properties();
if (url != null) {
@@ -138,8 +134,7 @@ public class PropertyUtils {
* @return the loaded properties or an empty {@code Properties} instance if properties fail to load
* @since 3.1.0
*/
- @Nonnull
- public static Properties loadOptionalProperties(final @Nullable File file) {
+ public static Properties loadOptionalProperties(final File file) {
Properties properties = new Properties();
if (file != null) {
try (InputStream in = new FileInputStream(file)) {
@@ -162,8 +157,7 @@ public class PropertyUtils {
* @return the loaded properties or an empty {@code Properties} instance if properties fail to load
* @since 3.1.0
*/
- @Nonnull
- public static Properties loadOptionalProperties(final @Nullable InputStream inputStream) {
+ public static Properties loadOptionalProperties(final InputStream inputStream) {
Properties properties = new Properties();
diff --git a/src/main/java/org/apache/maven/shared/utils/ReaderFactory.java b/src/main/java/org/apache/maven/shared/utils/ReaderFactory.java
index cb0921c..c51760a 100644
--- a/src/main/java/org/apache/maven/shared/utils/ReaderFactory.java
+++ b/src/main/java/org/apache/maven/shared/utils/ReaderFactory.java
@@ -18,8 +18,6 @@
*/
package org.apache.maven.shared.utils;
-import javax.annotation.Nonnull;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -115,7 +113,7 @@ public class ReaderFactory {
* @deprecated use {@code org.apache.commons.io.input.XmlStreamReader} instead
*/
@Deprecated
- public static Reader newXmlReader(@Nonnull InputStream in) throws IOException {
+ public static Reader newXmlReader(InputStream in) throws IOException {
return new XmlStreamReader(in);
}
@@ -128,7 +126,7 @@ public class ReaderFactory {
* @deprecated use {}@code org.apache.commons.io.input.XmlStreamReader} instead
*/
@Deprecated
- public static Reader newXmlReader(@Nonnull File file) throws IOException {
+ public static Reader newXmlReader(File file) throws IOException {
return new XmlStreamReader(file);
}
@@ -141,7 +139,7 @@ public class ReaderFactory {
* @deprecated use {@code org.apache.commons.io.input.XmlStreamReader} instead
*/
@Deprecated
- public static Reader newXmlReader(@Nonnull URL url) throws IOException {
+ public static Reader newXmlReader(URL url) throws IOException {
return new XmlStreamReader(url);
}
@@ -155,7 +153,7 @@ public class ReaderFactory {
* @deprecated always specify an encoding. Do not depend on the default platform character set.
*/
@Deprecated
- public static Reader newPlatformReader(@Nonnull File file) throws FileNotFoundException {
+ public static Reader newPlatformReader(File file) throws FileNotFoundException {
return new FileReader(file);
}
@@ -172,8 +170,7 @@ public class ReaderFactory {
* @deprecated use {@code new InputStreamReader(in, encoding)} instead
*/
@Deprecated
- public static Reader newReader(@Nonnull InputStream in, @Nonnull String encoding)
- throws UnsupportedEncodingException {
+ public static Reader newReader(InputStream in, String encoding) throws UnsupportedEncodingException {
return new InputStreamReader(in, encoding);
}
@@ -192,7 +189,7 @@ public class ReaderFactory {
* or {@code new Files.newBufferedReader} instead
*/
@Deprecated
- public static Reader newReader(@Nonnull File file, @Nonnull String encoding)
+ public static Reader newReader(File file, String encoding)
throws FileNotFoundException, UnsupportedEncodingException {
return new InputStreamReader(new FileInputStream(file), encoding);
}
@@ -211,7 +208,7 @@ public class ReaderFactory {
* @deprecated This method does not use HTTP headers to detect the resource's encoding.
*/
@Deprecated
- public static Reader newReader(@Nonnull URL url, @Nonnull String encoding) throws IOException {
+ public static Reader newReader(URL url, String encoding) throws IOException {
return new InputStreamReader(url.openStream(), encoding);
}
}
diff --git a/src/main/java/org/apache/maven/shared/utils/StringUtils.java b/src/main/java/org/apache/maven/shared/utils/StringUtils.java
index 8e89c4f..d02c17f 100644
--- a/src/main/java/org/apache/maven/shared/utils/StringUtils.java
+++ b/src/main/java/org/apache/maven/shared/utils/StringUtils.java
@@ -18,9 +18,6 @@
*/
package org.apache.maven.shared.utils;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
import java.util.Arrays;
import java.util.Iterator;
import java.util.Locale;
@@ -74,7 +71,6 @@ public class StringUtils {
* @deprecated use {@link #trim(String)} instead.
*/
@Deprecated
- @Nonnull
public static String clean(String str) {
return (str == null ? "" : str.trim());
}
@@ -101,8 +97,7 @@ public class StringUtils {
* @param str String target to delete whitespace from
* @return the String without whitespace
*/
- @Nonnull
- public static String deleteWhitespace(@Nonnull String str) {
+ public static String deleteWhitespace(String str) {
StringBuilder buffer = new StringBuilder();
int sz = str.length();
for (int i = 0; i < sz; i++) {
@@ -120,7 +115,7 @@ public class StringUtils {
* @param str the String to check
* @return true if the String is non-null, and not length zero
*/
- public static boolean isNotEmpty(@Nullable String str) {
+ public static boolean isNotEmpty(String str) {
return ((str != null) && (str.length() > 0));
}
@@ -135,7 +130,7 @@ public class StringUtils {
* @return <code>true</code> if the String is <code>null</code>, or
* length zero once trimmed
*/
- public static boolean isEmpty(@Nullable String str) {
+ public static boolean isEmpty(String str) {
return ((str == null) || (str.trim().length() == 0));
}
@@ -156,7 +151,7 @@ public class StringUtils {
* @return <code>true</code> if the String is null, empty or whitespace
*
*/
- public static boolean isBlank(@Nullable String str) {
+ public static boolean isBlank(String str) {
int strLen;
// CHECKSTYLE_OFF: InnerAssignment
if (str == null || (strLen = str.length()) == 0)
@@ -189,7 +184,7 @@ public class StringUtils {
* @return <code>true</code> if the String is not empty and not null and not whitespace
*
*/
- public static boolean isNotBlank(@Nullable String str) {
+ public static boolean isNotBlank(String str) {
return !isBlank(str);
}
@@ -210,7 +205,7 @@ public class StringUtils {
* @deprecated use {@code java.lang.Objects.equals()}
*/
@Deprecated
- public static boolean equals(@Nullable String str1, @Nullable String str2) {
+ public static boolean equals(String str1, String str2) {
return (str1 == null ? str2 == null : str1.equals(str2));
}
@@ -461,9 +456,8 @@ public class StringUtils {
* <code>String.split()</code>) splits on a regular expression so while it can
* do anything this method does, it is not a drop-in replacement.
*/
- @Nonnull
@Deprecated
- public static String[] split(@Nonnull String str) {
+ public static String[] split(String str) {
return split(str, null, -1);
}
@@ -476,9 +470,8 @@ public class StringUtils {
* <code>String.split()</code>) splits on a regular expression so while it can
* do anything this method does, it is not a drop-in replacement.
*/
- @Nonnull
@Deprecated
- public static String[] split(@Nonnull String text, @Nullable String separator) {
+ public static String[] split(String text, String separator) {
return split(text, separator, -1);
}
@@ -503,9 +496,8 @@ public class StringUtils {
* <code>String.split()</code>) splits on a regular expression so while it can
* do anything this method does, it is not a drop-in replacement.
*/
- @Nonnull
@Deprecated
- public static String[] split(@Nonnull String str, @Nullable String separator, int max) {
+ public static String[] split(String str, String separator, int max) {
StringTokenizer tok;
if (separator == null) {
// Null separator means we're using StringTokenizer's default
@@ -554,8 +546,7 @@ public class StringUtils {
* @param array the array of values to concatenate.
* @return the concatenated string.
*/
- @Nonnull
- public static String concatenate(@Nonnull Object... array) {
+ public static String concatenate(Object... array) {
return join(array, "");
}
@@ -572,8 +563,7 @@ public class StringUtils {
* @deprecated use <code>java.lang.String.join(</code>) instead
*/
@Deprecated
- @Nonnull
- public static String join(@Nonnull Object[] array, @Nullable String separator) {
+ public static String join(Object[] array, String separator) {
if (separator == null) {
separator = "";
}
@@ -603,8 +593,7 @@ public class StringUtils {
* @deprecated use <code>java.lang.String.join(</code>) instead
*/
@Deprecated
- @Nonnull
- public static String join(@Nonnull Iterator<?> iterator, String separator) {
+ public static String join(Iterator<?> iterator, String separator) {
if (separator == null) {
separator = "";
}
@@ -632,7 +621,7 @@ public class StringUtils {
* @return the text with any replacements processed
* @see #replace(String text, char repl, char with, int max)
*/
- public static String replaceOnce(@Nullable String text, char repl, char with) {
+ public static String replaceOnce(String text, char repl, char with) {
return replace(text, repl, with, 1);
}
@@ -647,7 +636,7 @@ public class StringUtils {
* @return the text with any replacements processed
* @see #replace(String text, char repl, char with, int max)
*/
- public static String replace(@Nullable String text, char repl, char with) {
+ public static String replace(String text, char repl, char with) {
return replace(text, repl, with, -1);
}
@@ -663,7 +652,7 @@ public class StringUtils {
* @param max maximum number of values to replace, or <code>-1</code> if no maximum
* @return the text with any replacements processed
*/
- public static String replace(@Nullable String text, char repl, char with, int max) {
+ public static String replace(String text, char repl, char with, int max) {
return replace(text, String.valueOf(repl), String.valueOf(with), max);
}
@@ -678,7 +667,7 @@ public class StringUtils {
* @return the text with any replacements processed
* @see #replace(String text, String repl, String with, int max)
*/
- public static String replaceOnce(@Nullable String text, @Nullable String repl, @Nullable String with) {
+ public static String replaceOnce(String text, String repl, String with) {
return replace(text, repl, with, 1);
}
@@ -693,7 +682,7 @@ public class StringUtils {
* @return the text with any replacements processed
* @see #replace(String text, String repl, String with, int max)
*/
- public static String replace(@Nullable String text, @Nullable String repl, @Nullable String with) {
+ public static String replace(String text, String repl, String with) {
return replace(text, repl, with, -1);
}
@@ -709,7 +698,7 @@ public class StringUtils {
* @param max maximum number of values to replace, or <code>-1</code> if no maximum
* @return the text with any replacements processed
*/
- public static String replace(@Nullable String text, @Nullable String repl, @Nullable String with, int max) {
+ public static String replace(String text, String repl, String with, int max) {
if ((text == null) || (repl == null) || (with == null) || (repl.length() == 0)) {
return text;
}
@@ -738,8 +727,7 @@ public class StringUtils {
* @return String with overlaid text
* @throws NullPointerException if text or overlay is <code>null</code>
*/
- @Nonnull
- public static String overlayString(@Nonnull String text, @Nonnull String overlay, int start, int end) {
+ public static String overlayString(String text, String overlay, int start, int end) {
if (overlay == null) {
throw new NullPointerException("overlay is null");
}
@@ -764,8 +752,7 @@ public class StringUtils {
* @return String containing centered String
* @throws NullPointerException if str is <code>null</code>
*/
- @Nonnull
- public static String center(@Nonnull String str, int size) {
+ public static String center(String str, int size) {
return center(str, size, " ");
}
@@ -781,8 +768,7 @@ public class StringUtils {
* @throws NullPointerException if str or delim is <code>null</code>
* @throws ArithmeticException if delim is the empty String
*/
- @Nonnull
- public static String center(@Nonnull String str, int size, @Nonnull String delim) {
+ public static String center(String str, int size, String delim) {
int sz = str.length();
int p = size - sz;
if (p < 1) {
@@ -803,8 +789,7 @@ public class StringUtils {
* @return String without chomped newline
* @throws NullPointerException if str is <code>null</code>
*/
- @Nonnull
- public static String chomp(@Nonnull String str) {
+ public static String chomp(String str) {
return chomp(str, "\n");
}
@@ -817,8 +802,7 @@ public class StringUtils {
* @return String without chomped ending
* @throws NullPointerException if str or sep is <code>null</code>
*/
- @Nonnull
- public static String chomp(@Nonnull String str, @Nonnull String sep) {
+ public static String chomp(String str, String sep) {
int idx = str.lastIndexOf(sep);
if (idx != -1) {
return str.substring(0, idx);
@@ -835,8 +819,7 @@ public class StringUtils {
* @return String without chomped ending
* @throws NullPointerException if str is <code>null</code>
*/
- @Nonnull
- public static String chompLast(@Nonnull String str) {
+ public static String chompLast(String str) {
return chompLast(str, "\n");
}
@@ -848,8 +831,7 @@ public class StringUtils {
* @return String without chomped ending
* @throws NullPointerException if str or sep is <code>null</code>
*/
- @Nonnull
- public static String chompLast(@Nonnull String str, @Nonnull String sep) {
+ public static String chompLast(String str, String sep) {
if (str.length() == 0) {
return str;
}
@@ -870,8 +852,7 @@ public class StringUtils {
* @return String chomped
* @throws NullPointerException if str or sep is <code>null</code>
*/
- @Nonnull
- public static String getChomp(@Nonnull String str, @Nonnull String sep) {
+ public static String getChomp(String str, String sep) {
int idx = str.lastIndexOf(sep);
if (idx == str.length() - sep.length()) {
return sep;
@@ -891,8 +872,7 @@ public class StringUtils {
* @return String without chomped beginning
* @throws NullPointerException if str or sep is <code>null</code>
*/
- @Nonnull
- public static String prechomp(@Nonnull String str, @Nonnull String sep) {
+ public static String prechomp(String str, String sep) {
int idx = str.indexOf(sep);
if (idx != -1) {
return str.substring(idx + sep.length());
@@ -910,8 +890,7 @@ public class StringUtils {
* @return String prechomped
* @throws NullPointerException if str or sep is <code>null</code>
*/
- @Nonnull
- public static String getPrechomp(@Nonnull String str, @Nonnull String sep) {
+ public static String getPrechomp(String str, String sep) {
int idx = str.indexOf(sep);
if (idx != -1) {
return str.substring(0, idx + sep.length());
@@ -933,8 +912,7 @@ public class StringUtils {
* @return String without last character
* @throws NullPointerException if str is <code>null</code>
*/
- @Nonnull
- public static String chop(@Nonnull String str) {
+ public static String chop(String str) {
if ("".equals(str)) {
return "";
}
@@ -960,8 +938,7 @@ public class StringUtils {
* @return String without newline
* @throws NullPointerException if str is <code>null</code>
*/
- @Nonnull
- public static String chopNewline(@Nonnull String str) {
+ public static String chopNewline(String str) {
int lastIdx = str.length() - 1;
char last = str.charAt(lastIdx);
if (last == '\n') {
@@ -989,8 +966,7 @@ public class StringUtils {
* @return String with escaped values
* @throws NullPointerException if str is <code>null</code>
*/
- @Nonnull
- public static String escape(@Nonnull String str) {
+ public static String escape(String str) {
// improved with code from cybertiger@cyberiantiger.org
// unicode from him, and defaul for < 32's.
int sz = str.length();
@@ -1074,8 +1050,7 @@ public class StringUtils {
* @throws NegativeArraySizeException if <code>repeat < 0</code>
* @throws NullPointerException if str is <code>null</code>
*/
- @Nonnull
- public static String repeat(@Nonnull String str, int repeat) {
+ public static String repeat(String str, int repeat) {
StringBuilder buffer = new StringBuilder(repeat * str.length());
for (int i = 0; i < repeat; i++) {
buffer.append(str);
@@ -1093,8 +1068,7 @@ public class StringUtils {
* @return right padded String
* @throws NullPointerException if str is <code>null</code>
*/
- @Nonnull
- public static String rightPad(@Nonnull String str, int size) {
+ public static String rightPad(String str, int size) {
return rightPad(str, size, " ");
}
@@ -1110,8 +1084,7 @@ public class StringUtils {
* @throws NullPointerException if str or delim is <code>null</code>
* @throws ArithmeticException if delim is the empty String
*/
- @Nonnull
- public static String rightPad(@Nonnull String str, int size, @Nonnull String delim) {
+ public static String rightPad(String str, int size, String delim) {
size = (size - str.length()) / delim.length();
if (size > 0) {
str += repeat(delim, size);
@@ -1129,8 +1102,7 @@ public class StringUtils {
* @return left padded String
* @throws NullPointerException if str or delim is <code>null</code>
*/
- @Nonnull
- public static String leftPad(@Nonnull String str, int size) {
+ public static String leftPad(String str, int size) {
return leftPad(str, size, " ");
}
@@ -1144,8 +1116,7 @@ public class StringUtils {
* @throws NullPointerException if str or delim is null
* @throws ArithmeticException if delim is the empty string
*/
- @Nonnull
- public static String leftPad(@Nonnull String str, int size, @Nonnull String delim) {
+ public static String leftPad(String str, int size, String delim) {
size = (size - str.length()) / delim.length();
if (size > 0) {
str = repeat(delim, size) + str;
@@ -1177,7 +1148,7 @@ public class StringUtils {
* @param delim the String to remove at start and end
* @return the stripped String
*/
- public static String strip(String str, @Nullable String delim) {
+ public static String strip(String str, String delim) {
str = stripStart(str, delim);
return stripEnd(str, delim);
}
@@ -1201,7 +1172,7 @@ public class StringUtils {
* @param delimiter the String to remove at start and end
* @return the stripped Strings
*/
- public static String[] stripAll(String[] strs, @Nullable String delimiter) {
+ public static String[] stripAll(String[] strs, String delimiter) {
if ((strs == null) || (strs.length == 0)) {
return strs;
}
@@ -1223,7 +1194,7 @@ public class StringUtils {
* @param strip the String to remove
* @return the stripped String
*/
- public static String stripEnd(String str, @Nullable String strip) {
+ public static String stripEnd(String str, String strip) {
if (str == null) {
return null;
}
@@ -1251,7 +1222,7 @@ public class StringUtils {
* @param strip the String to remove
* @return the stripped String
*/
- public static String stripStart(String str, @Nullable String strip) {
+ public static String stripStart(String str, String strip) {
if (str == null) {
return null;
}
@@ -1477,7 +1448,7 @@ public class StringUtils {
* @return the String that was nested, or <code>null</code>
* @throws NullPointerException if tag is <code>null</code>
*/
- public static String getNestedString(String str, @Nonnull String tag) {
+ public static String getNestedString(String str, String tag) {
return getNestedString(str, tag, tag);
}
@@ -1490,7 +1461,7 @@ public class StringUtils {
* @return the String that was nested, or <code>null</code>
* @throws NullPointerException if open or close is <code>null</code>
*/
- public static String getNestedString(String str, @Nonnull String open, @Nonnull String close) {
+ public static String getNestedString(String str, String open, String close) {
if (str == null) {
return null;
}
@@ -1514,7 +1485,7 @@ public class StringUtils {
* @return the number of occurrences, 0 if the String is <code>null</code>
* @throws NullPointerException if sub is <code>null</code>
*/
- public static int countMatches(@Nullable String str, @Nonnull String sub) {
+ public static int countMatches(String str, String sub) {
if (sub.equals("")) {
return 0;
}
@@ -1684,7 +1655,6 @@ public class StringUtils {
* @deprecated use {@code java.lang.Objects.toString()}
*/
@Deprecated
- @Nonnull
public static String defaultString(Object obj) {
return defaultString(obj, "");
}
@@ -1702,8 +1672,7 @@ public class StringUtils {
* @deprecated use {@code java.lang.Objects.toString()}
*/
@Deprecated
- @Nonnull
- public static String defaultString(Object obj, @Nonnull String defaultString) {
+ public static String defaultString(Object obj, String defaultString) {
return (obj == null) ? defaultString : obj.toString();
}
@@ -1736,8 +1705,7 @@ public class StringUtils {
* @param delimiter the delimiter to use
* @return the reversed String
*/
- @Nonnull
- public static String reverseDelimitedString(@Nonnull String str, String delimiter) {
+ public static String reverseDelimitedString(String str, String delimiter) {
// could implement manually, but simple way is to reuse other,
// probably slower, methods.
String[] strs = split(str, delimiter);
@@ -1750,7 +1718,7 @@ public class StringUtils {
*
* @param array the array to reverse
*/
- private static void reverseArray(@Nonnull String... array) {
+ private static void reverseArray(String... array) {
int i = 0;
int j = array.length - 1;
String tmp;
@@ -1779,8 +1747,7 @@ public class StringUtils {
* @param maxWidth maximum length of result string
* @return The abbreviated string.
*/
- @Nonnull
- public static String abbreviate(@Nonnull String s, int maxWidth) {
+ public static String abbreviate(String s, int maxWidth) {
return abbreviate(s, 0, maxWidth);
}
@@ -1799,8 +1766,7 @@ public class StringUtils {
* @param maxWidth maximum length of result string
* @return The abbreviated string.
*/
- @Nonnull
- public static String abbreviate(@Nonnull String s, int offset, int maxWidth) {
+ public static String abbreviate(String s, int offset, int maxWidth) {
if (maxWidth < 4) {
throw new IllegalArgumentException("Minimum abbreviation width is 4");
}
@@ -1840,7 +1806,7 @@ public class StringUtils {
* @param s2 The second string.
* @return the portion of s2 where it differs from s1; returns the empty string ("") if they are equal
*/
- public static String difference(@Nonnull String s1, @Nonnull String s2) {
+ public static String difference(String s1, String s2) {
int at = differenceAt(s1, s2);
if (at == -1) {
return "";
@@ -1858,7 +1824,7 @@ public class StringUtils {
* @param s2 The second string.
* @return the index where s2 and s1 begin to differ; -1 if they are equal
*/
- public static int differenceAt(@Nonnull String s1, @Nonnull String s2) {
+ public static int differenceAt(String s1, String s2) {
int i;
for (i = 0; (i < s1.length()) && (i < s2.length()); ++i) {
if (s1.charAt(i) != s2.charAt(i)) {
@@ -1880,7 +1846,7 @@ public class StringUtils {
* @param namespace The namespace which contains the replacements.
* @return the interpolated text.
*/
- public static String interpolate(String text, @Nonnull Map<?, ?> namespace) {
+ public static String interpolate(String text, Map<?, ?> namespace) {
for (Map.Entry<?, ?> entry : namespace.entrySet()) {
String key = entry.getKey().toString();
@@ -1914,8 +1880,7 @@ public class StringUtils {
* @param replaceThis The things which should be replaced.
* @return humped String
*/
- @Nonnull
- public static String removeAndHump(@Nonnull String data, @Nonnull String replaceThis) {
+ public static String removeAndHump(String data, String replaceThis) {
String temp;
StringBuilder out = new StringBuilder();
@@ -1942,8 +1907,7 @@ public class StringUtils {
* @throws NullPointerException if data is <code>null</code>
* @throws IndexOutOfBoundsException if data is empty
*/
- @Nonnull
- public static String capitalizeFirstLetter(@Nonnull String data) {
+ public static String capitalizeFirstLetter(String data) {
char firstChar = data.charAt(0);
char titleCase = Character.toTitleCase(firstChar);
if (firstChar == titleCase) {
@@ -1964,8 +1928,7 @@ public class StringUtils {
* @throws NullPointerException if data is <code>null</code>
* @throws IndexOutOfBoundsException if data is empty
*/
- @Nonnull
- public static String lowercaseFirstLetter(@Nonnull String data) {
+ public static String lowercaseFirstLetter(String data) {
char firstLetter = Character.toLowerCase(data.substring(0, 1).charAt(0));
String restLetters = data.substring(1);
@@ -1980,8 +1943,7 @@ public class StringUtils {
* @param view the view
* @return deHumped String
*/
- @Nonnull
- public static String addAndDeHump(@Nonnull String view) {
+ public static String addAndDeHump(String view) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < view.length(); i++) {
@@ -2013,7 +1975,7 @@ public class StringUtils {
* @see #quoteAndEscape(String, char, char[], char[], char, boolean)
*
*/
- public static String quoteAndEscape(@Nullable String source, char quoteChar) {
+ public static String quoteAndEscape(String source, char quoteChar) {
return quoteAndEscape(source, quoteChar, new char[] {quoteChar}, new char[] {' '}, '\\', false);
}
@@ -2027,7 +1989,7 @@ public class StringUtils {
* @see #quoteAndEscape(String, char, char[], char[], char, boolean)
*
*/
- public static String quoteAndEscape(@Nullable String source, char quoteChar, @Nonnull char[] quotingTriggers) {
+ public static String quoteAndEscape(String source, char quoteChar, char[] quotingTriggers) {
return quoteAndEscape(source, quoteChar, new char[] {quoteChar}, quotingTriggers, '\\', false);
}
@@ -2042,11 +2004,7 @@ public class StringUtils {
*
*/
public static String quoteAndEscape(
- @Nullable String source,
- char quoteChar,
- @Nonnull final char[] escapedChars,
- char escapeChar,
- boolean force) {
+ String source, char quoteChar, final char[] escapedChars, char escapeChar, boolean force) {
return quoteAndEscape(source, quoteChar, escapedChars, new char[] {' '}, escapeChar, force);
}
@@ -2060,10 +2018,10 @@ public class StringUtils {
* @return the String quoted and escaped
*/
public static String quoteAndEscape(
- @Nullable String source,
+ String source,
char quoteChar,
- @Nonnull final char[] escapedChars,
- @Nonnull final char[] quotingTriggers,
+ final char[] escapedChars,
+ final char[] quotingTriggers,
char escapeChar,
boolean force) {
if (source == null) {
@@ -2105,7 +2063,7 @@ public class StringUtils {
* @param escapeChar prefix for escaping a character
* @return the String escaped
*/
- public static String escape(@Nullable String source, @Nonnull final char[] escapedChars, char escapeChar) {
+ public static String escape(String source, final char[] escapedChars, char escapeChar) {
if (source == null) {
return null;
}
@@ -2136,8 +2094,7 @@ public class StringUtils {
* @return a string with unique whitespace
*
*/
- @Nonnull
- public static String removeDuplicateWhitespace(@Nonnull String s) {
+ public static String removeDuplicateWhitespace(String s) {
StringBuilder result = new StringBuilder();
int length = s.length();
boolean isPreviousWhiteSpace = false;
@@ -2165,7 +2122,7 @@ public class StringUtils {
* {@code StringUtils.unifyLineSeparators(s)} to simply {@code s}.
*/
@Deprecated
- public static String unifyLineSeparators(@Nullable String s) {
+ public static String unifyLineSeparators(String s) {
return unifyLineSeparators(s, System.lineSeparator());
}
@@ -2178,7 +2135,7 @@ public class StringUtils {
* @return a String that contains only System line separators
* @throws IllegalArgumentException if ls is not "\n", "\r", or "\r\n"
*/
- public static String unifyLineSeparators(@Nullable String s, @Nullable String ls) {
+ public static String unifyLineSeparators(String s, String ls) {
if (s == null) {
return null;
}
@@ -2230,7 +2187,7 @@ public class StringUtils {
* false if not or <code>null</code> string input
*
*/
- public static boolean contains(@Nullable String str, char searchChar) {
+ public static boolean contains(String str, char searchChar) {
return !isEmpty(str) && str.indexOf(searchChar) >= 0;
}
@@ -2254,7 +2211,7 @@ public class StringUtils {
* @return true if the String contains the search String,
* false if not or <code>null</code> string input
*/
- public static boolean contains(@Nullable String str, @Nullable String searchStr) {
+ public static boolean contains(String str, String searchStr) {
return !(str == null || searchStr == null) && str.contains(searchStr);
}
@@ -2277,7 +2234,7 @@ public class StringUtils {
* false if not or <code>null</code> string input
*
*/
- public static boolean endsWithIgnoreCase(@Nullable String str, @Nullable String searchStr) {
+ public static boolean endsWithIgnoreCase(String str, String searchStr) {
if (str == null || searchStr == null) {
// for consistency with contains
return false;
diff --git a/src/main/java/org/apache/maven/shared/utils/WriterFactory.java b/src/main/java/org/apache/maven/shared/utils/WriterFactory.java
index 5088914..1a2fb67 100644
--- a/src/main/java/org/apache/maven/shared/utils/WriterFactory.java
+++ b/src/main/java/org/apache/maven/shared/utils/WriterFactory.java
@@ -18,8 +18,6 @@
*/
package org.apache.maven.shared.utils;
-import javax.annotation.Nonnull;
-
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
@@ -115,7 +113,7 @@ public class WriterFactory {
* @deprecated use {@code org.apache.commons.io.input.XmlStreamWriter} instead
*/
@Deprecated
- public static XmlStreamWriter newXmlWriter(@Nonnull OutputStream out) throws IOException {
+ public static XmlStreamWriter newXmlWriter(OutputStream out) throws IOException {
return new XmlStreamWriter(out);
}
@@ -129,7 +127,7 @@ public class WriterFactory {
* @deprecated use {@code org.apache.commons.io.input.XmlStreamWriter} instead
*/
@Deprecated
- public static XmlStreamWriter newXmlWriter(@Nonnull File file) throws IOException {
+ public static XmlStreamWriter newXmlWriter(File file) throws IOException {
return new XmlStreamWriter(file);
}
@@ -141,7 +139,7 @@ public class WriterFactory {
* @deprecated always specify an encoding. Do not depend on the default platform character set.
*/
@Deprecated
- public static Writer newPlatformWriter(@Nonnull OutputStream out) {
+ public static Writer newPlatformWriter(OutputStream out) {
return new OutputStreamWriter(out);
}
@@ -154,7 +152,7 @@ public class WriterFactory {
* @deprecated always specify an encoding. Do not depend on the default platform character set.
*/
@Deprecated
- public static Writer newPlatformWriter(@Nonnull File file) throws IOException {
+ public static Writer newPlatformWriter(File file) throws IOException {
return new FileWriter(file);
}
@@ -171,8 +169,7 @@ public class WriterFactory {
* @deprecated use {@code new OutputStreamWriter(out, encoding)} instead
*/
@Deprecated
- public static Writer newWriter(@Nonnull OutputStream out, @Nonnull String encoding)
- throws UnsupportedEncodingException {
+ public static Writer newWriter(OutputStream out, String encoding) throws UnsupportedEncodingException {
return new OutputStreamWriter(out, encoding);
}
@@ -190,7 +187,7 @@ public class WriterFactory {
* @deprecated use {@code java.nio.file.Files.newBufferedWriter()} instead
*/
@Deprecated
- public static Writer newWriter(@Nonnull File file, @Nonnull String encoding)
+ public static Writer newWriter(File file, String encoding)
throws UnsupportedEncodingException, FileNotFoundException {
return newWriter(new FileOutputStream(file), encoding);
}
diff --git a/src/main/java/org/apache/maven/shared/utils/cli/CommandLineUtils.java b/src/main/java/org/apache/maven/shared/utils/cli/CommandLineUtils.java
index 04f5cd6..a702296 100644
--- a/src/main/java/org/apache/maven/shared/utils/cli/CommandLineUtils.java
+++ b/src/main/java/org/apache/maven/shared/utils/cli/CommandLineUtils.java
@@ -18,9 +18,6 @@
*/
package org.apache.maven.shared.utils.cli;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.ArrayList;
@@ -73,7 +70,7 @@ public abstract class CommandLineUtils {
* @return return code.
* @throws CommandLineException in case of a problem.
*/
- public static int executeCommandLine(@Nonnull Commandline cl, StreamConsumer systemOut, StreamConsumer systemErr)
+ public static int executeCommandLine(Commandline cl, StreamConsumer systemOut, StreamConsumer systemErr)
throws CommandLineException {
return executeCommandLine(cl, null, systemOut, systemErr, 0);
}
@@ -87,7 +84,7 @@ public abstract class CommandLineUtils {
* @throws CommandLineException in case of a problem.
*/
public static int executeCommandLine(
- @Nonnull Commandline cl, StreamConsumer systemOut, StreamConsumer systemErr, int timeoutInSeconds)
+ Commandline cl, StreamConsumer systemOut, StreamConsumer systemErr, int timeoutInSeconds)
throws CommandLineException {
return executeCommandLine(cl, null, systemOut, systemErr, timeoutInSeconds);
}
@@ -101,7 +98,7 @@ public abstract class CommandLineUtils {
* @throws CommandLineException in case of a problem.
*/
public static int executeCommandLine(
- @Nonnull Commandline cl, InputStream systemIn, StreamConsumer systemOut, StreamConsumer systemErr)
+ Commandline cl, InputStream systemIn, StreamConsumer systemOut, StreamConsumer systemErr)
throws CommandLineException {
return executeCommandLine(cl, systemIn, systemOut, systemErr, 0);
}
@@ -116,7 +113,7 @@ public abstract class CommandLineUtils {
* @throws CommandLineException or CommandLineTimeOutException if time out occurs
*/
public static int executeCommandLine(
- @Nonnull Commandline cl,
+ Commandline cl,
InputStream systemIn,
StreamConsumer systemOut,
StreamConsumer systemErr,
@@ -137,12 +134,12 @@ public abstract class CommandLineUtils {
* @throws CommandLineException or CommandLineTimeOutException if time out occurs
*/
public static int executeCommandLine(
- @Nonnull Commandline cl,
+ Commandline cl,
InputStream systemIn,
StreamConsumer systemOut,
StreamConsumer systemErr,
int timeoutInSeconds,
- @Nullable Runnable runAfterProcessTermination)
+ Runnable runAfterProcessTermination)
throws CommandLineException {
return executeCommandLine(
cl, systemIn, systemOut, systemErr, timeoutInSeconds, runAfterProcessTermination, null);
@@ -161,13 +158,13 @@ public abstract class CommandLineUtils {
* @throws CommandLineException or CommandLineTimeOutException if time out occurs
*/
public static int executeCommandLine(
- @Nonnull Commandline cl,
+ Commandline cl,
InputStream systemIn,
StreamConsumer systemOut,
StreamConsumer systemErr,
int timeoutInSeconds,
- @Nullable Runnable runAfterProcessTermination,
- @Nullable final Charset streamCharset)
+ Runnable runAfterProcessTermination,
+ final Charset streamCharset)
throws CommandLineException {
final CommandLineCallable future = executeCommandLineAsCallable(
cl, systemIn, systemOut, systemErr, timeoutInSeconds, runAfterProcessTermination, streamCharset);
@@ -189,12 +186,12 @@ public abstract class CommandLineUtils {
* @throws CommandLineException or CommandLineTimeOutException if time out occurs
*/
public static CommandLineCallable executeCommandLineAsCallable(
- @Nonnull final Commandline cl,
- @Nullable final InputStream systemIn,
+ final Commandline cl,
+ final InputStream systemIn,
final StreamConsumer systemOut,
final StreamConsumer systemErr,
final int timeoutInSeconds,
- @Nullable final Runnable runAfterProcessTermination)
+ final Runnable runAfterProcessTermination)
throws CommandLineException {
return executeCommandLineAsCallable(
cl, systemIn, systemOut, systemErr, timeoutInSeconds, runAfterProcessTermination, null);
@@ -216,13 +213,13 @@ public abstract class CommandLineUtils {
* @throws CommandLineException or CommandLineTimeOutException if time out occurs
*/
public static CommandLineCallable executeCommandLineAsCallable(
- @Nonnull final Commandline cl,
- @Nullable final InputStream systemIn,
+ final Commandline cl,
+ final InputStream systemIn,
final StreamConsumer systemOut,
final StreamConsumer systemErr,
final int timeoutInSeconds,
- @Nullable final Runnable runAfterProcessTermination,
- @Nullable final Charset streamCharset)
+ final Runnable runAfterProcessTermination,
+ final Charset streamCharset)
throws CommandLineException {
//noinspection ConstantConditions
if (cl == null) {
diff --git a/src/main/java/org/apache/maven/shared/utils/cli/StreamPumper.java b/src/main/java/org/apache/maven/shared/utils/cli/StreamPumper.java
index 03a79ca..bfa59cb 100644
--- a/src/main/java/org/apache/maven/shared/utils/cli/StreamPumper.java
+++ b/src/main/java/org/apache/maven/shared/utils/cli/StreamPumper.java
@@ -18,8 +18,6 @@
*/
package org.apache.maven.shared.utils.cli;
-import javax.annotation.Nullable;
-
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@@ -55,7 +53,7 @@ public class StreamPumper extends AbstractStreamHandler {
* @param consumer {@link StreamConsumer}
* @param charset {@link Charset}
*/
- public StreamPumper(InputStream in, StreamConsumer consumer, @Nullable Charset charset) {
+ public StreamPumper(InputStream in, StreamConsumer consumer, Charset charset) {
this(null == charset ? new InputStreamReader(in) : new InputStreamReader(in, charset), consumer);
}
diff --git a/src/main/java/org/apache/maven/shared/utils/introspection/ReflectionValueExtractor.java b/src/main/java/org/apache/maven/shared/utils/introspection/ReflectionValueExtractor.java
index 1c6965e..ee518a5 100644
--- a/src/main/java/org/apache/maven/shared/utils/introspection/ReflectionValueExtractor.java
+++ b/src/main/java/org/apache/maven/shared/utils/introspection/ReflectionValueExtractor.java
@@ -18,9 +18,6 @@
*/
package org.apache.maven.shared.utils.introspection;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -141,7 +138,7 @@ public class ReflectionValueExtractor {
* @return the object defined by the expression
* @throws IntrospectionException if any
*/
- public static Object evaluate(@Nonnull String expression, @Nullable Object root) throws IntrospectionException {
+ public static Object evaluate(String expression, Object root) throws IntrospectionException {
return evaluate(expression, root, true);
}
@@ -163,8 +160,7 @@ public class ReflectionValueExtractor {
* @return the object defined by the expression
* @throws IntrospectionException if any
*/
- public static Object evaluate(@Nonnull String expression, @Nullable Object root, boolean trimRootToken)
- throws IntrospectionException {
+ public static Object evaluate(String expression, Object root, boolean trimRootToken) throws IntrospectionException {
Object value = root;
// ----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/maven/shared/utils/io/DirectoryScanner.java b/src/main/java/org/apache/maven/shared/utils/io/DirectoryScanner.java
index aad7a01..0233c23 100644
--- a/src/main/java/org/apache/maven/shared/utils/io/DirectoryScanner.java
+++ b/src/main/java/org/apache/maven/shared/utils/io/DirectoryScanner.java
@@ -18,9 +18,6 @@
*/
package org.apache.maven.shared.utils.io;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
import java.io.File;
import java.nio.file.Files;
import java.util.ArrayList;
@@ -279,7 +276,7 @@ public class DirectoryScanner {
*
* @param basedir The base directory for scanning. Should not be <code>null</code>.
*/
- public void setBasedir(@Nonnull final File basedir) {
+ public void setBasedir(final File basedir) {
this.basedir = basedir;
}
@@ -462,7 +459,7 @@ public class DirectoryScanner {
* @param newFiles array of new files
* @return calculated difference
*/
- public static DirectoryScanResult diffFiles(@Nullable String[] oldFiles, @Nullable String[] newFiles) {
+ public static DirectoryScanResult diffFiles(String[] oldFiles, String[] newFiles) {
Set<String> oldFileSet = arrayAsHashSet(oldFiles);
Set<String> newFileSet = arrayAsHashSet(newFiles);
@@ -494,7 +491,7 @@ public class DirectoryScanner {
* @param array The array
* @return the filled HashSet of type T
*/
- private static <T> Set<T> arrayAsHashSet(@Nullable T[] array) {
+ private static <T> Set<T> arrayAsHashSet(T[] array) {
if (array == null || array.length == 0) {
return Collections.emptySet();
}
@@ -553,7 +550,7 @@ public class DirectoryScanner {
* @see #dirsExcluded
* @see #slowScan
*/
- private void scandir(@Nonnull final File dir, @Nonnull final String vpath, final boolean fast) {
+ private void scandir(final File dir, final String vpath, final boolean fast) {
String[] newfiles = dir.list();
if (newfiles == null) {
@@ -698,7 +695,7 @@ public class DirectoryScanner {
* @return <code>true</code> when the name matches against the start of at least one include pattern, or
* <code>false</code> otherwise.
*/
- private boolean couldHoldIncluded(@Nonnull final String name) {
+ private boolean couldHoldIncluded(final String name) {
return includesPatterns.matchesPatternStart(name, isCaseSensitive);
}
@@ -709,7 +706,7 @@ public class DirectoryScanner {
* @return <code>true</code> when the name matches against at least one exclude pattern, or <code>false</code>
* otherwise.
*/
- private boolean isExcluded(@Nonnull final String name) {
+ private boolean isExcluded(final String name) {
return excludesPatterns.matches(name, isCaseSensitive);
}
diff --git a/src/main/java/org/apache/maven/shared/utils/io/FileUtils.java b/src/main/java/org/apache/maven/shared/utils/io/FileUtils.java
index 1996e0b..9492af2 100644
--- a/src/main/java/org/apache/maven/shared/utils/io/FileUtils.java
+++ b/src/main/java/org/apache/maven/shared/utils/io/FileUtils.java
@@ -18,10 +18,6 @@
*/
package org.apache.maven.shared.utils.io;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-import javax.annotation.WillClose;
-
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
@@ -131,7 +127,6 @@ public class FileUtils {
* @return the default excludes pattern
* @see DirectoryScanner#DEFAULTEXCLUDES
*/
- @Nonnull
public static String[] getDefaultExcludes() {
return DirectoryScanner.DEFAULTEXCLUDES;
}
@@ -140,7 +135,6 @@ public class FileUtils {
* @return the default excludes pattern as list
* @see #getDefaultExcludes()
*/
- @Nonnull
public static List<String> getDefaultExcludesAsList() {
return Arrays.asList(getDefaultExcludes());
}
@@ -150,7 +144,6 @@ public class FileUtils {
* @see DirectoryScanner#DEFAULTEXCLUDES
* @see StringUtils#join(Object[], String)
*/
- @Nonnull
public static String getDefaultExcludesAsString() {
return StringUtils.join(DirectoryScanner.DEFAULTEXCLUDES, ",");
}
@@ -164,8 +157,7 @@ public class FileUtils {
* @deprecated use {@code Paths.get(path).getParent().getName()}
*/
@Deprecated
- @Nonnull
- public static String dirname(@Nonnull String path) {
+ public static String dirname(String path) {
int i = path.lastIndexOf(File.separator);
return (i >= 0 ? path.substring(0, i) : "");
}
@@ -178,8 +170,7 @@ public class FileUtils {
* @deprecated use {@code Paths.get(path).getName()}
*/
@Deprecated
- @Nonnull
- public static String filename(@Nonnull String path) {
+ public static String filename(String path) {
int i = path.lastIndexOf(File.separator);
return (i >= 0 ? path.substring(i + 1) : path);
}
@@ -193,8 +184,7 @@ public class FileUtils {
* @deprecated use {@code org.apache.commons.io.FilenameUtils.getExtension}
*/
@Deprecated
- @Nonnull
- public static String extension(@Nonnull String path) {
+ public static String extension(String path) {
// Ensure the last dot is after the last file separator
int lastSep = path.lastIndexOf(File.separatorChar);
int lastDot;
@@ -222,7 +212,7 @@ public class FileUtils {
* @deprecated use {@code java.io.File.exists()}
*/
@Deprecated
- public static boolean fileExists(@Nonnull String fileName) {
+ public static boolean fileExists(String fileName) {
File file = new File(fileName);
return file.exists();
}
@@ -236,8 +226,7 @@ public class FileUtils {
* @deprecated use {@code new String(java.nio.files.Files.readAllBytes(file))}
*/
@Deprecated
- @Nonnull
- public static String fileRead(@Nonnull String file) throws IOException {
+ public static String fileRead(String file) throws IOException {
return fileRead(file, null);
}
@@ -249,8 +238,7 @@ public class FileUtils {
* @deprecated use {@code new String(java.nio.files.Files.readAllBytes(Paths.get(file)), encoding)}
*/
@Deprecated
- @Nonnull
- private static String fileRead(@Nonnull String file, @Nullable String encoding) throws IOException {
+ private static String fileRead(String file, String encoding) throws IOException {
return fileRead(new File(file), encoding);
}
@@ -263,8 +251,7 @@ public class FileUtils {
* @deprecated use {@code new String(java.nio.files.Files.readAllBytes(file.toPath()))}
*/
@Deprecated
- @Nonnull
- public static String fileRead(@Nonnull File file) throws IOException {
+ public static String fileRead(File file) throws IOException {
return fileRead(file, null);
}
@@ -276,8 +263,7 @@ public class FileUtils {
* @deprecated use {@code new String(java.nio.files.Files.readAllBytes(file.toPath()), encoding)}
*/
@Deprecated
- @Nonnull
- public static String fileRead(@Nonnull File file, @Nullable String encoding) throws IOException {
+ public static String fileRead(File file, String encoding) throws IOException {
Charset charset = charset(encoding);
StringBuilder buf = new StringBuilder();
@@ -302,8 +288,7 @@ public class FileUtils {
* @deprecated use {@code java.nio.files.Files.readAllLines()}
*/
@Deprecated
- @Nonnull
- public static String[] fileReadArray(@Nonnull File file) throws IOException {
+ public static String[] fileReadArray(File file) throws IOException {
List<String> lines = loadFile(file);
return lines.toArray(new String[lines.size()]);
@@ -320,7 +305,7 @@ public class FileUtils {
* StandardOpenOption.APPEND, StandardOpenOption.CREATE)}
*/
@Deprecated
- public static void fileAppend(@Nonnull String fileName, @Nonnull String data) throws IOException {
+ public static void fileAppend(String fileName, String data) throws IOException {
fileAppend(fileName, null, data);
}
@@ -335,8 +320,7 @@ public class FileUtils {
* StandardOpenOption.APPEND, StandardOpenOption.CREATE)}
*/
@Deprecated
- public static void fileAppend(@Nonnull String fileName, @Nullable String encoding, @Nonnull String data)
- throws IOException {
+ public static void fileAppend(String fileName, String encoding, String data) throws IOException {
Charset charset = charset(encoding);
try (OutputStream out = new FileOutputStream(fileName, true)) {
@@ -355,7 +339,7 @@ public class FileUtils {
* data.getBytes(), StandardOpenOption.CREATE)}
*/
@Deprecated
- public static void fileWrite(@Nonnull String fileName, @Nonnull String data) throws IOException {
+ public static void fileWrite(String fileName, String data) throws IOException {
fileWrite(fileName, null, data);
}
@@ -370,8 +354,7 @@ public class FileUtils {
* data.getBytes(encoding), StandardOpenOption.CREATE)}
*/
@Deprecated
- public static void fileWrite(@Nonnull String fileName, @Nullable String encoding, @Nonnull String data)
- throws IOException {
+ public static void fileWrite(String fileName, String encoding, String data) throws IOException {
File file = new File(fileName);
fileWrite(file, encoding, data);
}
@@ -387,8 +370,7 @@ public class FileUtils {
* data.getBytes(encoding), StandardOpenOption.CREATE)}
*/
@Deprecated
- public static void fileWrite(@Nonnull File file, @Nullable String encoding, @Nonnull String data)
- throws IOException {
+ public static void fileWrite(File file, String encoding, String data) throws IOException {
Charset charset = charset(encoding);
try (Writer writer = Files.newBufferedWriter(file.toPath(), charset)) {
@@ -407,7 +389,7 @@ public class FileUtils {
* data.getBytes(encoding), StandardOpenOption.CREATE)}
*/
@Deprecated
- public static void fileWriteArray(@Nonnull File file, @Nullable String... data) throws IOException {
+ public static void fileWriteArray(File file, String... data) throws IOException {
fileWriteArray(file, null, data);
}
@@ -422,8 +404,7 @@ public class FileUtils {
* data.getBytes(encoding), StandardOpenOption.CREATE)}
*/
@Deprecated
- public static void fileWriteArray(@Nonnull File file, @Nullable String encoding, @Nullable String... data)
- throws IOException {
+ public static void fileWriteArray(File file, String encoding, String... data) throws IOException {
Charset charset = charset(encoding);
try (Writer writer = Files.newBufferedWriter(file.toPath(), charset)) {
@@ -441,7 +422,7 @@ public class FileUtils {
* @deprecated use {@code Files.delete(Paths.get(fileName))}
*/
@Deprecated
- public static void fileDelete(@Nonnull String fileName) {
+ public static void fileDelete(String fileName) {
File file = new File(fileName);
deleteLegacyStyle(file);
}
@@ -455,7 +436,7 @@ public class FileUtils {
* @param extensions an array of expected extensions
* @return an array of files for the wanted extensions
*/
- public static String[] getFilesFromExtension(@Nonnull String directory, @Nonnull String... extensions) {
+ public static String[] getFilesFromExtension(String directory, String... extensions) {
List<String> files = new ArrayList<>();
File currentDir = new File(directory);
@@ -501,8 +482,7 @@ public class FileUtils {
/**
* Private helper method for getFilesFromExtension()
*/
- @Nonnull
- private static List<String> blendFilesToList(@Nonnull List<String> v, @Nonnull String... files) {
+ private static List<String> blendFilesToList(List<String> v, String... files) {
Collections.addAll(v, files);
return v;
@@ -513,7 +493,7 @@ public class FileUtils {
* Note that if the file does not have an extension, an empty string
* ("") is matched for.
*/
- private static boolean isValidFile(@Nonnull String file, @Nonnull String... extensions) {
+ private static boolean isValidFile(String file, String... extensions) {
String extension = extension(file);
// ok.. now that we have the "extension" go through the current know
@@ -537,7 +517,7 @@ public class FileUtils {
* @deprecated use {@code java.nio.file.Files.createDirectories(Paths.get(dir))}
*/
@Deprecated
- public static void mkdir(@Nonnull String dir) {
+ public static void mkdir(String dir) {
File file = new File(dir);
if (Os.isFamily(Os.FAMILY_WINDOWS) && !isValidWindowsFileName(file)) {
@@ -562,7 +542,7 @@ public class FileUtils {
* @deprecated use {@code org.apache.commons.io.FileUtils.contentEquals()}
*/
@Deprecated
- public static boolean contentEquals(@Nonnull final File file1, @Nonnull final File file2) throws IOException {
+ public static boolean contentEquals(final File file1, final File file2) throws IOException {
final boolean file1Exists = file1.exists();
if (file1Exists != file2.exists()) {
return false;
@@ -591,8 +571,7 @@ public class FileUtils {
* @return the equivalent <code>File</code> object, or <code>null</code> if the URL's protocol
* is not <code>file</code>
*/
- @Nullable
- public static File toFile(@Nullable final URL url) {
+ public static File toFile(final URL url) {
if (url == null || !url.getProtocol().equalsIgnoreCase("file")) {
return null;
}
@@ -616,8 +595,7 @@ public class FileUtils {
* @return the array of URLs
* @throws IOException if an error occurs
*/
- @Nonnull
- public static URL[] toURLs(@Nonnull final File... files) throws IOException {
+ public static URL[] toURLs(final File... files) throws IOException {
final URL[] urls = new URL[files.length];
for (int i = 0; i < urls.length; i++) {
@@ -640,8 +618,7 @@ public class FileUtils {
* @deprecated use {@code org.apache.commons.io.FilenameUtils.removeExtension()}
*/
@Deprecated
- @Nonnull
- public static String removeExtension(@Nonnull final String filename) {
+ public static String removeExtension(final String filename) {
String ext = extension(filename);
if ("".equals(ext)) {
@@ -666,8 +643,7 @@ public class FileUtils {
* @deprecated use {@code org.apache.commons.io.FilenameUtils.getExtension()}
*/
@Deprecated
- @Nonnull
- public static String getExtension(@Nonnull final String filename) {
+ public static String getExtension(final String filename) {
return extension(filename);
}
@@ -686,8 +662,7 @@ public class FileUtils {
* @deprecated use {@code org.apache.commons.io.FileUtils.copyFileToDirectory()}
*/
@Deprecated
- public static void copyFileToDirectory(@Nonnull final File source, @Nonnull final File destinationDirectory)
- throws IOException {
+ public static void copyFileToDirectory(final File source, final File destinationDirectory) throws IOException {
if (destinationDirectory.exists() && !destinationDirectory.isDirectory()) {
throw new IOException("Destination is not a directory");
}
@@ -709,8 +684,8 @@ public class FileUtils {
* <code>destinationDirectory</code> cannot be written to, or an IO error
* occurs during copying
*/
- private static void copyFileToDirectoryIfModified(
- @Nonnull final File source, @Nonnull final File destinationDirectory) throws IOException {
+ private static void copyFileToDirectoryIfModified(final File source, final File destinationDirectory)
+ throws IOException {
if (destinationDirectory.exists() && !destinationDirectory.isDirectory()) {
throw new IllegalArgumentException("Destination is not a directory");
}
@@ -733,7 +708,7 @@ public class FileUtils {
* StandardCopyOption.REPLACE_EXISTING)}
*/
@Deprecated
- public static void copyFile(@Nonnull final File source, @Nonnull final File destination) throws IOException {
+ public static void copyFile(final File source, final File destination) throws IOException {
// check source exists
if (!source.exists()) {
final String message = "File " + source + " does not exist";
@@ -761,7 +736,7 @@ public class FileUtils {
}
}
- private static void mkdirsFor(@Nonnull File destination) {
+ private static void mkdirsFor(File destination) {
// does destination directory exist ?
if (destination.getParentFile() != null && !destination.getParentFile().exists()) {
//noinspection ResultOfMethodCallIgnored
@@ -769,7 +744,7 @@ public class FileUtils {
}
}
- private static void doCopyFile(@Nonnull File source, @Nonnull File destination) throws IOException {
+ private static void doCopyFile(File source, File destination) throws IOException {
try (FileInputStream fis = new FileInputStream(source);
FileOutputStream fos = new FileOutputStream(destination);
@@ -800,8 +775,7 @@ public class FileUtils {
* @throws IOException if <code>source</code> does not exist, <code>destination</code> cannot be
* written to, or an IO error occurs during copying.
*/
- private static boolean copyFileIfModified(@Nonnull final File source, @Nonnull final File destination)
- throws IOException {
+ private static boolean copyFileIfModified(final File source, final File destination) throws IOException {
if (destination.lastModified() < source.lastModified()) {
copyFile(source, destination);
@@ -828,7 +802,7 @@ public class FileUtils {
* @deprecated use {@code java.nio.Files.copy(source.openStream(), destination.toPath(),
* StandardCopyOption.REPLACE_EXISTING)}
*/
- public static void copyURLToFile(@Nonnull final URL source, @Nonnull final File destination) throws IOException {
+ public static void copyURLToFile(final URL source, final File destination) throws IOException {
copyStreamToFile(source.openStream(), destination);
}
@@ -851,8 +825,7 @@ public class FileUtils {
* StandardCopyOption.REPLACE_EXISTING)}
*/
@Deprecated
- private static void copyStreamToFile(@Nonnull @WillClose final InputStream source, @Nonnull final File destination)
- throws IOException {
+ private static void copyStreamToFile(final InputStream source, final File destination) throws IOException {
// does destination directory exist ?
if (destination.getParentFile() != null && !destination.getParentFile().exists()) {
// noinspection ResultOfMethodCallIgnored
@@ -891,8 +864,7 @@ public class FileUtils {
* @deprecated use {@code org.apache.commons.io.FileNameUtils.normalize()}
*/
@Deprecated
- @Nonnull
- public static String normalize(@Nonnull final String path) {
+ public static String normalize(final String path) {
String normalized = path;
// Resolve occurrences of "//" in the normalized path
while (true) {
@@ -938,8 +910,7 @@ public class FileUtils {
* @param filename absolute or relative file path to resolve
* @return the canonical <code>File</code> of <code>filename</code>
*/
- @Nonnull
- public static File resolveFile(final File baseFile, @Nonnull String filename) {
+ public static File resolveFile(final File baseFile, String filename) {
String filenm = filename;
if ('/' != File.separatorChar) {
filenm = filename.replace('/', File.separatorChar);
@@ -1005,7 +976,7 @@ public class FileUtils {
* @deprecated use {@code org.apache.commons.io.FileUtils.deleteQuietly()}
*/
@Deprecated
- public static void forceDelete(@Nonnull final String file) throws IOException {
+ public static void forceDelete(final String file) throws IOException {
forceDelete(new File(file));
}
@@ -1017,7 +988,7 @@ public class FileUtils {
* @deprecated use {@code org.apache.commons.io.FileUtils.deleteQuietly()}
*/
@Deprecated
- public static void forceDelete(@Nonnull final File file) throws IOException {
+ public static void forceDelete(final File file) throws IOException {
if (file.isDirectory()) {
deleteDirectory(file);
} else {
@@ -1041,7 +1012,7 @@ public class FileUtils {
* @deprecated use {@code java.nio.files.Files.delete(file.toPath())}
*/
@Deprecated
- public static void delete(@Nonnull File file) throws IOException {
+ public static void delete(File file) throws IOException {
Files.delete(file.toPath());
}
@@ -1051,7 +1022,7 @@ public class FileUtils {
* @deprecated use {@code java.nio.files.Files.delete(file.toPath())}
*/
@Deprecated
- public static boolean deleteLegacyStyle(@Nonnull File file) {
+ public static boolean deleteLegacyStyle(File file) {
try {
Files.delete(file.toPath());
return true;
@@ -1068,7 +1039,7 @@ public class FileUtils {
* @param file a file
* @throws IOException if any
*/
- private static boolean deleteFile(@Nonnull File file) throws IOException {
+ private static boolean deleteFile(File file) throws IOException {
if (file.isDirectory()) {
throw new IOException("File " + file + " isn't a file.");
}
@@ -1099,7 +1070,7 @@ public class FileUtils {
* @deprecated use {@code org.apache.commons.io.FileUtils.forceMkdir()}
*/
@Deprecated
- public static void forceMkdir(@Nonnull final File file) throws IOException {
+ public static void forceMkdir(final File file) throws IOException {
if (Os.isFamily(Os.FAMILY_WINDOWS) && !isValidWindowsFileName(file)) {
throw new IllegalArgumentException(
"The file (" + file.getAbsolutePath() + ") cannot contain any of the following characters: \n"
@@ -1128,7 +1099,7 @@ public class FileUtils {
* @deprecated use {@code org.apache.commons.io.FileUtils.deleteDirectory()}
*/
@Deprecated
- public static void deleteDirectory(@Nonnull final String directory) throws IOException {
+ public static void deleteDirectory(final String directory) throws IOException {
deleteDirectory(new File(directory));
}
@@ -1140,7 +1111,7 @@ public class FileUtils {
* @deprecated use {@code org.apache.commons.io.FileUtils.deleteDirectory()}
*/
@Deprecated
- public static void deleteDirectory(@Nonnull final File directory) throws IOException {
+ public static void deleteDirectory(final File directory) throws IOException {
if (!directory.exists()) {
return;
}
@@ -1168,7 +1139,7 @@ public class FileUtils {
* @deprecated use {@code org.apache.commons.io.FileUtils.cleanDirectory()}
*/
@Deprecated
- public static void cleanDirectory(@Nonnull final File directory) throws IOException {
+ public static void cleanDirectory(final File directory) throws IOException {
if (!directory.exists()) {
final String message = directory + " does not exist";
throw new IllegalArgumentException(message);
@@ -1208,7 +1179,7 @@ public class FileUtils {
* @deprecated use {@code org.apache.commons.io.FileUtils.sizeOf()}
*/
@Deprecated
- public static long sizeOfDirectory(@Nonnull final String directory) {
+ public static long sizeOfDirectory(final String directory) {
return sizeOfDirectory(new File(directory));
}
@@ -1220,7 +1191,7 @@ public class FileUtils {
* @deprecated use {@code org.apache.commons.io.FileUtils.sizeOf()}
*/
@Deprecated
- public static long sizeOfDirectory(@Nonnull final File directory) {
+ public static long sizeOfDirectory(final File directory) {
if (!directory.exists()) {
final String message = directory + " does not exist";
throw new IllegalArgumentException(message);
@@ -1262,9 +1233,7 @@ public class FileUtils {
* @see #getFileNames(File, String, String, boolean)
* @throws IOException never
*/
- @Nonnull
- public static List<File> getFiles(@Nonnull File directory, @Nullable String includes, @Nullable String excludes)
- throws IOException {
+ public static List<File> getFiles(File directory, String includes, String excludes) throws IOException {
return getFiles(directory, includes, excludes, true);
}
@@ -1283,9 +1252,7 @@ public class FileUtils {
* @throws IOException never
* @see #getFileNames(File, String, String, boolean)
*/
- @Nonnull
- public static List<File> getFiles(
- @Nonnull File directory, @Nullable String includes, @Nullable String excludes, boolean includeBasedir)
+ public static List<File> getFiles(File directory, String includes, String excludes, boolean includeBasedir)
throws IOException {
List<String> fileNames = getFileNames(directory, includes, excludes, includeBasedir);
@@ -1311,9 +1278,7 @@ public class FileUtils {
* @return a list of file names
* @throws IOException never
*/
- @Nonnull
- public static List<String> getFileNames(
- @Nonnull File directory, @Nullable String includes, @Nullable String excludes, boolean includeBasedir)
+ public static List<String> getFileNames(File directory, String includes, String excludes, boolean includeBasedir)
throws IOException {
return getFileNames(directory, includes, excludes, includeBasedir, true);
}
@@ -1331,13 +1296,8 @@ public class FileUtils {
* @param includeBasedir true to include the base directory at the start of each path
* @return a list of relative paths of files
*/
- @Nonnull
private static List<String> getFileNames(
- @Nonnull File directory,
- @Nullable String includes,
- @Nullable String excludes,
- boolean includeBasedir,
- boolean isCaseSensitive) {
+ File directory, String includes, String excludes, boolean includeBasedir, boolean isCaseSensitive) {
return getFileAndDirectoryNames(directory, includes, excludes, includeBasedir, isCaseSensitive, true, false);
}
@@ -1353,10 +1313,8 @@ public class FileUtils {
* @return a list of relative paths of directories
* @throws IOException never
*/
- @Nonnull
public static List<String> getDirectoryNames(
- @Nonnull File directory, @Nullable String includes, @Nullable String excludes, boolean includeBasedir)
- throws IOException {
+ File directory, String includes, String excludes, boolean includeBasedir) throws IOException {
return getDirectoryNames(directory, includes, excludes, includeBasedir, true);
}
@@ -1372,13 +1330,8 @@ public class FileUtils {
* @return a list of relative paths of directories
* @throws IOException never
*/
- @Nonnull
public static List<String> getDirectoryNames(
- @Nonnull File directory,
- @Nullable String includes,
- @Nullable String excludes,
- boolean includeBasedir,
- boolean isCaseSensitive)
+ File directory, String includes, String excludes, boolean includeBasedir, boolean isCaseSensitive)
throws IOException {
return getFileAndDirectoryNames(directory, includes, excludes, includeBasedir, isCaseSensitive, false, true);
}
@@ -1396,11 +1349,10 @@ public class FileUtils {
* @param getDirectories true to include directories in the list
* @return a list of relative paths
*/
- @Nonnull
public static List<String> getFileAndDirectoryNames(
File directory,
- @Nullable String includes,
- @Nullable String excludes,
+ String includes,
+ String excludes,
boolean includeBasedir,
boolean isCaseSensitive,
boolean getFiles,
@@ -1460,8 +1412,7 @@ public class FileUtils {
* @deprecated use {@code org.apache.commons.io.FileUtils.copyDirectory()}
*/
@Deprecated
- public static void copyDirectory(@Nonnull File sourceDirectory, @Nonnull File destinationDirectory)
- throws IOException {
+ public static void copyDirectory(File sourceDirectory, File destinationDirectory) throws IOException {
Objects.requireNonNull(sourceDirectory);
Objects.requireNonNull(destinationDirectory);
if (destinationDirectory.equals(sourceDirectory)) {
@@ -1486,11 +1437,7 @@ public class FileUtils {
* @deprecated use {@code org.apache.commons.io.FileUtils.copyDirectory()}
*/
@Deprecated
- public static void copyDirectory(
- @Nonnull File sourceDirectory,
- @Nonnull File destinationDirectory,
- @Nullable String includes,
- @Nullable String excludes)
+ public static void copyDirectory(File sourceDirectory, File destinationDirectory, String includes, String excludes)
throws IOException {
if (!sourceDirectory.exists()) {
return;
@@ -1519,16 +1466,12 @@ public class FileUtils {
* @deprecated use {@code org.apache.commons.io.FileUtils.copyDirectory()}
*/
@Deprecated
- public static void copyDirectoryStructure(@Nonnull File sourceDirectory, @Nonnull File destinationDirectory)
- throws IOException {
+ public static void copyDirectoryStructure(File sourceDirectory, File destinationDirectory) throws IOException {
copyDirectoryStructure(sourceDirectory, destinationDirectory, destinationDirectory, false);
}
private static void copyDirectoryStructure(
- @Nonnull File sourceDirectory,
- @Nonnull File destinationDirectory,
- File rootDestinationDirectory,
- boolean onlyModifiedFiles)
+ File sourceDirectory, File destinationDirectory, File rootDestinationDirectory, boolean onlyModifiedFiles)
throws IOException {
//noinspection ConstantConditions
if (sourceDirectory == null) {
@@ -1603,7 +1546,7 @@ public class FileUtils {
* @deprecated use {@code java.nio.Files.move()}
*/
@Deprecated
- public static void rename(@Nonnull File from, @Nonnull File to) throws IOException {
+ public static void rename(File from, File to) throws IOException {
if (to.exists() && !deleteLegacyStyle(to)) {
throw new IOException("Failed to delete " + to + " while trying to rename " + from);
}
@@ -1644,7 +1587,7 @@ public class FileUtils {
* @deprecated use {@code java.nio.Files.createTempFile()}
*/
@Deprecated
- public static File createTempFile(@Nonnull String prefix, @Nonnull String suffix, @Nullable File parentDir) {
+ public static File createTempFile(String prefix, String suffix, File parentDir) {
File result;
String parent = System.getProperty("java.io.tmpdir");
if (parentDir != null) {
@@ -1680,9 +1623,7 @@ public class FileUtils {
* @deprecated use {@code org.apache.maven.shared.filtering.FilteringUtils.copyFile()} instead
*/
@Deprecated
- public static void copyFile(
- @Nonnull File from, @Nonnull File to, @Nullable String encoding, @Nullable FilterWrapper... wrappers)
- throws IOException {
+ public static void copyFile(File from, File to, String encoding, FilterWrapper... wrappers) throws IOException {
copyFile(from, to, encoding, wrappers, false);
}
@@ -1714,12 +1655,7 @@ public class FileUtils {
* @deprecated use {@code org.apache.maven.shared.filtering.FilteringUtils.copyFile()} instead
*/
@Deprecated
- public static void copyFile(
- @Nonnull File from,
- @Nonnull File to,
- @Nullable String encoding,
- @Nullable FilterWrapper[] wrappers,
- boolean overwrite)
+ public static void copyFile(File from, File to, String encoding, FilterWrapper[] wrappers, boolean overwrite)
throws IOException {
if (wrappers == null || wrappers.length == 0) {
if (overwrite || !to.exists() || to.lastModified() < from.lastModified()) {
@@ -1810,7 +1746,7 @@ public class FileUtils {
* @param source the file to copy permissions from.
* @param destination the file to copy permissions to.
*/
- private static void copyFilePermissions(@Nonnull File source, @Nonnull File destination) throws IOException {
+ private static void copyFilePermissions(File source, File destination) throws IOException {
try {
// attempt to copy posix file permissions
Files.setPosixFilePermissions(destination.toPath(), Files.getPosixFilePermissions(source.toPath()));
@@ -1831,8 +1767,7 @@ public class FileUtils {
* @deprecated assumes the platform default character set
*/
@Deprecated
- @Nonnull
- public static List<String> loadFile(@Nonnull File file) throws IOException {
+ public static List<String> loadFile(File file) throws IOException {
List<String> lines = new ArrayList<>();
if (file.exists()) {
@@ -1871,7 +1806,7 @@ public class FileUtils {
* <code>true</code> if the Os is not Windows or if the file path respect the Windows constraints.
* @see #INVALID_CHARACTERS_FOR_WINDOWS_FILE_NAME
*/
- private static boolean isValidWindowsFileName(@Nonnull File f) {
+ private static boolean isValidWindowsFileName(File f) {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
if (StringUtils.indexOfAny(f.getName(), INVALID_CHARACTERS_FOR_WINDOWS_FILE_NAME) != -1) {
return false;
@@ -1894,7 +1829,7 @@ public class FileUtils {
* @deprecated use {@code java.nio.file.Files.isSymbolicLink(file.toPath())}
*/
@Deprecated
- public static boolean isSymbolicLink(@Nonnull final File file) throws IOException {
+ public static boolean isSymbolicLink(final File file) throws IOException {
return Files.isSymbolicLink(file.toPath());
}
@@ -1908,7 +1843,7 @@ public class FileUtils {
* @deprecated use {@code java.nio.file.Files.isSymbolicLink(file.toPath())}
*/
@Deprecated
- public static boolean isSymbolicLinkForSure(@Nonnull final File file) throws IOException {
+ public static boolean isSymbolicLinkForSure(final File file) throws IOException {
return Files.isSymbolicLink(file.toPath());
}
@@ -1922,8 +1857,7 @@ public class FileUtils {
* @see Files#createSymbolicLink(Path, Path, FileAttribute[]) which creates a new symbolic link but does
* not replace existing symbolic links
*/
- @Nonnull
- public static File createSymbolicLink(@Nonnull File symlink, @Nonnull File target) throws IOException {
+ public static File createSymbolicLink(File symlink, File target) throws IOException {
final Path symlinkPath = symlink.toPath();
if (Files.exists(symlinkPath)) {
diff --git a/src/main/java/org/apache/maven/shared/utils/io/IOUtil.java b/src/main/java/org/apache/maven/shared/utils/io/IOUtil.java
index bb90a27..1ab7017 100644
--- a/src/main/java/org/apache/maven/shared/utils/io/IOUtil.java
+++ b/src/main/java/org/apache/maven/shared/utils/io/IOUtil.java
@@ -18,9 +18,6 @@
*/
package org.apache.maven.shared.utils.io;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -133,7 +130,7 @@ public final class IOUtil
* Java 9 and later {@code InputStream.transferTo()}.
*/
@Deprecated
- public static void copy(@Nonnull final InputStream input, @Nonnull final OutputStream output) throws IOException {
+ public static void copy(final InputStream input, final OutputStream output) throws IOException {
copy(input, output, DEFAULT_BUFFER_SIZE);
}
@@ -150,7 +147,7 @@ public final class IOUtil
* Java 9 and later {@code InputStream.transferTo()}.
*/
@Deprecated
- public static void copy(@Nonnull final InputStream input, @Nonnull final OutputStream output, final int bufferSize)
+ public static void copy(final InputStream input, final OutputStream output, final int bufferSize)
throws IOException {
final byte[] buffer = new byte[bufferSize];
int n;
@@ -167,7 +164,7 @@ public final class IOUtil
* @throws IOException in case of failure * @deprecated use {@code org.apache.commons.io.IOUtils.copy()}.
*/
@Deprecated
- public static void copy(@Nonnull final Reader input, @Nonnull final Writer output) throws IOException {
+ public static void copy(final Reader input, final Writer output) throws IOException {
copy(input, output, DEFAULT_BUFFER_SIZE);
}
@@ -181,8 +178,7 @@ public final class IOUtil
* @deprecated use {@code org.apache.commons.io.IOUtils.copy()}.
*/
@Deprecated
- public static void copy(@Nonnull final Reader input, @Nonnull final Writer output, final int bufferSize)
- throws IOException {
+ public static void copy(final Reader input, final Writer output, final int bufferSize) throws IOException {
final char[] buffer = new char[bufferSize];
int n;
while (-1 != (n = input.read(buffer))) {
@@ -211,7 +207,7 @@ public final class IOUtil
* @deprecated use {@code org.apache.commons.io.IOUtils.copy()}.
*/
@Deprecated
- public static void copy(@Nonnull final InputStream input, @Nonnull final Writer output) throws IOException {
+ public static void copy(final InputStream input, final Writer output) throws IOException {
copy(input, output, DEFAULT_BUFFER_SIZE);
}
@@ -227,8 +223,7 @@ public final class IOUtil
* @deprecated use {@code org.apache.commons.io.IOUtils.copy()}.
*/
@Deprecated
- public static void copy(@Nonnull final InputStream input, @Nonnull final Writer output, final int bufferSize)
- throws IOException {
+ public static void copy(final InputStream input, final Writer output, final int bufferSize) throws IOException {
final InputStreamReader in = new InputStreamReader(input);
copy(in, output, bufferSize);
}
@@ -246,9 +241,7 @@ public final class IOUtil
* @deprecated use {@code org.apache.commons.io.IOUtils.copy()}.
*/
@Deprecated
- public static void copy(
- @Nonnull final InputStream input, @Nonnull final Writer output, @Nonnull final String encoding)
- throws IOException {
+ public static void copy(final InputStream input, final Writer output, final String encoding) throws IOException {
final InputStreamReader in = new InputStreamReader(input, encoding);
copy(in, output);
}
@@ -267,11 +260,7 @@ public final class IOUtil
* @deprecated use {@code org.apache.commons.io.IOUtils.copy()}.
*/
@Deprecated
- public static void copy(
- @Nonnull final InputStream input,
- @Nonnull final Writer output,
- @Nonnull final String encoding,
- final int bufferSize)
+ public static void copy(final InputStream input, final Writer output, final String encoding, final int bufferSize)
throws IOException {
final InputStreamReader in = new InputStreamReader(input, encoding);
copy(in, output, bufferSize);
@@ -290,8 +279,7 @@ public final class IOUtil
* @deprecated always specify a character encoding
*/
@Deprecated
- @Nonnull
- public static String toString(@Nonnull final InputStream input) throws IOException {
+ public static String toString(final InputStream input) throws IOException {
return toString(input, DEFAULT_BUFFER_SIZE);
}
@@ -306,8 +294,7 @@ public final class IOUtil
* @deprecated always specify a character encoding
*/
@Deprecated
- @Nonnull
- public static String toString(@Nonnull final InputStream input, final int bufferSize) throws IOException {
+ public static String toString(final InputStream input, final int bufferSize) throws IOException {
final StringWriter sw = new StringWriter();
copy(input, sw, bufferSize);
return sw.toString();
@@ -325,8 +312,7 @@ public final class IOUtil
* @deprecated use {@code org.apache.commons.io.IOUtils.toString()}.
*/
@Deprecated
- @Nonnull
- public static String toString(@Nonnull final InputStream input, @Nonnull final String encoding) throws IOException {
+ public static String toString(final InputStream input, final String encoding) throws IOException {
return toString(input, encoding, DEFAULT_BUFFER_SIZE);
}
@@ -343,9 +329,8 @@ public final class IOUtil
* @deprecated use {@code org.apache.commons.io.IOUtils.toString()}.
*/
@Deprecated
- @Nonnull
- public static String toString(
- @Nonnull final InputStream input, @Nonnull final String encoding, final int bufferSize) throws IOException {
+ public static String toString(final InputStream input, final String encoding, final int bufferSize)
+ throws IOException {
final StringWriter sw = new StringWriter();
copy(input, sw, encoding, bufferSize);
return sw.toString();
@@ -363,8 +348,7 @@ public final class IOUtil
* @deprecated use {@code org.apache.commons.io.IOUtils.readFully()}.
*/
@Deprecated
- @Nonnull
- public static byte[] toByteArray(@Nonnull final InputStream input) throws IOException {
+ public static byte[] toByteArray(final InputStream input) throws IOException {
return toByteArray(input, DEFAULT_BUFFER_SIZE);
}
@@ -378,8 +362,7 @@ public final class IOUtil
* @deprecated use {@code org.apache.commons.io.IOUtils.readFully()}.
*/
@Deprecated
- @Nonnull
- public static byte[] toByteArray(@Nonnull final InputStream input, final int bufferSize) throws IOException {
+ public static byte[] toByteArray(final InputStream input, final int bufferSize) throws IOException {
final ByteArrayOutputStream output = new ByteArrayOutputStream();
copy(input, output, bufferSize);
return output.toByteArray();
@@ -403,7 +386,7 @@ public final class IOUtil
* @deprecated always specify a character encoding
*/
@Deprecated
- public static void copy(@Nonnull final Reader input, @Nonnull final OutputStream output) throws IOException {
+ public static void copy(final Reader input, final OutputStream output) throws IOException {
copy(input, output, DEFAULT_BUFFER_SIZE);
}
@@ -418,8 +401,7 @@ public final class IOUtil
* @deprecated always specify a character encoding
*/
@Deprecated
- public static void copy(@Nonnull final Reader input, @Nonnull final OutputStream output, final int bufferSize)
- throws IOException {
+ public static void copy(final Reader input, final OutputStream output, final int bufferSize) throws IOException {
final OutputStreamWriter out = new OutputStreamWriter(output);
copy(input, out, bufferSize);
// NOTE: Unless anyone is planning on rewriting OutputStreamWriter, we have to flush
@@ -438,8 +420,7 @@ public final class IOUtil
* @deprecated use {@code org.apache.commons.io.IOUtils.toString()}.
*/
@Deprecated
- @Nonnull
- public static String toString(@Nonnull final Reader input) throws IOException {
+ public static String toString(final Reader input) throws IOException {
return toString(input, DEFAULT_BUFFER_SIZE);
}
@@ -453,8 +434,7 @@ public final class IOUtil
* @deprecated use {@code org.apache.commons.io.IOUtils.toString()}.
*/
@Deprecated
- @Nonnull
- public static String toString(@Nonnull final Reader input, final int bufferSize) throws IOException {
+ public static String toString(final Reader input, final int bufferSize) throws IOException {
final StringWriter sw = new StringWriter();
copy(input, sw, bufferSize);
return sw.toString();
@@ -472,8 +452,7 @@ public final class IOUtil
* @deprecated always specify a character encoding
*/
@Deprecated
- @Nonnull
- public static byte[] toByteArray(@Nonnull final Reader input) throws IOException {
+ public static byte[] toByteArray(final Reader input) throws IOException {
return toByteArray(input, DEFAULT_BUFFER_SIZE);
}
@@ -487,8 +466,7 @@ public final class IOUtil
* @deprecated always specify a character encoding
*/
@Deprecated
- @Nonnull
- public static byte[] toByteArray(@Nonnull final Reader input, final int bufferSize) throws IOException {
+ public static byte[] toByteArray(final Reader input, final int bufferSize) throws IOException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
copy(input, output, bufferSize);
return output.toByteArray();
@@ -511,7 +489,7 @@ public final class IOUtil
* @deprecated always specify a character encoding
*/
@Deprecated
- public static void copy(@Nonnull final String input, @Nonnull final OutputStream output) throws IOException {
+ public static void copy(final String input, final OutputStream output) throws IOException {
copy(input, output, DEFAULT_BUFFER_SIZE);
}
@@ -526,8 +504,7 @@ public final class IOUtil
* @deprecated always specify a character encoding
*/
@Deprecated
- public static void copy(@Nonnull final String input, @Nonnull final OutputStream output, final int bufferSize)
- throws IOException {
+ public static void copy(final String input, final OutputStream output, final int bufferSize) throws IOException {
final StringReader in = new StringReader(input);
final OutputStreamWriter out = new OutputStreamWriter(output);
copy(in, out, bufferSize);
@@ -548,7 +525,7 @@ public final class IOUtil
* @deprecated use {@code org.apache.commons.io.IOUtils.write()}.
*/
@Deprecated
- public static void copy(@Nonnull final String input, @Nonnull final Writer output) throws IOException {
+ public static void copy(final String input, final Writer output) throws IOException {
output.write(input);
}
@@ -564,8 +541,7 @@ public final class IOUtil
* @deprecated always specify a character encoding
*/
@Deprecated
- @Nonnull
- public static byte[] toByteArray(@Nonnull final String input) throws IOException {
+ public static byte[] toByteArray(final String input) throws IOException {
return toByteArray(input, DEFAULT_BUFFER_SIZE);
}
@@ -579,8 +555,7 @@ public final class IOUtil
* @deprecated always specify a character encoding
*/
@Deprecated
- @Nonnull
- public static byte[] toByteArray(@Nonnull final String input, final int bufferSize) throws IOException {
+ public static byte[] toByteArray(final String input, final int bufferSize) throws IOException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
copy(input, output, bufferSize);
return output.toByteArray();
@@ -605,7 +580,7 @@ public final class IOUtil
* @deprecated always specify a character encoding
*/
@Deprecated
- public static void copy(@Nonnull final byte[] input, @Nonnull final Writer output) throws IOException {
+ public static void copy(final byte[] input, final Writer output) throws IOException {
copy(input, output, DEFAULT_BUFFER_SIZE);
}
@@ -621,8 +596,7 @@ public final class IOUtil
* @deprecated always specify a character encoding
*/
@Deprecated
- public static void copy(@Nonnull final byte[] input, @Nonnull final Writer output, final int bufferSize)
- throws IOException {
+ public static void copy(final byte[] input, final Writer output, final int bufferSize) throws IOException {
final ByteArrayInputStream in = new ByteArrayInputStream(input);
copy(in, output, bufferSize);
}
@@ -640,8 +614,7 @@ public final class IOUtil
* @deprecated use {@code org.apache.commons.io.IOUtils.write()}.
*/
@Deprecated
- public static void copy(@Nonnull final byte[] input, @Nonnull final Writer output, final String encoding)
- throws IOException {
+ public static void copy(final byte[] input, final Writer output, final String encoding) throws IOException {
final ByteArrayInputStream in = new ByteArrayInputStream(input);
copy(in, output, encoding);
}
@@ -660,11 +633,7 @@ public final class IOUtil
* @deprecated use {@code org.apache.commons.io.IOUtils.write()}.
*/
@Deprecated
- public static void copy(
- @Nonnull final byte[] input,
- @Nonnull final Writer output,
- @Nonnull final String encoding,
- final int bufferSize)
+ public static void copy(final byte[] input, final Writer output, final String encoding, final int bufferSize)
throws IOException {
final ByteArrayInputStream in = new ByteArrayInputStream(input);
copy(in, output, encoding, bufferSize);
@@ -682,8 +651,7 @@ public final class IOUtil
* @deprecated always specify a character encoding
*/
@Deprecated
- @Nonnull
- public static String toString(@Nonnull final byte[] input) throws IOException {
+ public static String toString(final byte[] input) throws IOException {
return toString(input, DEFAULT_BUFFER_SIZE);
}
@@ -698,8 +666,7 @@ public final class IOUtil
* @deprecated always specify a character encoding
*/
@Deprecated
- @Nonnull
- public static String toString(@Nonnull final byte[] input, final int bufferSize) throws IOException {
+ public static String toString(final byte[] input, final int bufferSize) throws IOException {
final StringWriter sw = new StringWriter();
copy(input, sw, bufferSize);
return sw.toString();
@@ -717,8 +684,7 @@ public final class IOUtil
* @deprecated use {@code new String(input, encoding)}
*/
@Deprecated
- @Nonnull
- public static String toString(@Nonnull final byte[] input, @Nonnull final String encoding) throws IOException {
+ public static String toString(final byte[] input, final String encoding) throws IOException {
return toString(input, encoding, DEFAULT_BUFFER_SIZE);
}
@@ -735,9 +701,7 @@ public final class IOUtil
* @deprecated use {@code new String(input, encoding)}
*/
@Deprecated
- @Nonnull
- public static String toString(@Nonnull final byte[] input, @Nonnull final String encoding, final int bufferSize)
- throws IOException {
+ public static String toString(final byte[] input, final String encoding, final int bufferSize) throws IOException {
final StringWriter sw = new StringWriter();
copy(input, sw, encoding, bufferSize);
return sw.toString();
@@ -755,7 +719,7 @@ public final class IOUtil
* @deprecated inline this method
*/
@Deprecated
- public static void copy(@Nonnull final byte[] input, @Nonnull final OutputStream output) throws IOException {
+ public static void copy(final byte[] input, final OutputStream output) throws IOException {
output.write(input);
}
@@ -769,8 +733,7 @@ public final class IOUtil
* @deprecated use {@code org.apache.commons.io.IOUtils.contentEquals()}
*/
@Deprecated
- public static boolean contentEquals(@Nonnull final InputStream input1, @Nonnull final InputStream input2)
- throws IOException {
+ public static boolean contentEquals(final InputStream input1, final InputStream input2) throws IOException {
final InputStream bufferedInput1 = new BufferedInputStream(input1);
final InputStream bufferedInput2 = new BufferedInputStream(input2);
@@ -882,7 +845,7 @@ public final class IOUtil
* @deprecated use try-with-resources
*/
@Deprecated
- public static void close(@Nullable Channel channel) {
+ public static void close(Channel channel) {
try {
if (channel != null) {
channel.close();
@@ -983,7 +946,7 @@ public final class IOUtil
* @deprecated use try-with-resources
*/
@Deprecated
- public static void close(@Nullable InputStream inputStream) {
+ public static void close(InputStream inputStream) {
try {
if (inputStream != null) {
inputStream.close();
@@ -1084,7 +1047,7 @@ public final class IOUtil
* @deprecated use try-with-resources
*/
@Deprecated
- public static void close(@Nullable OutputStream outputStream) {
+ public static void close(OutputStream outputStream) {
try {
if (outputStream != null) {
outputStream.close();
@@ -1185,7 +1148,7 @@ public final class IOUtil
* @deprecated use try-with-resources
*/
@Deprecated
- public static void close(@Nullable Reader reader) {
+ public static void close(Reader reader) {
try {
if (reader != null) {
reader.close();
@@ -1286,7 +1249,7 @@ public final class IOUtil
* @deprecated use try-with-resources
*/
@Deprecated
- public static void close(@Nullable Writer writer) {
+ public static void close(Writer writer) {
try {
if (writer != null) {
writer.close();
diff --git a/src/main/java/org/apache/maven/shared/utils/io/Java7Support.java b/src/main/java/org/apache/maven/shared/utils/io/Java7Support.java
index 1aa87d8..ce97623 100644
--- a/src/main/java/org/apache/maven/shared/utils/io/Java7Support.java
+++ b/src/main/java/org/apache/maven/shared/utils/io/Java7Support.java
@@ -18,8 +18,6 @@
*/
package org.apache.maven.shared.utils.io;
-import javax.annotation.Nonnull;
-
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
@@ -37,7 +35,7 @@ public class Java7Support {
* @param file The file to check for being a symbolic link.
* @return true if the file is a symlink false otherwise.
*/
- public static boolean isSymLink(@Nonnull File file) {
+ public static boolean isSymLink(File file) {
return Files.isSymbolicLink(file.toPath());
}
@@ -46,8 +44,7 @@ public class Java7Support {
* @return The file.
* @throws IOException in case of error.
*/
- @Nonnull
- public static File readSymbolicLink(@Nonnull File symlink) throws IOException {
+ public static File readSymbolicLink(File symlink) throws IOException {
return Files.readSymbolicLink(symlink.toPath()).toFile();
}
@@ -56,7 +53,7 @@ public class Java7Support {
* @return true if exist false otherwise.
* @throws IOException in case of failure.
*/
- public static boolean exists(@Nonnull File file) throws IOException {
+ public static boolean exists(File file) throws IOException {
return Files.exists(file.toPath());
}
@@ -66,8 +63,7 @@ public class Java7Support {
* @return The linked file.
* @throws IOException in case of an error.
*/
- @Nonnull
- public static File createSymbolicLink(@Nonnull File symlink, @Nonnull File target) throws IOException {
+ public static File createSymbolicLink(File symlink, File target) throws IOException {
return FileUtils.createSymbolicLink(symlink, target);
}
@@ -76,7 +72,7 @@ public class Java7Support {
* @param file the file to delete
* @throws IOException in case of error.
*/
- public static void delete(@Nonnull File file) throws IOException {
+ public static void delete(File file) throws IOException {
Files.delete(file.toPath());
}
diff --git a/src/main/java/org/apache/maven/shared/utils/io/MatchPattern.java b/src/main/java/org/apache/maven/shared/utils/io/MatchPattern.java
index 75ad557..c595c89 100644
--- a/src/main/java/org/apache/maven/shared/utils/io/MatchPattern.java
+++ b/src/main/java/org/apache/maven/shared/utils/io/MatchPattern.java
@@ -18,8 +18,6 @@
*/
package org.apache.maven.shared.utils.io;
-import javax.annotation.Nonnull;
-
import java.io.File;
import java.util.ArrayList;
import java.util.List;
@@ -46,7 +44,7 @@ public class MatchPattern {
private final String[] tokenized;
- private MatchPattern(@Nonnull String source, @Nonnull String separator) {
+ private MatchPattern(String source, String separator) {
regexPattern = SelectorUtils.isRegexPrefixedPattern(source)
? source.substring(
SelectorUtils.REGEX_HANDLER_PREFIX.length(),
@@ -88,7 +86,7 @@ public class MatchPattern {
* @param isCaseSensitive Check case sensitive or not.
* @return true in case of matching pattern.
*/
- public boolean matchPatternStart(@Nonnull String str, boolean isCaseSensitive) {
+ public boolean matchPatternStart(String str, boolean isCaseSensitive) {
if (regexPattern != null) {
// FIXME: ICK! But we can't do partial matches for regex, so we have to reserve judgment until we have
// a file to deal with, or we can definitely say this is an exclusion...
@@ -116,7 +114,7 @@ public class MatchPattern {
return source.startsWith(string);
}
- static String[] tokenizePathToString(@Nonnull String path, @Nonnull String separator) {
+ static String[] tokenizePathToString(String path, String separator) {
List<String> ret = new ArrayList<>();
StringTokenizer st = new StringTokenizer(path, separator);
while (st.hasMoreTokens()) {
diff --git a/src/main/java/org/apache/maven/shared/utils/io/MatchPatterns.java b/src/main/java/org/apache/maven/shared/utils/io/MatchPatterns.java
index f083aa5..6d1762b 100644
--- a/src/main/java/org/apache/maven/shared/utils/io/MatchPatterns.java
+++ b/src/main/java/org/apache/maven/shared/utils/io/MatchPatterns.java
@@ -18,8 +18,6 @@
*/
package org.apache.maven.shared.utils.io;
-import javax.annotation.Nonnull;
-
import java.io.File;
/**
@@ -32,7 +30,7 @@ import java.io.File;
public class MatchPatterns {
private final MatchPattern[] patterns;
- private MatchPatterns(@Nonnull MatchPattern... patterns) {
+ private MatchPatterns(MatchPattern... patterns) {
this.patterns = patterns;
}
@@ -44,7 +42,7 @@ public class MatchPatterns {
* @param isCaseSensitive If the comparison is case sensitive
* @return true if any of the supplied patterns match
*/
- public boolean matches(@Nonnull String name, boolean isCaseSensitive) {
+ public boolean matches(String name, boolean isCaseSensitive) {
String[] tokenized = MatchPattern.tokenizePathToString(name, File.separator);
for (MatchPattern pattern : patterns) {
if (pattern.matchPath(name, tokenized, isCaseSensitive)) {
@@ -59,7 +57,7 @@ public class MatchPatterns {
* @param isCaseSensitive being case sensetive.
* @return true if any of the supplied patterns match start.
*/
- public boolean matchesPatternStart(@Nonnull String name, boolean isCaseSensitive) {
+ public boolean matchesPatternStart(String name, boolean isCaseSensitive) {
for (MatchPattern includesPattern : patterns) {
if (includesPattern.matchPatternStart(name, isCaseSensitive)) {
return true;
@@ -72,7 +70,7 @@ public class MatchPatterns {
* @param sources The sources
* @return Converted match patterns.
*/
- public static MatchPatterns from(@Nonnull String... sources) {
+ public static MatchPatterns from(String... sources) {
final int length = sources.length;
MatchPattern[] result = new MatchPattern[length];
for (int i = 0; i < length; i++) {
diff --git a/src/main/java/org/apache/maven/shared/utils/io/SelectorUtils.java b/src/main/java/org/apache/maven/shared/utils/io/SelectorUtils.java
index 007d292..38f4b8f 100644
--- a/src/main/java/org/apache/maven/shared/utils/io/SelectorUtils.java
+++ b/src/main/java/org/apache/maven/shared/utils/io/SelectorUtils.java
@@ -18,8 +18,6 @@
*/
package org.apache.maven.shared.utils.io;
-import javax.annotation.Nonnull;
-
import java.io.File;
import java.util.ArrayList;
import java.util.List;
@@ -513,12 +511,12 @@ public final class SelectorUtils {
}
static boolean matchAntPathPatternStart(
- @Nonnull MatchPattern pattern, @Nonnull String str, @Nonnull String separator, boolean isCaseSensitive) {
+ MatchPattern pattern, String str, String separator, boolean isCaseSensitive) {
return !separatorPatternStartSlashMismatch(pattern, str, separator)
&& matchAntPathPatternStart(pattern.getTokenizedPathString(), str, separator, isCaseSensitive);
}
- private static String[] tokenizePathToString(@Nonnull String path, @Nonnull String separator) {
+ private static String[] tokenizePathToString(String path, String separator) {
List<String> ret = new ArrayList<>();
StringTokenizer st = new StringTokenizer(path, separator);
while (st.hasMoreTokens()) {
@@ -528,13 +526,13 @@ public final class SelectorUtils {
}
private static boolean matchAntPathPatternStart(
- @Nonnull String[] patDirs, @Nonnull String str, @Nonnull String separator, boolean isCaseSensitive) {
+ String[] patDirs, String str, String separator, boolean isCaseSensitive) {
String[] strDirs = tokenizePathToString(str, separator);
return matchAntPathPatternStart(patDirs, strDirs, isCaseSensitive);
}
private static boolean matchAntPathPatternStart(
- @Nonnull String[] patDirs, @Nonnull String[] tokenizedFileName, boolean isCaseSensitive) {
+ String[] patDirs, String[] tokenizedFileName, boolean isCaseSensitive) {
int patIdxStart = 0;
int patIdxEnd = patDirs.length - 1;
@@ -557,8 +555,7 @@ public final class SelectorUtils {
return strIdxStart > strIdxEnd || patIdxStart <= patIdxEnd;
}
- private static boolean separatorPatternStartSlashMismatch(
- @Nonnull MatchPattern matchPattern, @Nonnull String str, @Nonnull String separator) {
+ private static boolean separatorPatternStartSlashMismatch(MatchPattern matchPattern, String str, String separator) {
return str.startsWith(separator) != matchPattern.startsWith(separator);
}
@@ -683,10 +680,7 @@ public final class SelectorUtils {
}
static boolean matchAntPathPattern(
- @Nonnull MatchPattern matchPattern,
- @Nonnull String str,
- @Nonnull String separator,
- boolean isCaseSensitive) {
+ MatchPattern matchPattern, String str, String separator, boolean isCaseSensitive) {
if (separatorPatternStartSlashMismatch(matchPattern, str, separator)) {
return false;
}
diff --git a/src/main/java/org/apache/maven/shared/utils/xml/Xpp3Dom.java b/src/main/java/org/apache/maven/shared/utils/xml/Xpp3Dom.java
index 2ba422d..714a6cf 100644
--- a/src/main/java/org/apache/maven/shared/utils/xml/Xpp3Dom.java
+++ b/src/main/java/org/apache/maven/shared/utils/xml/Xpp3Dom.java
@@ -18,8 +18,6 @@
*/
package org.apache.maven.shared.utils.xml;
-import javax.annotation.Nonnull;
-
import java.io.IOException;
import java.io.StringWriter;
import java.util.ArrayList;
@@ -109,7 +107,7 @@ public class Xpp3Dom implements Iterable<Xpp3Dom> {
* @param src The source Dom.
* @param name The name of the Dom.
*/
- public Xpp3Dom(@Nonnull Xpp3Dom src, String name) {
+ public Xpp3Dom(Xpp3Dom src, String name) {
this.name = name;
int size = src.getChildCount();
@@ -137,7 +135,6 @@ public class Xpp3Dom implements Iterable<Xpp3Dom> {
/**
* @return The current value.
*/
- @Nonnull
public String getValue() {
return value;
}
@@ -145,7 +142,7 @@ public class Xpp3Dom implements Iterable<Xpp3Dom> {
/**
* @param value The value to be set.
*/
- public void setValue(@Nonnull String value) {
+ public void setValue(String value) {
this.value = value;
}
@@ -169,7 +166,7 @@ public class Xpp3Dom implements Iterable<Xpp3Dom> {
* @param nameParameter The name of the attribute.
* @param valueParameter The value of the attribute.
*/
- public void setAttribute(@Nonnull String nameParameter, @Nonnull String valueParameter) {
+ public void setAttribute(String nameParameter, String valueParameter) {
if (valueParameter == null) {
throw new NullPointerException("value can not be null");
}
diff --git a/src/main/java/org/apache/maven/shared/utils/xml/Xpp3DomBuilder.java b/src/main/java/org/apache/maven/shared/utils/xml/Xpp3DomBuilder.java
index aeadbb2..cc6298e 100644
--- a/src/main/java/org/apache/maven/shared/utils/xml/Xpp3DomBuilder.java
+++ b/src/main/java/org/apache/maven/shared/utils/xml/Xpp3DomBuilder.java
@@ -18,9 +18,6 @@
*/
package org.apache.maven.shared.utils.xml;
-import javax.annotation.Nonnull;
-import javax.annotation.WillClose;
-
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -48,7 +45,7 @@ public class Xpp3DomBuilder {
* @return the built DOM
* @throws XmlPullParserException in case of an error
*/
- public static Xpp3Dom build(@WillClose @Nonnull Reader reader) throws XmlPullParserException {
+ public static Xpp3Dom build(Reader reader) throws XmlPullParserException {
return build(reader, false);
}
@@ -58,7 +55,7 @@ public class Xpp3DomBuilder {
* @return the built DOM
* @throws XmlPullParserException in case of an error
*/
- public static Xpp3Dom build(@WillClose InputStream is, @Nonnull String encoding) throws XmlPullParserException {
+ public static Xpp3Dom build(InputStream is, String encoding) throws XmlPullParserException {
return build(is, encoding, false);
}
@@ -71,8 +68,7 @@ public class Xpp3DomBuilder {
* @deprecated use the two-arg variant
*/
@Deprecated
- public static Xpp3Dom build(@WillClose InputStream is, @Nonnull String encoding, boolean noop)
- throws XmlPullParserException {
+ public static Xpp3Dom build(InputStream is, String encoding, boolean noop) throws XmlPullParserException {
try {
Reader reader = new InputStreamReader(is, encoding);
return build(reader);
@@ -89,7 +85,7 @@ public class Xpp3DomBuilder {
* @deprecated use {#build(java.io.Reader)}
*/
@Deprecated
- public static Xpp3Dom build(@WillClose Reader in, boolean noop) throws XmlPullParserException {
+ public static Xpp3Dom build(Reader in, boolean noop) throws XmlPullParserException {
try (Reader reader = in) {
DocHandler docHandler = parseSax(new InputSource(reader));
reader.close();
@@ -99,7 +95,7 @@ public class Xpp3DomBuilder {
}
}
- private static DocHandler parseSax(@Nonnull InputSource inputSource) throws XmlPullParserException {
+ private static DocHandler parseSax(InputSource inputSource) throws XmlPullParserException {
try {
DocHandler ch = new DocHandler();
XMLReader parser = createXmlReader();
diff --git a/src/test/java/org/apache/maven/shared/utils/io/FileUtilsTest.java b/src/test/java/org/apache/maven/shared/utils/io/FileUtilsTest.java
index 9f5baf3..40129d3 100644
--- a/src/test/java/org/apache/maven/shared/utils/io/FileUtilsTest.java
+++ b/src/test/java/org/apache/maven/shared/utils/io/FileUtilsTest.java
@@ -18,8 +18,6 @@
*/
package org.apache.maven.shared.utils.io;
-import javax.annotation.Nonnull;
-
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -490,7 +488,7 @@ public class FileUtilsTest {
};
}
- private File write(@Nonnull String name, long lastModified, @Nonnull String text) throws IOException {
+ private File write(String name, long lastModified, String text) throws IOException {
final File file = new File(tempFolder, name);
try (Writer writer = new FileWriter(file)) {
writer.write(text);
@@ -500,7 +498,7 @@ public class FileUtilsTest {
return file;
}
- private static void assertFileContent(@Nonnull File file, @Nonnull String expected) throws IOException {
+ private static void assertFileContent(File file, String expected) throws IOException {
try (Reader in = new FileReader(file)) {
assertEquals(expected, IOUtils.toString(in), "Expected " + file.getPath() + " to contain: " + expected);
}