修改注释

dev
ZhouXY108 2024-10-21 18:18:53 +08:00
parent 66d0e811f7
commit e5cd981508
2 changed files with 66 additions and 27 deletions

View File

@ -26,18 +26,23 @@ import javax.annotation.Nullable;
public class ArrayTools { public class ArrayTools {
// empty arrays // #region - empty arrays
public static final char[] EMPTY_CHAR_ARRAY = {}; public static final char[] EMPTY_CHAR_ARRAY = {};
public static final int[] EMPTY_INTEGER_ARRAY = {}; public static final int[] EMPTY_INTEGER_ARRAY = {};
public static final long[] EMPTY_LONG_ARRAY = {}; public static final long[] EMPTY_LONG_ARRAY = {};
public static final float[] EMPTY_FLOAT_ARRAY = {}; public static final float[] EMPTY_FLOAT_ARRAY = {};
public static final double[] EMPTY_DOUBLE_ARRAY = {}; public static final double[] EMPTY_DOUBLE_ARRAY = {};
// #endregion
// #region - isNullOrEmpty
// isNullOrEmpty // isNullOrEmpty
/** /**
* *
* *
* @param arr {@code null} * @param arr {@code null}
* @param <T> * @param <T>
* @return {@code null} 0 {@code true} {@code false} * @return {@code null} 0 {@code true} {@code false}
@ -49,7 +54,7 @@ public class ArrayTools {
// isNullOrEmpty - float // isNullOrEmpty - float
/** /**
* *
* *
* @param arr {@code null} * @param arr {@code null}
* @return {@code null} 0 {@code true} {@code false} * @return {@code null} 0 {@code true} {@code false}
*/ */
@ -60,7 +65,7 @@ public class ArrayTools {
// isNullOrEmpty - double // isNullOrEmpty - double
/** /**
* *
* *
* @param arr {@code null} * @param arr {@code null}
* @return {@code null} 0 {@code true} {@code false} * @return {@code null} 0 {@code true} {@code false}
*/ */
@ -71,7 +76,7 @@ public class ArrayTools {
// isNullOrEmpty - byte // isNullOrEmpty - byte
/** /**
* *
* *
* @param arr {@code null} * @param arr {@code null}
* @return {@code null} 0 {@code true} {@code false} * @return {@code null} 0 {@code true} {@code false}
*/ */
@ -82,7 +87,7 @@ public class ArrayTools {
// isNullOrEmpty - long // isNullOrEmpty - long
/** /**
* *
* *
* @param arr {@code null} * @param arr {@code null}
* @return {@code null} 0 {@code true} {@code false} * @return {@code null} 0 {@code true} {@code false}
*/ */
@ -93,7 +98,7 @@ public class ArrayTools {
// isNullOrEmpty - int // isNullOrEmpty - int
/** /**
* *
* *
* @param arr {@code null} * @param arr {@code null}
* @return {@code null} 0 {@code true} {@code false} * @return {@code null} 0 {@code true} {@code false}
*/ */
@ -101,10 +106,14 @@ public class ArrayTools {
return arr == null || arr.length == 0; return arr == null || arr.length == 0;
} }
// #endregion
// #region - isNotEmpty
// isNotEmpty // isNotEmpty
/** /**
* *
* *
* @param arr {@code null} * @param arr {@code null}
* @param <T> * @param <T>
* @return {@code null} 0 {@code true} {@code false} * @return {@code null} 0 {@code true} {@code false}
@ -116,7 +125,7 @@ public class ArrayTools {
// isNotEmpty - float // isNotEmpty - float
/** /**
* *
* *
* @param arr {@code null} * @param arr {@code null}
* @return {@code null} 0 {@code true} {@code false} * @return {@code null} 0 {@code true} {@code false}
*/ */
@ -127,7 +136,7 @@ public class ArrayTools {
// isNotEmpty - double // isNotEmpty - double
/** /**
* *
* *
* @param arr {@code null} * @param arr {@code null}
* @return {@code null} 0 {@code true} {@code false} * @return {@code null} 0 {@code true} {@code false}
*/ */
@ -138,7 +147,7 @@ public class ArrayTools {
// isNotEmpty - byte // isNotEmpty - byte
/** /**
* *
* *
* @param arr {@code null} * @param arr {@code null}
* @return {@code null} 0 {@code true} {@code false} * @return {@code null} 0 {@code true} {@code false}
*/ */
@ -149,7 +158,7 @@ public class ArrayTools {
// isNotEmpty - long // isNotEmpty - long
/** /**
* *
* *
* @param arr {@code null} * @param arr {@code null}
* @return {@code null} 0 {@code true} {@code false} * @return {@code null} 0 {@code true} {@code false}
*/ */
@ -160,7 +169,7 @@ public class ArrayTools {
// isNotEmpty - int // isNotEmpty - int
/** /**
* *
* *
* @param arr {@code null} * @param arr {@code null}
* @return {@code null} 0 {@code true} {@code false} * @return {@code null} 0 {@code true} {@code false}
*/ */
@ -168,7 +177,9 @@ public class ArrayTools {
return arr != null && arr.length > 0; return arr != null && arr.length > 0;
} }
// isAllElementsNotNull // #endregion
// #region - isAllElementsNotNull
/** /**
* *
@ -178,11 +189,11 @@ public class ArrayTools {
* <li><b> {@code null}</b> {@code false} * <li><b> {@code null}</b> {@code false}
* <li><b> {@code null}</b> {@code true} * <li><b> {@code null}</b> {@code true}
* </ol> * </ol>
* *
* @param <T> * @param <T>
* @param arr {@code null} * @param arr {@code null}
* @return {@code null} {@code true} {@code false} * @return {@code null} {@code true} {@code false}
* *
* @throws IllegalArgumentException * @throws IllegalArgumentException
*/ */
public static <T> boolean isAllElementsNotNull(@Nonnull final T[] arr) { public static <T> boolean isAllElementsNotNull(@Nonnull final T[] arr) {
@ -195,11 +206,13 @@ public class ArrayTools {
return true; return true;
} }
// concat // #endregion
// #region - concat
/** /**
* *
* *
* @param arrays {@code null} * @param arrays {@code null}
* @return * @return
*/ */
@ -219,7 +232,7 @@ public class ArrayTools {
/** /**
* *
* *
* @param arrays {@code null} * @param arrays {@code null}
* @return * @return
*/ */
@ -239,7 +252,7 @@ public class ArrayTools {
/** /**
* *
* *
* @param arrays {@code null} * @param arrays {@code null}
* @return * @return
*/ */
@ -259,7 +272,7 @@ public class ArrayTools {
/** /**
* *
* *
* @param arrays {@code null} * @param arrays {@code null}
* @return * @return
*/ */
@ -279,7 +292,7 @@ public class ArrayTools {
/** /**
* *
* *
* @param arrays {@code null} * @param arrays {@code null}
* @return * @return
*/ */
@ -299,7 +312,7 @@ public class ArrayTools {
/** /**
* *
* *
* @param arrays * @param arrays
* @param <T> * @param <T>
* @return * @return
@ -322,6 +335,10 @@ public class ArrayTools {
return result; return result;
} }
// #endregion
// #region - fill
// fill - char // fill - char
public static void fill(char[] a, char... values) { public static void fill(char[] a, char... values) {
@ -451,7 +468,7 @@ public class ArrayTools {
public static <T> void fill(@Nonnull T[] a, int fromIndex, int toIndex, T[] values) { public static <T> void fill(@Nonnull T[] a, int fromIndex, int toIndex, T[] values) {
fillInternal(a, fromIndex, toIndex, values); fillInternal(a, fromIndex, toIndex, values);
} }
private static <T> void fillInternal(@Nonnull T[] a, int fromIndex, int toIndex, @Nullable T[] values) { private static <T> void fillInternal(@Nonnull T[] a, int fromIndex, int toIndex, @Nullable T[] values) {
AssertTools.checkArgumentNotNull(a); AssertTools.checkArgumentNotNull(a);
if (values == null || values.length == 0) { if (values == null || values.length == 0) {
@ -475,7 +492,13 @@ public class ArrayTools {
} }
} }
// #endregion
// #region - private constructor
private ArrayTools() { private ArrayTools() {
throw new IllegalStateException("Utility class"); throw new IllegalStateException("Utility class");
} }
// #endregion
} }

View File

@ -22,22 +22,24 @@ import javax.annotation.Nonnull;
/** /**
* *
* *
* <p> * <p>
* {@code false} * {@code false}
* 使 * 使
* </p> * </p>
* *
* <pre> * <pre>
* AssertTools.checkArgument(StringUtils.hasText(str), "The argument cannot be blank."); * AssertTools.checkArgument(StringUtils.hasText(str), "The argument cannot be blank.");
* AssertTools.checkState(ArrayUtils.isNotEmpty(result), "The result cannot be empty."); * AssertTools.checkState(ArrayUtils.isNotEmpty(result), "The result cannot be empty.");
* AssertTools.checkCondition(!CollectionUtils.isEmpty(roles), () -> new InvalidInputException("The roles cannot be empty.")); * AssertTools.checkCondition(!CollectionUtils.isEmpty(roles), () -> new InvalidInputException("The roles cannot be empty."));
* </pre> * </pre>
* *
* @author ZhouXY * @author ZhouXY
*/ */
public class AssertTools { public class AssertTools {
// #region - checkArgument
public static <T> void checkArgumentNotNull(T argument) { public static <T> void checkArgumentNotNull(T argument) {
checkCondition(argument != null, () -> new IllegalArgumentException("The argument cannot be null.")); checkCondition(argument != null, () -> new IllegalArgumentException("The argument cannot be null."));
} }
@ -70,6 +72,10 @@ public class AssertTools {
checkCondition(condition, () -> new IllegalArgumentException(String.format(format, args))); checkCondition(condition, () -> new IllegalArgumentException(String.format(format, args)));
} }
// #endregion
// #region - checkState
public static void checkState(boolean condition) { public static void checkState(boolean condition) {
checkCondition(condition, IllegalStateException::new); checkCondition(condition, IllegalStateException::new);
} }
@ -86,6 +92,10 @@ public class AssertTools {
checkCondition(condition, () -> new IllegalStateException(String.format(format, args))); checkCondition(condition, () -> new IllegalStateException(String.format(format, args)));
} }
// #endregion
// #region - checkCondition
public static <T extends Exception> void checkCondition(boolean condition, @Nonnull Supplier<T> e) public static <T extends Exception> void checkCondition(boolean condition, @Nonnull Supplier<T> e)
throws T { throws T {
if (!condition) { if (!condition) {
@ -93,7 +103,13 @@ public class AssertTools {
} }
} }
// #endregion
// #region - private constructor
private AssertTools() { private AssertTools() {
throw new IllegalStateException("Utility class"); throw new IllegalStateException("Utility class");
} }
// #endregion
} }