File tree Expand file tree Collapse file tree
src/main/java/io/github/thibaultmeyer/cuid Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -117,12 +117,24 @@ public static boolean isValid(final String cuidAsString) {
117117
118118 return cuidAsString != null
119119 && (cuidAsString .length () == CUIDv1 .LENGTH_STANDARD && cuidAsString .startsWith (CUIDv1 .START_CHARACTER ) // Version 1
120- || (cuidAsString .length () > 0 )) // Version 2
120+ || (! cuidAsString .isEmpty () )) // Version 2
121121 && cuidAsString .chars ()
122122 .filter (c -> !((c >= '0' && c <= '9' ) || (c >= 'A' && c <= 'Z' ) || (c >= 'a' && c <= 'z' )))
123123 .count () == 0 ;
124124 }
125125
126+ /**
127+ * Always return non-negative value.
128+ *
129+ * @param i the integer value
130+ * @return a non-negative value
131+ * @since 2.0.3
132+ */
133+ private static int safeAbs (final int i ) {
134+
135+ return i == Integer .MIN_VALUE ? 0 : Math .abs (i );
136+ }
137+
126138 /**
127139 * {@inheritDoc}
128140 *
@@ -177,11 +189,6 @@ public int hashCode() {
177189 return Objects .hash (value );
178190 }
179191
180- // Always return non-negative value (including Integer.MIN_VALUE)
181- private static int safeAbs (int a ) {
182- return a == Integer .MIN_VALUE ? 0 : Math .abs (a );
183- }
184-
185192 /**
186193 * CUID Version 1.
187194 *
You can’t perform that action at this time.
0 commit comments