2525
2626import com .github .packageurl .ValidationException ;
2727import java .nio .charset .StandardCharsets ;
28+ import org .jspecify .annotations .NonNull ;
2829
2930/**
3031 * String utility for validation and encoding.
@@ -65,7 +66,7 @@ private StringUtil() {
6566 *
6667 * @since 2.0.0
6768 */
68- public static String toLowerCase (String s ) {
69+ public static @ NonNull String toLowerCase (@ NonNull String s ) {
6970 int pos = indexOfFirstUpperCaseChar (s );
7071
7172 if (pos == -1 ) {
@@ -89,7 +90,7 @@ public static String toLowerCase(String s) {
8990 *
9091 * @since 2.0.0
9192 */
92- public static String percentDecode (final String source ) {
93+ public static @ NonNull String percentDecode (@ NonNull final String source ) {
9394 if (source .indexOf (PERCENT_CHAR ) == -1 ) {
9495 return source ;
9596 }
@@ -120,7 +121,7 @@ public static String percentDecode(final String source) {
120121 *
121122 * @since 2.0.0
122123 */
123- public static String percentEncode (final String source ) {
124+ public static @ NonNull String percentEncode (@ NonNull final String source ) {
124125 if (!shouldEncode (source )) {
125126 return source ;
126127 }
@@ -142,10 +143,6 @@ public static String percentEncode(final String source) {
142143 return new String (dest , 0 , writePos , StandardCharsets .UTF_8 );
143144 }
144145
145- private static byte toHexDigit (int b ) {
146- return (byte ) Character .toUpperCase (Character .forDigit (b & 0xF , 16 ));
147- }
148-
149146 /**
150147 * Determines if the character is a digit.
151148 *
@@ -182,6 +179,10 @@ public static boolean isValidCharForKey(int c) {
182179 return (isAlphaNumeric (c ) || c == '.' || c == '_' || c == '-' );
183180 }
184181
182+ private static byte toHexDigit (int b ) {
183+ return (byte ) Character .toUpperCase (Character .forDigit (b & 0xF , 16 ));
184+ }
185+
185186 /**
186187 * Returns {@code true} if the character is in the unreserved RFC 3986 set.
187188 * <p>
0 commit comments