修改注释

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

View File

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