java.lang.Object
org.cicirello.util.ArrayMinimumLengthEnforcer
Utility class for checking and enforcing that the length of an array is at least some target
minimum length.
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean[]enforce(boolean[] array, int minLength) Validates that an array is non-null and has a length at least that of a target minimum.static byte[]enforce(byte[] array, int minLength) Validates that an array is non-null and has a length at least that of a target minimum.static char[]enforce(char[] array, int minLength) Validates that an array is non-null and has a length at least that of a target minimum.static double[]enforce(double[] array, int minLength) Validates that an array is non-null and has a length at least that of a target minimum.static float[]enforce(float[] array, int minLength) Validates that an array is non-null and has a length at least that of a target minimum.static int[]enforce(int[] array, int minLength) Validates that an array is non-null and has a length at least that of a target minimum.static long[]enforce(long[] array, int minLength) Validates that an array is non-null and has a length at least that of a target minimum.static short[]enforce(short[] array, int minLength) Validates that an array is non-null and has a length at least that of a target minimum.
-
Method Details
-
enforce
public static int[] enforce(int[] array, int minLength) Validates that an array is non-null and has a length at least that of a target minimum.- Parameters:
array- The array to check.minLength- The target minimum length.- Returns:
- The original array if it is non-null and length at least minLength, and otherwise returns a new array of the minLength.
-
enforce
public static long[] enforce(long[] array, int minLength) Validates that an array is non-null and has a length at least that of a target minimum.- Parameters:
array- The array to check.minLength- The target minimum length.- Returns:
- The original array if it is non-null and length at least minLength, and otherwise returns a new array of the minLength.
-
enforce
public static short[] enforce(short[] array, int minLength) Validates that an array is non-null and has a length at least that of a target minimum.- Parameters:
array- The array to check.minLength- The target minimum length.- Returns:
- The original array if it is non-null and length at least minLength, and otherwise returns a new array of the minLength.
-
enforce
public static byte[] enforce(byte[] array, int minLength) Validates that an array is non-null and has a length at least that of a target minimum.- Parameters:
array- The array to check.minLength- The target minimum length.- Returns:
- The original array if it is non-null and length at least minLength, and otherwise returns a new array of the minLength.
-
enforce
public static double[] enforce(double[] array, int minLength) Validates that an array is non-null and has a length at least that of a target minimum.- Parameters:
array- The array to check.minLength- The target minimum length.- Returns:
- The original array if it is non-null and length at least minLength, and otherwise returns a new array of the minLength.
-
enforce
public static float[] enforce(float[] array, int minLength) Validates that an array is non-null and has a length at least that of a target minimum.- Parameters:
array- The array to check.minLength- The target minimum length.- Returns:
- The original array if it is non-null and length at least minLength, and otherwise returns a new array of the minLength.
-
enforce
public static char[] enforce(char[] array, int minLength) Validates that an array is non-null and has a length at least that of a target minimum.- Parameters:
array- The array to check.minLength- The target minimum length.- Returns:
- The original array if it is non-null and length at least minLength, and otherwise returns a new array of the minLength.
-
enforce
public static boolean[] enforce(boolean[] array, int minLength) Validates that an array is non-null and has a length at least that of a target minimum.- Parameters:
array- The array to check.minLength- The target minimum length.- Returns:
- The original array if it is non-null and length at least minLength, and otherwise returns a new array of the minLength.
-