/** * Checks that the specified argument array is non-null and not empty. * <p> * Given the input argument, this returns only if it is non-null and contains * at least one element. * For example, in a constructor: * <pre> * this.values = ArgChecker.notEmpty(values, "values"); * </pre> * * @param argument the argument to check, null or empty throws an exception * @param name the name of the argument to use in the error message, not null * @return the input {@code argument}, not null * @throws IllegalArgumentException if the input is null or empty */ public static int[] notEmpty(int[] argument, String name) { notNull(argument, name); if (argument.length == 0) { throw new IllegalArgumentException(notEmptyArrayMsg(name)); } return argument; }
/** * Checks that the specified argument array is non-null and not empty. * <p> * Given the input argument, this returns only if it is non-null and contains * at least one element. * For example, in a constructor: * <pre> * this.values = ArgChecker.notEmpty(values, "values"); * </pre> * * @param argument the argument to check, null or empty throws an exception * @param name the name of the argument to use in the error message, not null * @return the input {@code argument}, not null * @throws IllegalArgumentException if the input is null or empty */ public static long[] notEmpty(long[] argument, String name) { notNull(argument, name); if (argument.length == 0) { throw new IllegalArgumentException(notEmptyArrayMsg(name)); } return argument; }
/** * Checks that the specified argument array is non-null and not empty. * <p> * Given the input argument, this returns only if it is non-null and contains * at least one element. * For example, in a constructor: * <pre> * this.values = ArgChecker.notEmpty(values, "values"); * </pre> * * @param argument the argument to check, null or empty throws an exception * @param name the name of the argument to use in the error message, not null * @return the input {@code argument}, not null * @throws IllegalArgumentException if the input is null or empty */ public static double[] notEmpty(double[] argument, String name) { notNull(argument, name); if (argument.length == 0) { throw new IllegalArgumentException(notEmptyArrayMsg(name)); } return argument; }
/** * Checks that the specified argument array is non-null and not empty. * <p> * Given the input argument, this returns only if it is non-null and contains * at least one element. The element is not validated and may be null. * For example, in a constructor: * <pre> * this.names = ArgChecker.notEmpty(names, "names"); * </pre> * * @param <T> the type of the input array reflected in the result * @param argument the argument to check, null or empty throws an exception * @param name the name of the argument to use in the error message, not null * @return the input {@code argument}, not null * @throws IllegalArgumentException if the input is null or empty */ public static <T> T[] notEmpty(T[] argument, String name) { notNull(argument, name); if (argument.length == 0) { throw new IllegalArgumentException(notEmptyArrayMsg(name)); } return argument; }