Path tool contains static methods to assist in determining path-related * information such as relative paths.
@@ -198,8 +198,8 @@ public static String getRelativeFilePath(final String oldPath, final String newP * 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 @@ static String uppercaseDrive(@Nullable String path) { 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 0730828c..199def0d 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.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 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 static java.util.Properties loadProperties(@Nonnull URL url) { * 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 static Properties loadProperties(@Nullable InputStream is) { * @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 static Properties loadOptionalProperties(final @Nullable URL url) { * @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 static Properties loadOptionalProperties(final @Nullable File file) { * @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 cb0921c2..a75b0bbb 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.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 static Reader newXmlReader(@Nonnull InputStream in) throws IOException { * @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 static Reader newXmlReader(@Nonnull File file) throws IOException { * @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 static Reader newXmlReader(@Nonnull URL url) throws IOException { * @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 static Reader newPlatformReader(@Nonnull File file) throws FileNotFoundEx * @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 static Reader newReader(@Nonnull InputStream in, @Nonnull String encoding * 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 static Reader newReader(@Nonnull File file, @Nonnull String encoding) * @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 8e89c4f8..f953da9d 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; + /** *Common String manipulation routines.
String.split()) 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 static String[] split(@Nonnull String str) {
* String.split()) 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 static String[] split(@Nonnull String text, @Nullable String separator) {
* String.split()) 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 static String[] split(@Nonnull String str, @Nullable String separator, in
* @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 static String concatenate(@Nonnull Object... array) {
* @deprecated use java.lang.String.join() 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 static String join(@Nonnull Object[] array, @Nullable String separator) {
* @deprecated use java.lang.String.join() 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 static String replace(@Nullable String text, @Nullable String repl, @Null
* @return String with overlaid text
* @throws NullPointerException if text or overlay is null
*/
- @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 static String overlayString(@Nonnull String text, @Nonnull String overlay
* @return String containing centered String
* @throws NullPointerException if str is null
*/
- @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 static String center(@Nonnull String str, int size) {
* @throws NullPointerException if str or delim is null
* @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 static String center(@Nonnull String str, int size, @Nonnull String delim
* @return String without chomped newline
* @throws NullPointerException if str is null
*/
- @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 static String chomp(@Nonnull String str) {
* @return String without chomped ending
* @throws NullPointerException if str or sep is null
*/
- @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 static String chomp(@Nonnull String str, @Nonnull String sep) {
* @return String without chomped ending
* @throws NullPointerException if str is null
*/
- @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 static String chompLast(@Nonnull String str) {
* @return String without chomped ending
* @throws NullPointerException if str or sep is null
*/
- @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 static String chompLast(@Nonnull String str, @Nonnull String sep) {
* @return String chomped
* @throws NullPointerException if str or sep is null
*/
- @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 static String getChomp(@Nonnull String str, @Nonnull String sep) {
* @return String without chomped beginning
* @throws NullPointerException if str or sep is null
*/
- @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 static String prechomp(@Nonnull String str, @Nonnull String sep) {
* @return String prechomped
* @throws NullPointerException if str or sep is null
*/
- @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 static String getPrechomp(@Nonnull String str, @Nonnull String sep) {
* @return String without last character
* @throws NullPointerException if str is null
*/
- @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 static String chop(@Nonnull String str) {
* @return String without newline
* @throws NullPointerException if str is null
*/
- @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 static String chopNewline(@Nonnull String str) {
* @return String with escaped values
* @throws NullPointerException if str is null
*/
- @Nonnull
- public static String escape(@Nonnull String str) {
+ @NonNull
+ public static String escape(@NonNull String str) {
// improved with code from cybertiger@cyberiantiger.org
// unicode from him, and defaul for < 32's.
int sz = str.length();
@@ -1074,8 +1074,8 @@ else if (ch < 32) {
* @throws NegativeArraySizeException if repeat < 0
* @throws NullPointerException if str is null
*/
- @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 static String repeat(@Nonnull String str, int repeat) {
* @return right padded String
* @throws NullPointerException if str is null
*/
- @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 static String rightPad(@Nonnull String str, int size) {
* @throws NullPointerException if str or delim is null
* @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 static String rightPad(@Nonnull String str, int size, @Nonnull String del
* @return left padded String
* @throws NullPointerException if str or delim is null
*/
- @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 static String leftPad(@Nonnull String str, int size) {
* @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 static String uncapitaliseAllWords(String str) {
* @return the String that was nested, or null
* @throws NullPointerException if tag is null
*/
- 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 static String getNestedString(String str, @Nonnull String tag) {
* @return the String that was nested, or null
* @throws NullPointerException if open or close is null
*/
- 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 static String getNestedString(String str, @Nonnull String open, @Nonnull
* @return the number of occurrences, 0 if the String is null
* @throws NullPointerException if sub is null
*/
- 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 static boolean isNumeric(String str) {
* @deprecated use {@code java.lang.Objects.toString()}
*/
@Deprecated
- @Nonnull
+ @NonNull
public static String defaultString(Object obj) {
return defaultString(obj, "");
}
@@ -1702,8 +1702,8 @@ public static String defaultString(Object obj) {
* @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 static String reverse(String str) {
* @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 static String reverseDelimitedString(@Nonnull String str, String delimite
*
* @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 @@ private static void reverseArray(@Nonnull String... array) {
* @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 static String abbreviate(@Nonnull String s, int maxWidth) {
* @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 static String abbreviate(@Nonnull String s, int offset, int maxWidth) {
* @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 static String difference(@Nonnull String s1, @Nonnull String s2) {
* @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 static int differenceAt(@Nonnull String s1, @Nonnull String s2) {
* @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 static String interpolate(String text, @Nonnull Map, ?> namespace) {
* @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 static String removeAndHump(@Nonnull String data, @Nonnull String replace
* @throws NullPointerException if data is null
* @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 static String capitalizeFirstLetter(@Nonnull String data) {
* @throws NullPointerException if data is null
* @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 static String lowercaseFirstLetter(@Nonnull String data) {
* @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 static String quoteAndEscape(@Nullable String source, char quoteChar) {
* @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 static String quoteAndEscape(@Nullable String source, char quoteChar, @No
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 static String quoteAndEscape(
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 static String quoteAndEscape(
* @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 static String escape(@Nullable String source, @Nonnull final char[] escap
* @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 5088914b..c84315c5 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.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 static XmlStreamWriter newXmlWriter(@Nonnull OutputStream out) throws IOE
* @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 static XmlStreamWriter newXmlWriter(@Nonnull File file) throws IOExceptio
* @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 static Writer newPlatformWriter(@Nonnull OutputStream out) {
* @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 static Writer newPlatformWriter(@Nonnull File file) throws IOException {
* @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 static Writer newWriter(@Nonnull OutputStream out, @Nonnull String encodi
* @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 04f5cd6a..99fd1e62 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 org.apache.maven.shared.utils.Os;
import org.apache.maven.shared.utils.StringUtils;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
/**
* @author Trygve Laugstøl
@@ -73,7 +72,7 @@ public String getOutput() {
* @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 static int executeCommandLine(@Nonnull Commandline cl, StreamConsumer sys
* @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 static int executeCommandLine(
* @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 static int executeCommandLine(
* @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 static int executeCommandLine(
* @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 static int executeCommandLine(
* @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 static int executeCommandLine(
* @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 static CommandLineCallable executeCommandLineAsCallable(
* @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 03a79ca1..cbe6c18e 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.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 1c6965ea..f8c58de2 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 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;
/**
* Using simple dotted expressions to extract the values from an Object instance, @@ -141,7 +140,7 @@ private 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 static Object evaluate(@Nonnull String expression, @Nullable Object root) * @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 aad7a017..77dc97c4 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.List; import java.util.Set; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; + /** *
Class for scanning a directory for files/directories which match certain criteria.
*
@@ -279,7 +279,7 @@ public void setBasedir(final String basedir) {
*
* @param basedir The base directory for scanning. Should not be General IO Stream manipulation.
@@ -133,7 +133,7 @@ private 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 static void copy(@Nonnull final InputStream input, @Nonnull final OutputS
* 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 static void copy(@Nonnull final InputStream input, @Nonnull final OutputS
* @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 static void copy(@Nonnull final Reader input, @Nonnull final Writer outpu
* @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 static void copy(@Nonnull final Reader input, @Nonnull final Writer outpu
* @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 static void copy(@Nonnull final InputStream input, @Nonnull final Writer
* @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 static void copy(@Nonnull final InputStream input, @Nonnull final Writer
*/
@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 static void copy(
*/
@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 static void copy(
* @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 static String toString(@Nonnull final InputStream input) throws IOExcepti
* @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 static String toString(@Nonnull final InputStream input, final int buffer
* @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 static String toString(@Nonnull final InputStream input, @Nonnull final S
* @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 static String toString(
* @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 static byte[] toByteArray(@Nonnull final InputStream input) throws IOExce
* @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 static byte[] toByteArray(@Nonnull final InputStream input, final int buf
* @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 static void copy(@Nonnull final Reader input, @Nonnull final OutputStream
* @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 static void copy(@Nonnull final Reader input, @Nonnull final OutputStream
* @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 static String toString(@Nonnull final Reader input) throws IOException {
* @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 static String toString(@Nonnull final Reader input, final int bufferSize)
* @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 static byte[] toByteArray(@Nonnull final Reader input) throws IOException
* @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 static byte[] toByteArray(@Nonnull final Reader input, final int bufferSi
* @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 static void copy(@Nonnull final String input, @Nonnull final OutputStream
* @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 static void copy(@Nonnull final String input, @Nonnull final OutputStream
* @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 static void copy(@Nonnull final String input, @Nonnull final Writer outpu
* @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 static byte[] toByteArray(@Nonnull final String input) throws IOException
* @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 static byte[] toByteArray(@Nonnull final String input, final int bufferSi
* @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 static void copy(@Nonnull final byte[] input, @Nonnull final Writer outpu
* @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 static void copy(@Nonnull final byte[] input, @Nonnull final Writer outpu
* @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 static void copy(@Nonnull final byte[] input, @Nonnull final Writer outpu
*/
@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 static void copy(
* @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 static String toString(@Nonnull final byte[] input) throws IOException {
* @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 static String toString(@Nonnull final byte[] input, final int bufferSize)
* @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 static String toString(@Nonnull final byte[] input, @Nonnull final String
* @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 static String toString(@Nonnull final byte[] input, @Nonnull final String
* @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 static void copy(@Nonnull final byte[] input, @Nonnull final OutputStream
* @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 1aa87d88..1ec64432 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 static boolean isSymLink(@Nonnull File file) {
* @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 static File readSymbolicLink(@Nonnull File symlink) throws IOException {
* @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 static boolean exists(@Nonnull File file) throws IOException {
* @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 static File createSymbolicLink(@Nonnull File symlink, @Nonnull File targe
* @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 75ad557f..2b57c019 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;
+
/**
* Describes a match target for SelectorUtils.
@@ -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 @@ boolean matchPath(String str, String[] strDirs, boolean isCaseSensitive) {
* @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 boolean startsWith(String string) {
return source.startsWith(string);
}
- static String[] tokenizePathToString(@Nonnull String path, @Nonnull String separator) {
+ static String[] tokenizePathToString(@NonNull String path, @NonNull String separator) {
List This is a utility class used by selectors and DirectoryScanner. The
* functionality more properly belongs just to selectors, but unfortunately
@@ -513,12 +513,12 @@ private static Listnull.
*/
- public void setBasedir(@Nonnull final File basedir) {
+ public void setBasedir(@NonNull final File basedir) {
this.basedir = basedir;
}
@@ -553,7 +553,7 @@ private void slowScan() {
* @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 @@ private boolean isIncluded(final String name) {
* @return true when the name matches against the start of at least one include pattern, or
* false otherwise.
*/
- private boolean couldHoldIncluded(@Nonnull final String name) {
+ private boolean couldHoldIncluded(@NonNull final String name) {
return includesPatterns.matchesPatternStart(name, isCaseSensitive);
}
@@ -709,7 +709,7 @@ private boolean couldHoldIncluded(@Nonnull final String name) {
* @return true when the name matches against at least one exclude pattern, or false
* 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 1996e0bc..682c4dac 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 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 @@ protected FileUtils() {
* @return the default excludes pattern
* @see DirectoryScanner#DEFAULTEXCLUDES
*/
- @Nonnull
+ @NonNull
public static String[] getDefaultExcludes() {
return DirectoryScanner.DEFAULTEXCLUDES;
}
@@ -140,7 +138,7 @@ public static String[] getDefaultExcludes() {
* @return the default excludes pattern as list
* @see #getDefaultExcludes()
*/
- @Nonnull
+ @NonNull
public static Listsource does not exist, destination 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 @@ private static boolean copyFileIfModified(@Nonnull final File source, @Nonnull f
* @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 static void copyURLToFile(@Nonnull final URL source, @Nonnull final File
* 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 @@ private static void copyStreamToFile(@Nonnull @WillClose final InputStream sourc
* @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 static String normalize(@Nonnull final String path) {
* @param filename absolute or relative file path to resolve
* @return the canonical File of filename
*/
- @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 static File resolveFile(final File baseFile, @Nonnull String filename) {
* @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 static void forceDelete(@Nonnull final String file) throws IOException {
* @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 static void forceDelete(@Nonnull final File file) throws IOException {
* @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 static void delete(@Nonnull File file) throws IOException {
* @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 static boolean deleteLegacyStyle(@Nonnull File file) {
* @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 @@ private static boolean deleteFile(@Nonnull File file) throws IOException {
* @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 static void forceMkdir(@Nonnull final File file) throws IOException {
* @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 static void deleteDirectory(@Nonnull final String directory) throws IOExc
* @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 static void deleteDirectory(@Nonnull final File directory) throws IOExcep
* @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 static void cleanDirectory(@Nonnull final File directory) throws IOExcept
* @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 static long sizeOfDirectory(@Nonnull final String directory) {
* @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 static long sizeOfDirectory(@Nonnull final File directory) {
* @see #getFileNames(File, String, String, boolean)
* @throws IOException never
*/
- @Nonnull
- public static Listtrue 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 @@ private static boolean isValidWindowsFileName(@Nonnull File f) {
* @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 static boolean isSymbolicLink(@Nonnull final File file) throws IOExceptio
* @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 static boolean isSymbolicLinkForSure(@Nonnull final File file) throws IOE
* @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 bb90a270..1515a869 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.Writer;
import java.nio.channels.Channel;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
*