This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-shared-utils.git
The following commit(s) were added to refs/heads/master by this push:
new 6e77398 chore: Migrate to JSpecify from jsr305
6e77398 is described below
commit 6e773988c132bfe99e6e76ed2531d12087f0901e
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Sun Feb 1 16:39:46 2026 +0100
chore: Migrate to JSpecify from jsr305
---
pom.xml | 11 +-
.../org/apache/maven/shared/utils/PathTool.java | 14 +-
.../apache/maven/shared/utils/PropertyUtils.java | 16 +-
.../apache/maven/shared/utils/ReaderFactory.java | 17 +-
.../org/apache/maven/shared/utils/StringUtils.java | 170 +++++++++---------
.../apache/maven/shared/utils/WriterFactory.java | 15 +-
.../maven/shared/utils/cli/CommandLineUtils.java | 21 ++-
.../maven/shared/utils/cli/StreamPumper.java | 4 +-
.../introspection/ReflectionValueExtractor.java | 9 +-
.../maven/shared/utils/io/DirectoryScanner.java | 14 +-
.../apache/maven/shared/utils/io/FileUtils.java | 196 ++++++++++-----------
.../org/apache/maven/shared/utils/io/IOUtil.java | 116 ++++++------
.../apache/maven/shared/utils/io/Java7Support.java | 18 +-
.../apache/maven/shared/utils/io/MatchPattern.java | 10 +-
.../maven/shared/utils/io/MatchPatterns.java | 12 +-
.../maven/shared/utils/io/SelectorUtils.java | 20 +--
.../org/apache/maven/shared/utils/xml/Xpp3Dom.java | 12 +-
.../maven/shared/utils/xml/Xpp3DomBuilder.java | 15 +-
.../maven/shared/utils/io/FileUtilsTest.java | 7 +-
19 files changed, 343 insertions(+), 354 deletions(-)
diff --git a/pom.xml b/pom.xml
index e09ce3d..b01cc2a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -79,6 +79,11 @@
<version>2.4.2</version>
<optional>true</optional>
</dependency>
+ <dependency>
+ <groupId>org.jspecify</groupId>
+ <artifactId>jspecify</artifactId>
+ <version>1.0.0</version>
+ </dependency>
<dependency>
<groupId>commons-io</groupId>
@@ -90,12 +95,6 @@
<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>
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..0b5b93f 100644
--- a/src/main/java/org/apache/maven/shared/utils/PathTool.java
+++ b/src/main/java/org/apache/maven/shared/utils/PathTool.java
@@ -18,12 +18,12 @@
*/
package org.apache.maven.shared.utils;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
import java.io.File;
import java.util.StringTokenizer;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* <p>Path tool contains static methods to assist in determining path-related
* information such as relative paths.</p>
@@ -198,8 +198,8 @@ 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) {
+ @NonNull
+ private static String determineRelativePath(@NonNull String filename,
@NonNull String separator) {
if (filename.length() == 0) {
return "";
}
@@ -264,9 +264,9 @@ public class PathTool {
return path;
}
- @Nonnull
+ @NonNull
private static String buildRelativePath(
- @Nonnull String toPath, @Nonnull String fromPath, final char
separatorChar) {
+ @NonNull String toPath, @NonNull 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..199def0 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;
@@ -28,6 +25,9 @@ import java.io.InputStream;
import java.net.URL;
import java.util.Properties;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* Static utility methods for loading properties.
*/
@@ -49,7 +49,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(@NonNull URL url) {
try (InputStream in = url.openStream()) {
return loadProperties(in);
} catch (Exception e) {
@@ -66,7 +66,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(@NonNull File file) {
try (InputStream in = new FileInputStream(file)) {
return loadProperties(in);
} catch (Exception e) {
@@ -113,7 +113,7 @@ public class PropertyUtils {
* @return the loaded properties or an empty {@code Properties} instance
if properties fail to load
* @since 3.1.0
*/
- @Nonnull
+ @NonNull
public static Properties loadOptionalProperties(final @Nullable URL url) {
Properties properties = new Properties();
@@ -138,7 +138,7 @@ public class PropertyUtils {
* @return the loaded properties or an empty {@code Properties} instance
if properties fail to load
* @since 3.1.0
*/
- @Nonnull
+ @NonNull
public static Properties loadOptionalProperties(final @Nullable File file)
{
Properties properties = new Properties();
if (file != null) {
@@ -162,7 +162,7 @@ public class PropertyUtils {
* @return the loaded properties or an empty {@code Properties} instance
if properties fail to load
* @since 3.1.0
*/
- @Nonnull
+ @NonNull
public static Properties loadOptionalProperties(final @Nullable
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..a75b0bb 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;
@@ -33,6 +31,7 @@ import java.net.URL;
import java.nio.charset.Charset;
import org.apache.commons.io.input.XmlStreamReader;
+import org.jspecify.annotations.NonNull;
/**
* Utility to create Readers from streams, with explicit encoding choice:
platform default,
@@ -115,7 +114,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(@NonNull InputStream in) throws
IOException {
return new XmlStreamReader(in);
}
@@ -128,7 +127,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(@NonNull File file) throws IOException {
return new XmlStreamReader(file);
}
@@ -141,7 +140,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(@NonNull URL url) throws IOException {
return new XmlStreamReader(url);
}
@@ -155,7 +154,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(@NonNull File file) throws
FileNotFoundException {
return new FileReader(file);
}
@@ -172,7 +171,7 @@ public class ReaderFactory {
* @deprecated use {@code new InputStreamReader(in, encoding)} instead
*/
@Deprecated
- public static Reader newReader(@Nonnull InputStream in, @Nonnull String
encoding)
+ public static Reader newReader(@NonNull InputStream in, @NonNull String
encoding)
throws UnsupportedEncodingException {
return new InputStreamReader(in, encoding);
}
@@ -192,7 +191,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(@NonNull File file, @NonNull String
encoding)
throws FileNotFoundException, UnsupportedEncodingException {
return new InputStreamReader(new FileInputStream(file), encoding);
}
@@ -211,7 +210,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(@NonNull URL url, @NonNull 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..f953da9 100644
--- a/src/main/java/org/apache/maven/shared/utils/StringUtils.java
+++ b/src/main/java/org/apache/maven/shared/utils/StringUtils.java
@@ -18,15 +18,15 @@
*/
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;
import java.util.Map;
import java.util.StringTokenizer;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* <p>Common <code>String</code> manipulation routines.</p>
*
@@ -74,7 +74,7 @@ public class StringUtils {
* @deprecated use {@link #trim(String)} instead.
*/
@Deprecated
- @Nonnull
+ @NonNull
public static String clean(String str) {
return (str == null ? "" : str.trim());
}
@@ -101,8 +101,8 @@ public class StringUtils {
* @param str String target to delete whitespace from
* @return the String without whitespace
*/
- @Nonnull
- public static String deleteWhitespace(@Nonnull String str) {
+ @NonNull
+ public static String deleteWhitespace(@NonNull String str) {
StringBuilder buffer = new StringBuilder();
int sz = str.length();
for (int i = 0; i < sz; i++) {
@@ -461,9 +461,9 @@ 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
+ @NonNull
@Deprecated
- public static String[] split(@Nonnull String str) {
+ public static String[] split(@NonNull String str) {
return split(str, null, -1);
}
@@ -476,9 +476,9 @@ 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
+ @NonNull
@Deprecated
- public static String[] split(@Nonnull String text, @Nullable String
separator) {
+ public static String[] split(@NonNull String text, @Nullable String
separator) {
return split(text, separator, -1);
}
@@ -503,9 +503,9 @@ 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
+ @NonNull
@Deprecated
- public static String[] split(@Nonnull String str, @Nullable String
separator, int max) {
+ public static String[] split(@NonNull String str, @Nullable String
separator, int max) {
StringTokenizer tok;
if (separator == null) {
// Null separator means we're using StringTokenizer's default
@@ -554,8 +554,8 @@ public class StringUtils {
* @param array the array of values to concatenate.
* @return the concatenated string.
*/
- @Nonnull
- public static String concatenate(@Nonnull Object... array) {
+ @NonNull
+ public static String concatenate(@NonNull Object... array) {
return join(array, "");
}
@@ -572,8 +572,8 @@ public class StringUtils {
* @deprecated use <code>java.lang.String.join(</code>) instead
*/
@Deprecated
- @Nonnull
- public static String join(@Nonnull Object[] array, @Nullable String
separator) {
+ @NonNull
+ public static String join(@NonNull Object[] array, @Nullable String
separator) {
if (separator == null) {
separator = "";
}
@@ -603,8 +603,8 @@ public class StringUtils {
* @deprecated use <code>java.lang.String.join(</code>) instead
*/
@Deprecated
- @Nonnull
- public static String join(@Nonnull Iterator<?> iterator, String separator)
{
+ @NonNull
+ public static String join(@NonNull Iterator<?> iterator, String separator)
{
if (separator == null) {
separator = "";
}
@@ -738,8 +738,8 @@ 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) {
+ @NonNull
+ public static String overlayString(@NonNull String text, @NonNull String
overlay, int start, int end) {
if (overlay == null) {
throw new NullPointerException("overlay is null");
}
@@ -764,8 +764,8 @@ 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) {
+ @NonNull
+ public static String center(@NonNull String str, int size) {
return center(str, size, " ");
}
@@ -781,8 +781,8 @@ 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) {
+ @NonNull
+ public static String center(@NonNull String str, int size, @NonNull String
delim) {
int sz = str.length();
int p = size - sz;
if (p < 1) {
@@ -803,8 +803,8 @@ public class StringUtils {
* @return String without chomped newline
* @throws NullPointerException if str is <code>null</code>
*/
- @Nonnull
- public static String chomp(@Nonnull String str) {
+ @NonNull
+ public static String chomp(@NonNull String str) {
return chomp(str, "\n");
}
@@ -817,8 +817,8 @@ 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) {
+ @NonNull
+ public static String chomp(@NonNull String str, @NonNull String sep) {
int idx = str.lastIndexOf(sep);
if (idx != -1) {
return str.substring(0, idx);
@@ -835,8 +835,8 @@ public class StringUtils {
* @return String without chomped ending
* @throws NullPointerException if str is <code>null</code>
*/
- @Nonnull
- public static String chompLast(@Nonnull String str) {
+ @NonNull
+ public static String chompLast(@NonNull String str) {
return chompLast(str, "\n");
}
@@ -848,8 +848,8 @@ 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) {
+ @NonNull
+ public static String chompLast(@NonNull String str, @NonNull String sep) {
if (str.length() == 0) {
return str;
}
@@ -870,8 +870,8 @@ 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) {
+ @NonNull
+ public static String getChomp(@NonNull String str, @NonNull String sep) {
int idx = str.lastIndexOf(sep);
if (idx == str.length() - sep.length()) {
return sep;
@@ -891,8 +891,8 @@ 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) {
+ @NonNull
+ public static String prechomp(@NonNull String str, @NonNull String sep) {
int idx = str.indexOf(sep);
if (idx != -1) {
return str.substring(idx + sep.length());
@@ -910,8 +910,8 @@ 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)
{
+ @NonNull
+ public static String getPrechomp(@NonNull String str, @NonNull String sep)
{
int idx = str.indexOf(sep);
if (idx != -1) {
return str.substring(0, idx + sep.length());
@@ -933,8 +933,8 @@ public class StringUtils {
* @return String without last character
* @throws NullPointerException if str is <code>null</code>
*/
- @Nonnull
- public static String chop(@Nonnull String str) {
+ @NonNull
+ public static String chop(@NonNull String str) {
if ("".equals(str)) {
return "";
}
@@ -960,8 +960,8 @@ public class StringUtils {
* @return String without newline
* @throws NullPointerException if str is <code>null</code>
*/
- @Nonnull
- public static String chopNewline(@Nonnull String str) {
+ @NonNull
+ public static String chopNewline(@NonNull String str) {
int lastIdx = str.length() - 1;
char last = str.charAt(lastIdx);
if (last == '\n') {
@@ -989,8 +989,8 @@ public class StringUtils {
* @return String with escaped values
* @throws NullPointerException if str is <code>null</code>
*/
- @Nonnull
- public static String escape(@Nonnull String str) {
+ @NonNull
+ public static String escape(@NonNull String str) {
// improved with code from [email protected]
// unicode from him, and defaul for < 32's.
int sz = str.length();
@@ -1074,8 +1074,8 @@ 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) {
+ @NonNull
+ public static String repeat(@NonNull String str, int repeat) {
StringBuilder buffer = new StringBuilder(repeat * str.length());
for (int i = 0; i < repeat; i++) {
buffer.append(str);
@@ -1093,8 +1093,8 @@ 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) {
+ @NonNull
+ public static String rightPad(@NonNull String str, int size) {
return rightPad(str, size, " ");
}
@@ -1110,8 +1110,8 @@ 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) {
+ @NonNull
+ public static String rightPad(@NonNull String str, int size, @NonNull
String delim) {
size = (size - str.length()) / delim.length();
if (size > 0) {
str += repeat(delim, size);
@@ -1129,8 +1129,8 @@ 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) {
+ @NonNull
+ public static String leftPad(@NonNull String str, int size) {
return leftPad(str, size, " ");
}
@@ -1144,8 +1144,8 @@ 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) {
+ @NonNull
+ public static String leftPad(@NonNull String str, int size, @NonNull
String delim) {
size = (size - str.length()) / delim.length();
if (size > 0) {
str = repeat(delim, size) + str;
@@ -1477,7 +1477,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, @NonNull String tag) {
return getNestedString(str, tag, tag);
}
@@ -1490,7 +1490,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, @NonNull String open,
@NonNull String close) {
if (str == null) {
return null;
}
@@ -1514,7 +1514,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(@Nullable String str, @NonNull String sub) {
if (sub.equals("")) {
return 0;
}
@@ -1684,7 +1684,7 @@ public class StringUtils {
* @deprecated use {@code java.lang.Objects.toString()}
*/
@Deprecated
- @Nonnull
+ @NonNull
public static String defaultString(Object obj) {
return defaultString(obj, "");
}
@@ -1702,8 +1702,8 @@ public class StringUtils {
* @deprecated use {@code java.lang.Objects.toString()}
*/
@Deprecated
- @Nonnull
- public static String defaultString(Object obj, @Nonnull String
defaultString) {
+ @NonNull
+ public static String defaultString(Object obj, @NonNull String
defaultString) {
return (obj == null) ? defaultString : obj.toString();
}
@@ -1736,8 +1736,8 @@ public class StringUtils {
* @param delimiter the delimiter to use
* @return the reversed String
*/
- @Nonnull
- public static String reverseDelimitedString(@Nonnull String str, String
delimiter) {
+ @NonNull
+ public static String reverseDelimitedString(@NonNull String str, String
delimiter) {
// could implement manually, but simple way is to reuse other,
// probably slower, methods.
String[] strs = split(str, delimiter);
@@ -1750,7 +1750,7 @@ public class StringUtils {
*
* @param array the array to reverse
*/
- private static void reverseArray(@Nonnull String... array) {
+ private static void reverseArray(@NonNull String... array) {
int i = 0;
int j = array.length - 1;
String tmp;
@@ -1779,8 +1779,8 @@ public class StringUtils {
* @param maxWidth maximum length of result string
* @return The abbreviated string.
*/
- @Nonnull
- public static String abbreviate(@Nonnull String s, int maxWidth) {
+ @NonNull
+ public static String abbreviate(@NonNull String s, int maxWidth) {
return abbreviate(s, 0, maxWidth);
}
@@ -1799,8 +1799,8 @@ 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) {
+ @NonNull
+ public static String abbreviate(@NonNull String s, int offset, int
maxWidth) {
if (maxWidth < 4) {
throw new IllegalArgumentException("Minimum abbreviation width is
4");
}
@@ -1840,7 +1840,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(@NonNull String s1, @NonNull String s2) {
int at = differenceAt(s1, s2);
if (at == -1) {
return "";
@@ -1858,7 +1858,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(@NonNull String s1, @NonNull String s2) {
int i;
for (i = 0; (i < s1.length()) && (i < s2.length()); ++i) {
if (s1.charAt(i) != s2.charAt(i)) {
@@ -1880,7 +1880,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, @NonNull Map<?, ?>
namespace) {
for (Map.Entry<?, ?> entry : namespace.entrySet()) {
String key = entry.getKey().toString();
@@ -1914,8 +1914,8 @@ 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) {
+ @NonNull
+ public static String removeAndHump(@NonNull String data, @NonNull String
replaceThis) {
String temp;
StringBuilder out = new StringBuilder();
@@ -1942,8 +1942,8 @@ 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) {
+ @NonNull
+ public static String capitalizeFirstLetter(@NonNull String data) {
char firstChar = data.charAt(0);
char titleCase = Character.toTitleCase(firstChar);
if (firstChar == titleCase) {
@@ -1964,8 +1964,8 @@ 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) {
+ @NonNull
+ public static String lowercaseFirstLetter(@NonNull String data) {
char firstLetter = Character.toLowerCase(data.substring(0,
1).charAt(0));
String restLetters = data.substring(1);
@@ -1980,8 +1980,8 @@ public class StringUtils {
* @param view the view
* @return deHumped String
*/
- @Nonnull
- public static String addAndDeHump(@Nonnull String view) {
+ @NonNull
+ public static String addAndDeHump(@NonNull String view) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < view.length(); i++) {
@@ -2027,7 +2027,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(@Nullable String source, char
quoteChar, @NonNull char[] quotingTriggers) {
return quoteAndEscape(source, quoteChar, new char[] {quoteChar},
quotingTriggers, '\\', false);
}
@@ -2044,7 +2044,7 @@ public class StringUtils {
public static String quoteAndEscape(
@Nullable String source,
char quoteChar,
- @Nonnull final char[] escapedChars,
+ @NonNull final char[] escapedChars,
char escapeChar,
boolean force) {
return quoteAndEscape(source, quoteChar, escapedChars, new char[] {'
'}, escapeChar, force);
@@ -2062,8 +2062,8 @@ public class StringUtils {
public static String quoteAndEscape(
@Nullable String source,
char quoteChar,
- @Nonnull final char[] escapedChars,
- @Nonnull final char[] quotingTriggers,
+ @NonNull final char[] escapedChars,
+ @NonNull final char[] quotingTriggers,
char escapeChar,
boolean force) {
if (source == null) {
@@ -2105,7 +2105,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(@Nullable String source, @NonNull final char[]
escapedChars, char escapeChar) {
if (source == null) {
return null;
}
@@ -2136,8 +2136,8 @@ public class StringUtils {
* @return a string with unique whitespace
*
*/
- @Nonnull
- public static String removeDuplicateWhitespace(@Nonnull String s) {
+ @NonNull
+ public static String removeDuplicateWhitespace(@NonNull String s) {
StringBuilder result = new StringBuilder();
int length = s.length();
boolean isPreviousWhiteSpace = 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..c84315c 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;
@@ -32,6 +30,7 @@ import java.io.Writer;
import java.nio.charset.Charset;
import org.apache.maven.shared.utils.xml.XmlStreamWriter;
+import org.jspecify.annotations.NonNull;
/**
* Utility to create Writers, with explicit encoding choice: platform default,
@@ -115,7 +114,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(@NonNull OutputStream out)
throws IOException {
return new XmlStreamWriter(out);
}
@@ -129,7 +128,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(@NonNull File file) throws
IOException {
return new XmlStreamWriter(file);
}
@@ -141,7 +140,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(@NonNull OutputStream out) {
return new OutputStreamWriter(out);
}
@@ -154,7 +153,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(@NonNull File file) throws
IOException {
return new FileWriter(file);
}
@@ -171,7 +170,7 @@ public class WriterFactory {
* @deprecated use {@code new OutputStreamWriter(out, encoding)} instead
*/
@Deprecated
- public static Writer newWriter(@Nonnull OutputStream out, @Nonnull String
encoding)
+ public static Writer newWriter(@NonNull OutputStream out, @NonNull String
encoding)
throws UnsupportedEncodingException {
return new OutputStreamWriter(out, encoding);
}
@@ -190,7 +189,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(@NonNull File file, @NonNull 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..99fd1e6 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;
@@ -33,6 +30,8 @@ import java.util.concurrent.TimeUnit;
import org.apache.maven.shared.utils.Os;
import org.apache.maven.shared.utils.StringUtils;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
/**
* @author <a href="mailto:[email protected]">Trygve Laugstøl </a>
@@ -73,7 +72,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(@NonNull Commandline cl,
StreamConsumer systemOut, StreamConsumer systemErr)
throws CommandLineException {
return executeCommandLine(cl, null, systemOut, systemErr, 0);
}
@@ -87,7 +86,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)
+ @NonNull Commandline cl, StreamConsumer systemOut, StreamConsumer
systemErr, int timeoutInSeconds)
throws CommandLineException {
return executeCommandLine(cl, null, systemOut, systemErr,
timeoutInSeconds);
}
@@ -101,7 +100,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)
+ @NonNull Commandline cl, InputStream systemIn, StreamConsumer
systemOut, StreamConsumer systemErr)
throws CommandLineException {
return executeCommandLine(cl, systemIn, systemOut, systemErr, 0);
}
@@ -116,7 +115,7 @@ public abstract class CommandLineUtils {
* @throws CommandLineException or CommandLineTimeOutException if time out
occurs
*/
public static int executeCommandLine(
- @Nonnull Commandline cl,
+ @NonNull Commandline cl,
InputStream systemIn,
StreamConsumer systemOut,
StreamConsumer systemErr,
@@ -137,7 +136,7 @@ public abstract class CommandLineUtils {
* @throws CommandLineException or CommandLineTimeOutException if time out
occurs
*/
public static int executeCommandLine(
- @Nonnull Commandline cl,
+ @NonNull Commandline cl,
InputStream systemIn,
StreamConsumer systemOut,
StreamConsumer systemErr,
@@ -161,7 +160,7 @@ public abstract class CommandLineUtils {
* @throws CommandLineException or CommandLineTimeOutException if time out
occurs
*/
public static int executeCommandLine(
- @Nonnull Commandline cl,
+ @NonNull Commandline cl,
InputStream systemIn,
StreamConsumer systemOut,
StreamConsumer systemErr,
@@ -189,7 +188,7 @@ public abstract class CommandLineUtils {
* @throws CommandLineException or CommandLineTimeOutException if time out
occurs
*/
public static CommandLineCallable executeCommandLineAsCallable(
- @Nonnull final Commandline cl,
+ @NonNull final Commandline cl,
@Nullable final InputStream systemIn,
final StreamConsumer systemOut,
final StreamConsumer systemErr,
@@ -216,7 +215,7 @@ public abstract class CommandLineUtils {
* @throws CommandLineException or CommandLineTimeOutException if time out
occurs
*/
public static CommandLineCallable executeCommandLineAsCallable(
- @Nonnull final Commandline cl,
+ @NonNull final Commandline cl,
@Nullable final InputStream systemIn,
final StreamConsumer systemOut,
final StreamConsumer systemErr,
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..cbe6c18 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;
@@ -27,6 +25,8 @@ import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.Charset;
+import org.jspecify.annotations.Nullable;
+
/**
* Class to pump the error stream during Process's runtime. Copied from the
Ant built-in task.
*
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..f8c58de 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;
@@ -30,6 +27,8 @@ import java.util.WeakHashMap;
import org.apache.maven.shared.utils.StringUtils;
import
org.apache.maven.shared.utils.introspection.MethodMap.AmbiguousException;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
/**
* <p>Using simple dotted expressions to extract the values from an Object
instance,
@@ -141,7 +140,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(@NonNull String expression, @Nullable Object
root) throws IntrospectionException {
return evaluate(expression, root, true);
}
@@ -163,7 +162,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)
+ public static Object evaluate(@NonNull String expression, @Nullable 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..77dc97c 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;
@@ -29,6 +26,9 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* <p>Class for scanning a directory for files/directories which match certain
criteria.</p>
* <p>
@@ -279,7 +279,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(@NonNull final File basedir) {
this.basedir = basedir;
}
@@ -553,7 +553,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(@NonNull final File dir, @NonNull final String vpath,
final boolean fast) {
String[] newfiles = dir.list();
if (newfiles == null) {
@@ -698,7 +698,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(@NonNull final String name) {
return includesPatterns.matchesPatternStart(name, isCaseSensitive);
}
@@ -709,7 +709,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(@NonNull 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..682c4da 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;
@@ -55,6 +51,8 @@ import java.util.Random;
import org.apache.commons.io.IOUtils;
import org.apache.maven.shared.utils.Os;
import org.apache.maven.shared.utils.StringUtils;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
/**
* This class provides basic facilities for manipulating files and file paths.
@@ -131,7 +129,7 @@ public class FileUtils {
* @return the default excludes pattern
* @see DirectoryScanner#DEFAULTEXCLUDES
*/
- @Nonnull
+ @NonNull
public static String[] getDefaultExcludes() {
return DirectoryScanner.DEFAULTEXCLUDES;
}
@@ -140,7 +138,7 @@ public class FileUtils {
* @return the default excludes pattern as list
* @see #getDefaultExcludes()
*/
- @Nonnull
+ @NonNull
public static List<String> getDefaultExcludesAsList() {
return Arrays.asList(getDefaultExcludes());
}
@@ -150,7 +148,7 @@ public class FileUtils {
* @see DirectoryScanner#DEFAULTEXCLUDES
* @see StringUtils#join(Object[], String)
*/
- @Nonnull
+ @NonNull
public static String getDefaultExcludesAsString() {
return StringUtils.join(DirectoryScanner.DEFAULTEXCLUDES, ",");
}
@@ -164,8 +162,8 @@ public class FileUtils {
* @deprecated use {@code Paths.get(path).getParent().getName()}
*/
@Deprecated
- @Nonnull
- public static String dirname(@Nonnull String path) {
+ @NonNull
+ public static String dirname(@NonNull String path) {
int i = path.lastIndexOf(File.separator);
return (i >= 0 ? path.substring(0, i) : "");
}
@@ -178,8 +176,8 @@ public class FileUtils {
* @deprecated use {@code Paths.get(path).getName()}
*/
@Deprecated
- @Nonnull
- public static String filename(@Nonnull String path) {
+ @NonNull
+ public static String filename(@NonNull String path) {
int i = path.lastIndexOf(File.separator);
return (i >= 0 ? path.substring(i + 1) : path);
}
@@ -193,8 +191,8 @@ public class FileUtils {
* @deprecated use {@code org.apache.commons.io.FilenameUtils.getExtension}
*/
@Deprecated
- @Nonnull
- public static String extension(@Nonnull String path) {
+ @NonNull
+ public static String extension(@NonNull String path) {
// Ensure the last dot is after the last file separator
int lastSep = path.lastIndexOf(File.separatorChar);
int lastDot;
@@ -222,7 +220,7 @@ public class FileUtils {
* @deprecated use {@code java.io.File.exists()}
*/
@Deprecated
- public static boolean fileExists(@Nonnull String fileName) {
+ public static boolean fileExists(@NonNull String fileName) {
File file = new File(fileName);
return file.exists();
}
@@ -236,8 +234,8 @@ 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 {
+ @NonNull
+ public static String fileRead(@NonNull String file) throws IOException {
return fileRead(file, null);
}
@@ -249,8 +247,8 @@ 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 {
+ @NonNull
+ private static String fileRead(@NonNull String file, @Nullable String
encoding) throws IOException {
return fileRead(new File(file), encoding);
}
@@ -263,8 +261,8 @@ 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 {
+ @NonNull
+ public static String fileRead(@NonNull File file) throws IOException {
return fileRead(file, null);
}
@@ -276,8 +274,8 @@ 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 {
+ @NonNull
+ public static String fileRead(@NonNull File file, @Nullable String
encoding) throws IOException {
Charset charset = charset(encoding);
StringBuilder buf = new StringBuilder();
@@ -302,8 +300,8 @@ public class FileUtils {
* @deprecated use {@code java.nio.files.Files.readAllLines()}
*/
@Deprecated
- @Nonnull
- public static String[] fileReadArray(@Nonnull File file) throws
IOException {
+ @NonNull
+ public static String[] fileReadArray(@NonNull File file) throws
IOException {
List<String> lines = loadFile(file);
return lines.toArray(new String[lines.size()]);
@@ -320,7 +318,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(@NonNull String fileName, @NonNull String
data) throws IOException {
fileAppend(fileName, null, data);
}
@@ -335,7 +333,7 @@ public class FileUtils {
* StandardOpenOption.APPEND, StandardOpenOption.CREATE)}
*/
@Deprecated
- public static void fileAppend(@Nonnull String fileName, @Nullable String
encoding, @Nonnull String data)
+ public static void fileAppend(@NonNull String fileName, @Nullable String
encoding, @NonNull String data)
throws IOException {
Charset charset = charset(encoding);
@@ -355,7 +353,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(@NonNull String fileName, @NonNull String
data) throws IOException {
fileWrite(fileName, null, data);
}
@@ -370,7 +368,7 @@ public class FileUtils {
* data.getBytes(encoding), StandardOpenOption.CREATE)}
*/
@Deprecated
- public static void fileWrite(@Nonnull String fileName, @Nullable String
encoding, @Nonnull String data)
+ public static void fileWrite(@NonNull String fileName, @Nullable String
encoding, @NonNull String data)
throws IOException {
File file = new File(fileName);
fileWrite(file, encoding, data);
@@ -387,7 +385,7 @@ public class FileUtils {
* data.getBytes(encoding), StandardOpenOption.CREATE)}
*/
@Deprecated
- public static void fileWrite(@Nonnull File file, @Nullable String
encoding, @Nonnull String data)
+ public static void fileWrite(@NonNull File file, @Nullable String
encoding, @NonNull String data)
throws IOException {
Charset charset = charset(encoding);
@@ -407,7 +405,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(@NonNull File file, @Nullable String...
data) throws IOException {
fileWriteArray(file, null, data);
}
@@ -422,7 +420,7 @@ public class FileUtils {
* data.getBytes(encoding), StandardOpenOption.CREATE)}
*/
@Deprecated
- public static void fileWriteArray(@Nonnull File file, @Nullable String
encoding, @Nullable String... data)
+ public static void fileWriteArray(@NonNull File file, @Nullable String
encoding, @Nullable String... data)
throws IOException {
Charset charset = charset(encoding);
@@ -441,7 +439,7 @@ public class FileUtils {
* @deprecated use {@code Files.delete(Paths.get(fileName))}
*/
@Deprecated
- public static void fileDelete(@Nonnull String fileName) {
+ public static void fileDelete(@NonNull String fileName) {
File file = new File(fileName);
deleteLegacyStyle(file);
}
@@ -455,7 +453,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(@NonNull String directory,
@NonNull String... extensions) {
List<String> files = new ArrayList<>();
File currentDir = new File(directory);
@@ -501,8 +499,8 @@ public class FileUtils {
/**
* Private helper method for getFilesFromExtension()
*/
- @Nonnull
- private static List<String> blendFilesToList(@Nonnull List<String> v,
@Nonnull String... files) {
+ @NonNull
+ private static List<String> blendFilesToList(@NonNull List<String> v,
@NonNull String... files) {
Collections.addAll(v, files);
return v;
@@ -513,7 +511,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(@NonNull String file, @NonNull
String... extensions) {
String extension = extension(file);
// ok.. now that we have the "extension" go through the current know
@@ -537,7 +535,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(@NonNull String dir) {
File file = new File(dir);
if (Os.isFamily(Os.FAMILY_WINDOWS) && !isValidWindowsFileName(file)) {
@@ -562,7 +560,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(@NonNull final File file1, @NonNull
final File file2) throws IOException {
final boolean file1Exists = file1.exists();
if (file1Exists != file2.exists()) {
return false;
@@ -616,8 +614,8 @@ 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 {
+ @NonNull
+ public static URL[] toURLs(@NonNull final File... files) throws
IOException {
final URL[] urls = new URL[files.length];
for (int i = 0; i < urls.length; i++) {
@@ -640,8 +638,8 @@ public class FileUtils {
* @deprecated use {@code
org.apache.commons.io.FilenameUtils.removeExtension()}
*/
@Deprecated
- @Nonnull
- public static String removeExtension(@Nonnull final String filename) {
+ @NonNull
+ public static String removeExtension(@NonNull final String filename) {
String ext = extension(filename);
if ("".equals(ext)) {
@@ -666,8 +664,8 @@ public class FileUtils {
* @deprecated use {@code
org.apache.commons.io.FilenameUtils.getExtension()}
*/
@Deprecated
- @Nonnull
- public static String getExtension(@Nonnull final String filename) {
+ @NonNull
+ public static String getExtension(@NonNull final String filename) {
return extension(filename);
}
@@ -686,7 +684,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)
+ public static void copyFileToDirectory(@NonNull final File source,
@NonNull final File destinationDirectory)
throws IOException {
if (destinationDirectory.exists() &&
!destinationDirectory.isDirectory()) {
throw new IOException("Destination is not a directory");
@@ -710,7 +708,7 @@ public class FileUtils {
* occurs during copying
*/
private static void copyFileToDirectoryIfModified(
- @Nonnull final File source, @Nonnull final File
destinationDirectory) throws IOException {
+ @NonNull final File source, @NonNull final File
destinationDirectory) throws IOException {
if (destinationDirectory.exists() &&
!destinationDirectory.isDirectory()) {
throw new IllegalArgumentException("Destination is not a
directory");
}
@@ -733,7 +731,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(@NonNull final File source, @NonNull final
File destination) throws IOException {
// check source exists
if (!source.exists()) {
final String message = "File " + source + " does not exist";
@@ -761,7 +759,7 @@ public class FileUtils {
}
}
- private static void mkdirsFor(@Nonnull File destination) {
+ private static void mkdirsFor(@NonNull File destination) {
// does destination directory exist ?
if (destination.getParentFile() != null &&
!destination.getParentFile().exists()) {
//noinspection ResultOfMethodCallIgnored
@@ -769,7 +767,7 @@ public class FileUtils {
}
}
- private static void doCopyFile(@Nonnull File source, @Nonnull File
destination) throws IOException {
+ private static void doCopyFile(@NonNull File source, @NonNull File
destination) throws IOException {
try (FileInputStream fis = new FileInputStream(source);
FileOutputStream fos = new FileOutputStream(destination);
@@ -800,7 +798,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)
+ private static boolean copyFileIfModified(@NonNull final File source,
@NonNull final File destination)
throws IOException {
if (destination.lastModified() < source.lastModified()) {
copyFile(source, destination);
@@ -828,7 +826,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(@NonNull final URL source, @NonNull final
File destination) throws IOException {
copyStreamToFile(source.openStream(), destination);
}
@@ -851,7 +849,7 @@ public class FileUtils {
* StandardCopyOption.REPLACE_EXISTING)}
*/
@Deprecated
- private static void copyStreamToFile(@Nonnull @WillClose final InputStream
source, @Nonnull final File destination)
+ private static void copyStreamToFile(@NonNull final InputStream source,
@NonNull final File destination)
throws IOException {
// does destination directory exist ?
if (destination.getParentFile() != null &&
!destination.getParentFile().exists()) {
@@ -891,8 +889,8 @@ public class FileUtils {
* @deprecated use {@code org.apache.commons.io.FileNameUtils.normalize()}
*/
@Deprecated
- @Nonnull
- public static String normalize(@Nonnull final String path) {
+ @NonNull
+ public static String normalize(@NonNull final String path) {
String normalized = path;
// Resolve occurrences of "//" in the normalized path
while (true) {
@@ -938,8 +936,8 @@ 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) {
+ @NonNull
+ public static File resolveFile(final File baseFile, @NonNull String
filename) {
String filenm = filename;
if ('/' != File.separatorChar) {
filenm = filename.replace('/', File.separatorChar);
@@ -1005,7 +1003,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(@NonNull final String file) throws
IOException {
forceDelete(new File(file));
}
@@ -1017,7 +1015,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(@NonNull final File file) throws
IOException {
if (file.isDirectory()) {
deleteDirectory(file);
} else {
@@ -1041,7 +1039,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(@NonNull File file) throws IOException {
Files.delete(file.toPath());
}
@@ -1051,7 +1049,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(@NonNull File file) {
try {
Files.delete(file.toPath());
return true;
@@ -1068,7 +1066,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(@NonNull File file) throws IOException {
if (file.isDirectory()) {
throw new IOException("File " + file + " isn't a file.");
}
@@ -1099,7 +1097,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(@NonNull 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 +1126,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(@NonNull final String directory) throws
IOException {
deleteDirectory(new File(directory));
}
@@ -1140,7 +1138,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(@NonNull final File directory) throws
IOException {
if (!directory.exists()) {
return;
}
@@ -1168,7 +1166,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(@NonNull final File directory) throws
IOException {
if (!directory.exists()) {
final String message = directory + " does not exist";
throw new IllegalArgumentException(message);
@@ -1208,7 +1206,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(@NonNull final String directory) {
return sizeOfDirectory(new File(directory));
}
@@ -1220,7 +1218,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(@NonNull final File directory) {
if (!directory.exists()) {
final String message = directory + " does not exist";
throw new IllegalArgumentException(message);
@@ -1262,8 +1260,8 @@ 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)
+ @NonNull
+ public static List<File> getFiles(@NonNull File directory, @Nullable
String includes, @Nullable String excludes)
throws IOException {
return getFiles(directory, includes, excludes, true);
}
@@ -1283,9 +1281,9 @@ public class FileUtils {
* @throws IOException never
* @see #getFileNames(File, String, String, boolean)
*/
- @Nonnull
+ @NonNull
public static List<File> getFiles(
- @Nonnull File directory, @Nullable String includes, @Nullable
String excludes, boolean includeBasedir)
+ @NonNull File directory, @Nullable String includes, @Nullable
String excludes, boolean includeBasedir)
throws IOException {
List<String> fileNames = getFileNames(directory, includes, excludes,
includeBasedir);
@@ -1311,9 +1309,9 @@ public class FileUtils {
* @return a list of file names
* @throws IOException never
*/
- @Nonnull
+ @NonNull
public static List<String> getFileNames(
- @Nonnull File directory, @Nullable String includes, @Nullable
String excludes, boolean includeBasedir)
+ @NonNull File directory, @Nullable String includes, @Nullable
String excludes, boolean includeBasedir)
throws IOException {
return getFileNames(directory, includes, excludes, includeBasedir,
true);
}
@@ -1331,9 +1329,9 @@ 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
+ @NonNull
private static List<String> getFileNames(
- @Nonnull File directory,
+ @NonNull File directory,
@Nullable String includes,
@Nullable String excludes,
boolean includeBasedir,
@@ -1353,9 +1351,9 @@ public class FileUtils {
* @return a list of relative paths of directories
* @throws IOException never
*/
- @Nonnull
+ @NonNull
public static List<String> getDirectoryNames(
- @Nonnull File directory, @Nullable String includes, @Nullable
String excludes, boolean includeBasedir)
+ @NonNull File directory, @Nullable String includes, @Nullable
String excludes, boolean includeBasedir)
throws IOException {
return getDirectoryNames(directory, includes, excludes,
includeBasedir, true);
}
@@ -1372,9 +1370,9 @@ public class FileUtils {
* @return a list of relative paths of directories
* @throws IOException never
*/
- @Nonnull
+ @NonNull
public static List<String> getDirectoryNames(
- @Nonnull File directory,
+ @NonNull File directory,
@Nullable String includes,
@Nullable String excludes,
boolean includeBasedir,
@@ -1396,7 +1394,7 @@ public class FileUtils {
* @param getDirectories true to include directories in the list
* @return a list of relative paths
*/
- @Nonnull
+ @NonNull
public static List<String> getFileAndDirectoryNames(
File directory,
@Nullable String includes,
@@ -1460,7 +1458,7 @@ public class FileUtils {
* @deprecated use {@code org.apache.commons.io.FileUtils.copyDirectory()}
*/
@Deprecated
- public static void copyDirectory(@Nonnull File sourceDirectory, @Nonnull
File destinationDirectory)
+ public static void copyDirectory(@NonNull File sourceDirectory, @NonNull
File destinationDirectory)
throws IOException {
Objects.requireNonNull(sourceDirectory);
Objects.requireNonNull(destinationDirectory);
@@ -1487,8 +1485,8 @@ public class FileUtils {
*/
@Deprecated
public static void copyDirectory(
- @Nonnull File sourceDirectory,
- @Nonnull File destinationDirectory,
+ @NonNull File sourceDirectory,
+ @NonNull File destinationDirectory,
@Nullable String includes,
@Nullable String excludes)
throws IOException {
@@ -1519,14 +1517,14 @@ public class FileUtils {
* @deprecated use {@code org.apache.commons.io.FileUtils.copyDirectory()}
*/
@Deprecated
- public static void copyDirectoryStructure(@Nonnull File sourceDirectory,
@Nonnull File destinationDirectory)
+ public static void copyDirectoryStructure(@NonNull File sourceDirectory,
@NonNull File destinationDirectory)
throws IOException {
copyDirectoryStructure(sourceDirectory, destinationDirectory,
destinationDirectory, false);
}
private static void copyDirectoryStructure(
- @Nonnull File sourceDirectory,
- @Nonnull File destinationDirectory,
+ @NonNull File sourceDirectory,
+ @NonNull File destinationDirectory,
File rootDestinationDirectory,
boolean onlyModifiedFiles)
throws IOException {
@@ -1603,7 +1601,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(@NonNull File from, @NonNull File to) throws
IOException {
if (to.exists() && !deleteLegacyStyle(to)) {
throw new IOException("Failed to delete " + to + " while trying to
rename " + from);
}
@@ -1644,7 +1642,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(@NonNull String prefix, @NonNull String
suffix, @Nullable File parentDir) {
File result;
String parent = System.getProperty("java.io.tmpdir");
if (parentDir != null) {
@@ -1681,7 +1679,7 @@ public class FileUtils {
*/
@Deprecated
public static void copyFile(
- @Nonnull File from, @Nonnull File to, @Nullable String encoding,
@Nullable FilterWrapper... wrappers)
+ @NonNull File from, @NonNull File to, @Nullable String encoding,
@Nullable FilterWrapper... wrappers)
throws IOException {
copyFile(from, to, encoding, wrappers, false);
}
@@ -1715,8 +1713,8 @@ public class FileUtils {
*/
@Deprecated
public static void copyFile(
- @Nonnull File from,
- @Nonnull File to,
+ @NonNull File from,
+ @NonNull File to,
@Nullable String encoding,
@Nullable FilterWrapper[] wrappers,
boolean overwrite)
@@ -1810,7 +1808,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(@NonNull File source, @NonNull
File destination) throws IOException {
try {
// attempt to copy posix file permissions
Files.setPosixFilePermissions(destination.toPath(),
Files.getPosixFilePermissions(source.toPath()));
@@ -1831,8 +1829,8 @@ public class FileUtils {
* @deprecated assumes the platform default character set
*/
@Deprecated
- @Nonnull
- public static List<String> loadFile(@Nonnull File file) throws IOException
{
+ @NonNull
+ public static List<String> loadFile(@NonNull File file) throws IOException
{
List<String> lines = new ArrayList<>();
if (file.exists()) {
@@ -1871,7 +1869,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(@NonNull File f) {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
if (StringUtils.indexOfAny(f.getName(),
INVALID_CHARACTERS_FOR_WINDOWS_FILE_NAME) != -1) {
return false;
@@ -1894,7 +1892,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(@NonNull final File file) throws
IOException {
return Files.isSymbolicLink(file.toPath());
}
@@ -1908,7 +1906,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(@NonNull final File file)
throws IOException {
return Files.isSymbolicLink(file.toPath());
}
@@ -1922,8 +1920,8 @@ 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 {
+ @NonNull
+ public static File createSymbolicLink(@NonNull File symlink, @NonNull 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..1515a86 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;
@@ -35,6 +32,9 @@ import java.io.StringWriter;
import java.io.Writer;
import java.nio.channels.Channel;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* <p>General IO Stream manipulation.</p>
* <p>
@@ -133,7 +133,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(@NonNull final InputStream input, @NonNull final
OutputStream output) throws IOException {
copy(input, output, DEFAULT_BUFFER_SIZE);
}
@@ -150,7 +150,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(@NonNull final InputStream input, @NonNull final
OutputStream output, final int bufferSize)
throws IOException {
final byte[] buffer = new byte[bufferSize];
int n;
@@ -167,7 +167,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(@NonNull final Reader input, @NonNull final Writer
output) throws IOException {
copy(input, output, DEFAULT_BUFFER_SIZE);
}
@@ -181,7 +181,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)
+ public static void copy(@NonNull final Reader input, @NonNull final Writer
output, final int bufferSize)
throws IOException {
final char[] buffer = new char[bufferSize];
int n;
@@ -211,7 +211,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(@NonNull final InputStream input, @NonNull final
Writer output) throws IOException {
copy(input, output, DEFAULT_BUFFER_SIZE);
}
@@ -227,7 +227,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)
+ public static void copy(@NonNull final InputStream input, @NonNull final
Writer output, final int bufferSize)
throws IOException {
final InputStreamReader in = new InputStreamReader(input);
copy(in, output, bufferSize);
@@ -247,7 +247,7 @@ public final class IOUtil
*/
@Deprecated
public static void copy(
- @Nonnull final InputStream input, @Nonnull final Writer output,
@Nonnull final String encoding)
+ @NonNull final InputStream input, @NonNull final Writer output,
@NonNull final String encoding)
throws IOException {
final InputStreamReader in = new InputStreamReader(input, encoding);
copy(in, output);
@@ -268,9 +268,9 @@ public final class IOUtil
*/
@Deprecated
public static void copy(
- @Nonnull final InputStream input,
- @Nonnull final Writer output,
- @Nonnull final String encoding,
+ @NonNull final InputStream input,
+ @NonNull final Writer output,
+ @NonNull final String encoding,
final int bufferSize)
throws IOException {
final InputStreamReader in = new InputStreamReader(input, encoding);
@@ -290,8 +290,8 @@ public final class IOUtil
* @deprecated always specify a character encoding
*/
@Deprecated
- @Nonnull
- public static String toString(@Nonnull final InputStream input) throws
IOException {
+ @NonNull
+ public static String toString(@NonNull final InputStream input) throws
IOException {
return toString(input, DEFAULT_BUFFER_SIZE);
}
@@ -306,8 +306,8 @@ 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 {
+ @NonNull
+ public static String toString(@NonNull final InputStream input, final int
bufferSize) throws IOException {
final StringWriter sw = new StringWriter();
copy(input, sw, bufferSize);
return sw.toString();
@@ -325,8 +325,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) throws IOException {
+ @NonNull
+ public static String toString(@NonNull final InputStream input, @NonNull
final String encoding) throws IOException {
return toString(input, encoding, DEFAULT_BUFFER_SIZE);
}
@@ -343,9 +343,9 @@ public final class IOUtil
* @deprecated use {@code org.apache.commons.io.IOUtils.toString()}.
*/
@Deprecated
- @Nonnull
+ @NonNull
public static String toString(
- @Nonnull final InputStream input, @Nonnull final String encoding,
final int bufferSize) throws IOException {
+ @NonNull final InputStream input, @NonNull final String encoding,
final int bufferSize) throws IOException {
final StringWriter sw = new StringWriter();
copy(input, sw, encoding, bufferSize);
return sw.toString();
@@ -363,8 +363,8 @@ 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 {
+ @NonNull
+ public static byte[] toByteArray(@NonNull final InputStream input) throws
IOException {
return toByteArray(input, DEFAULT_BUFFER_SIZE);
}
@@ -378,8 +378,8 @@ 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 {
+ @NonNull
+ public static byte[] toByteArray(@NonNull final InputStream input, final
int bufferSize) throws IOException {
final ByteArrayOutputStream output = new ByteArrayOutputStream();
copy(input, output, bufferSize);
return output.toByteArray();
@@ -403,7 +403,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(@NonNull final Reader input, @NonNull final
OutputStream output) throws IOException {
copy(input, output, DEFAULT_BUFFER_SIZE);
}
@@ -418,7 +418,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)
+ public static void copy(@NonNull final Reader input, @NonNull final
OutputStream output, final int bufferSize)
throws IOException {
final OutputStreamWriter out = new OutputStreamWriter(output);
copy(input, out, bufferSize);
@@ -438,8 +438,8 @@ 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 {
+ @NonNull
+ public static String toString(@NonNull final Reader input) throws
IOException {
return toString(input, DEFAULT_BUFFER_SIZE);
}
@@ -453,8 +453,8 @@ 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 {
+ @NonNull
+ public static String toString(@NonNull final Reader input, final int
bufferSize) throws IOException {
final StringWriter sw = new StringWriter();
copy(input, sw, bufferSize);
return sw.toString();
@@ -472,8 +472,8 @@ public final class IOUtil
* @deprecated always specify a character encoding
*/
@Deprecated
- @Nonnull
- public static byte[] toByteArray(@Nonnull final Reader input) throws
IOException {
+ @NonNull
+ public static byte[] toByteArray(@NonNull final Reader input) throws
IOException {
return toByteArray(input, DEFAULT_BUFFER_SIZE);
}
@@ -487,8 +487,8 @@ 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 {
+ @NonNull
+ public static byte[] toByteArray(@NonNull final Reader input, final int
bufferSize) throws IOException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
copy(input, output, bufferSize);
return output.toByteArray();
@@ -511,7 +511,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(@NonNull final String input, @NonNull final
OutputStream output) throws IOException {
copy(input, output, DEFAULT_BUFFER_SIZE);
}
@@ -526,7 +526,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)
+ public static void copy(@NonNull final String input, @NonNull final
OutputStream output, final int bufferSize)
throws IOException {
final StringReader in = new StringReader(input);
final OutputStreamWriter out = new OutputStreamWriter(output);
@@ -548,7 +548,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(@NonNull final String input, @NonNull final Writer
output) throws IOException {
output.write(input);
}
@@ -564,8 +564,8 @@ public final class IOUtil
* @deprecated always specify a character encoding
*/
@Deprecated
- @Nonnull
- public static byte[] toByteArray(@Nonnull final String input) throws
IOException {
+ @NonNull
+ public static byte[] toByteArray(@NonNull final String input) throws
IOException {
return toByteArray(input, DEFAULT_BUFFER_SIZE);
}
@@ -579,8 +579,8 @@ 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 {
+ @NonNull
+ public static byte[] toByteArray(@NonNull final String input, final int
bufferSize) throws IOException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
copy(input, output, bufferSize);
return output.toByteArray();
@@ -605,7 +605,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(@NonNull final byte[] input, @NonNull final Writer
output) throws IOException {
copy(input, output, DEFAULT_BUFFER_SIZE);
}
@@ -621,7 +621,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)
+ public static void copy(@NonNull final byte[] input, @NonNull final Writer
output, final int bufferSize)
throws IOException {
final ByteArrayInputStream in = new ByteArrayInputStream(input);
copy(in, output, bufferSize);
@@ -640,7 +640,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)
+ public static void copy(@NonNull final byte[] input, @NonNull final Writer
output, final String encoding)
throws IOException {
final ByteArrayInputStream in = new ByteArrayInputStream(input);
copy(in, output, encoding);
@@ -661,9 +661,9 @@ public final class IOUtil
*/
@Deprecated
public static void copy(
- @Nonnull final byte[] input,
- @Nonnull final Writer output,
- @Nonnull final String encoding,
+ @NonNull final byte[] input,
+ @NonNull final Writer output,
+ @NonNull final String encoding,
final int bufferSize)
throws IOException {
final ByteArrayInputStream in = new ByteArrayInputStream(input);
@@ -682,8 +682,8 @@ public final class IOUtil
* @deprecated always specify a character encoding
*/
@Deprecated
- @Nonnull
- public static String toString(@Nonnull final byte[] input) throws
IOException {
+ @NonNull
+ public static String toString(@NonNull final byte[] input) throws
IOException {
return toString(input, DEFAULT_BUFFER_SIZE);
}
@@ -698,8 +698,8 @@ 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 {
+ @NonNull
+ public static String toString(@NonNull final byte[] input, final int
bufferSize) throws IOException {
final StringWriter sw = new StringWriter();
copy(input, sw, bufferSize);
return sw.toString();
@@ -717,8 +717,8 @@ 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 {
+ @NonNull
+ public static String toString(@NonNull final byte[] input, @NonNull final
String encoding) throws IOException {
return toString(input, encoding, DEFAULT_BUFFER_SIZE);
}
@@ -735,8 +735,8 @@ 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)
+ @NonNull
+ public static String toString(@NonNull final byte[] input, @NonNull final
String encoding, final int bufferSize)
throws IOException {
final StringWriter sw = new StringWriter();
copy(input, sw, encoding, bufferSize);
@@ -755,7 +755,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(@NonNull final byte[] input, @NonNull final
OutputStream output) throws IOException {
output.write(input);
}
@@ -769,7 +769,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)
+ public static boolean contentEquals(@NonNull final InputStream input1,
@NonNull final InputStream input2)
throws IOException {
final InputStream bufferedInput1 = new BufferedInputStream(input1);
final InputStream bufferedInput2 = new BufferedInputStream(input2);
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..1ec6443 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,12 +18,12 @@
*/
package org.apache.maven.shared.utils.io;
-import javax.annotation.Nonnull;
-
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
+import org.jspecify.annotations.NonNull;
+
/**
* Java7 feature detection
*
@@ -37,7 +37,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(@NonNull File file) {
return Files.isSymbolicLink(file.toPath());
}
@@ -46,8 +46,8 @@ public class Java7Support {
* @return The file.
* @throws IOException in case of error.
*/
- @Nonnull
- public static File readSymbolicLink(@Nonnull File symlink) throws
IOException {
+ @NonNull
+ public static File readSymbolicLink(@NonNull File symlink) throws
IOException {
return Files.readSymbolicLink(symlink.toPath()).toFile();
}
@@ -56,7 +56,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(@NonNull File file) throws IOException {
return Files.exists(file.toPath());
}
@@ -66,8 +66,8 @@ 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 {
+ @NonNull
+ public static File createSymbolicLink(@NonNull File symlink, @NonNull File
target) throws IOException {
return FileUtils.createSymbolicLink(symlink, target);
}
@@ -76,7 +76,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(@NonNull 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..2b57c01 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,14 +18,14 @@
*/
package org.apache.maven.shared.utils.io;
-import javax.annotation.Nonnull;
-
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.regex.Pattern;
+import org.jspecify.annotations.NonNull;
+
/**
* <p>Describes a match target for SelectorUtils.</p>
* <p>
@@ -46,7 +46,7 @@ public class MatchPattern {
private final String[] tokenized;
- private MatchPattern(@Nonnull String source, @Nonnull String separator) {
+ private MatchPattern(@NonNull String source, @NonNull String separator) {
regexPattern = SelectorUtils.isRegexPrefixedPattern(source)
? source.substring(
SelectorUtils.REGEX_HANDLER_PREFIX.length(),
@@ -88,7 +88,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(@NonNull 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 +116,7 @@ public class MatchPattern {
return source.startsWith(string);
}
- static String[] tokenizePathToString(@Nonnull String path, @Nonnull String
separator) {
+ static String[] tokenizePathToString(@NonNull String path, @NonNull 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..78bbf21 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,10 +18,10 @@
*/
package org.apache.maven.shared.utils.io;
-import javax.annotation.Nonnull;
-
import java.io.File;
+import org.jspecify.annotations.NonNull;
+
/**
* A list of patterns to be matched
*
@@ -32,7 +32,7 @@ import java.io.File;
public class MatchPatterns {
private final MatchPattern[] patterns;
- private MatchPatterns(@Nonnull MatchPattern... patterns) {
+ private MatchPatterns(@NonNull MatchPattern... patterns) {
this.patterns = patterns;
}
@@ -44,7 +44,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(@NonNull String name, boolean isCaseSensitive) {
String[] tokenized = MatchPattern.tokenizePathToString(name,
File.separator);
for (MatchPattern pattern : patterns) {
if (pattern.matchPath(name, tokenized, isCaseSensitive)) {
@@ -59,7 +59,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(@NonNull String name, boolean
isCaseSensitive) {
for (MatchPattern includesPattern : patterns) {
if (includesPattern.matchPatternStart(name, isCaseSensitive)) {
return true;
@@ -72,7 +72,7 @@ public class MatchPatterns {
* @param sources The sources
* @return Converted match patterns.
*/
- public static MatchPatterns from(@Nonnull String... sources) {
+ public static MatchPatterns from(@NonNull 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..f4e6293 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,13 +18,13 @@
*/
package org.apache.maven.shared.utils.io;
-import javax.annotation.Nonnull;
-
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
+import org.jspecify.annotations.NonNull;
+
/**
* <p>This is a utility class used by selectors and DirectoryScanner. The
* functionality more properly belongs just to selectors, but unfortunately
@@ -513,12 +513,12 @@ public final class SelectorUtils {
}
static boolean matchAntPathPatternStart(
- @Nonnull MatchPattern pattern, @Nonnull String str, @Nonnull
String separator, boolean isCaseSensitive) {
+ @NonNull MatchPattern pattern, @NonNull String str, @NonNull
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(@NonNull String path,
@NonNull String separator) {
List<String> ret = new ArrayList<>();
StringTokenizer st = new StringTokenizer(path, separator);
while (st.hasMoreTokens()) {
@@ -528,13 +528,13 @@ public final class SelectorUtils {
}
private static boolean matchAntPathPatternStart(
- @Nonnull String[] patDirs, @Nonnull String str, @Nonnull String
separator, boolean isCaseSensitive) {
+ @NonNull String[] patDirs, @NonNull String str, @NonNull 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) {
+ @NonNull String[] patDirs, @NonNull String[] tokenizedFileName,
boolean isCaseSensitive) {
int patIdxStart = 0;
int patIdxEnd = patDirs.length - 1;
@@ -558,7 +558,7 @@ public final class SelectorUtils {
}
private static boolean separatorPatternStartSlashMismatch(
- @Nonnull MatchPattern matchPattern, @Nonnull String str, @Nonnull
String separator) {
+ @NonNull MatchPattern matchPattern, @NonNull String str, @NonNull
String separator) {
return str.startsWith(separator) != matchPattern.startsWith(separator);
}
@@ -683,9 +683,9 @@ public final class SelectorUtils {
}
static boolean matchAntPathPattern(
- @Nonnull MatchPattern matchPattern,
- @Nonnull String str,
- @Nonnull String separator,
+ @NonNull MatchPattern matchPattern,
+ @NonNull String str,
+ @NonNull 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..c6cedd0 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;
@@ -29,6 +27,8 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import org.jspecify.annotations.NonNull;
+
/**
* A reimplementation of Plexus Xpp3Dom based on the public interface of
Plexus Xpp3Dom.
*
@@ -109,7 +109,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(@NonNull Xpp3Dom src, String name) {
this.name = name;
int size = src.getChildCount();
@@ -137,7 +137,7 @@ public class Xpp3Dom implements Iterable<Xpp3Dom> {
/**
* @return The current value.
*/
- @Nonnull
+ @NonNull
public String getValue() {
return value;
}
@@ -145,7 +145,7 @@ public class Xpp3Dom implements Iterable<Xpp3Dom> {
/**
* @param value The value to be set.
*/
- public void setValue(@Nonnull String value) {
+ public void setValue(@NonNull String value) {
this.value = value;
}
@@ -169,7 +169,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(@NonNull String nameParameter, @NonNull 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..a97e408 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;
@@ -30,6 +27,7 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.maven.shared.utils.xml.pull.XmlPullParserException;
+import org.jspecify.annotations.NonNull;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -48,7 +46,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(@NonNull Reader reader) throws
XmlPullParserException {
return build(reader, false);
}
@@ -58,7 +56,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, @NonNull String encoding)
throws XmlPullParserException {
return build(is, encoding, false);
}
@@ -71,8 +69,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, @NonNull String encoding,
boolean noop) throws XmlPullParserException {
try {
Reader reader = new InputStreamReader(is, encoding);
return build(reader);
@@ -89,7 +86,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 +96,7 @@ public class Xpp3DomBuilder {
}
}
- private static DocHandler parseSax(@Nonnull InputSource inputSource)
throws XmlPullParserException {
+ private static DocHandler parseSax(@NonNull 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..796f671 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;
@@ -44,6 +42,7 @@ import java.util.concurrent.TimeUnit;
import org.apache.commons.io.IOUtils;
import org.apache.maven.shared.utils.Os;
import org.apache.maven.shared.utils.testhelpers.FileTestHelper;
+import org.jspecify.annotations.NonNull;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
@@ -490,7 +489,7 @@ public class FileUtilsTest {
};
}
- private File write(@Nonnull String name, long lastModified, @Nonnull
String text) throws IOException {
+ private File write(@NonNull String name, long lastModified, @NonNull
String text) throws IOException {
final File file = new File(tempFolder, name);
try (Writer writer = new FileWriter(file)) {
writer.write(text);
@@ -500,7 +499,7 @@ public class FileUtilsTest {
return file;
}
- private static void assertFileContent(@Nonnull File file, @Nonnull String
expected) throws IOException {
+ private static void assertFileContent(@NonNull File file, @NonNull String
expected) throws IOException {
try (Reader in = new FileReader(file)) {
assertEquals(expected, IOUtils.toString(in), "Expected " +
file.getPath() + " to contain: " + expected);
}