/** * <p>Creates a random string whose length is between the inclusive minimum and * the exclusive maximum.</p> * * <p>Characters will be chosen from the set of \p{Print} characters.</p> * * @param minLengthInclusive the inclusive minimum length of the string to generate * @param maxLengthExclusive the exclusive maximum length of the string to generate * @return the random string * @since 3.5 */ public static String randomPrint(final int minLengthInclusive, final int maxLengthExclusive) { return randomPrint(RandomUtils.nextInt(minLengthInclusive, maxLengthExclusive)); }
/** * <p>Creates a random string whose length is between the inclusive minimum and * the exclusive maximum.</p> * * <p>Characters will be chosen from the set of Latin alphabetic characters (a-z, A-Z).</p> * * @param minLengthInclusive the inclusive minimum length of the string to generate * @param maxLengthExclusive the exclusive maximum length of the string to generate * @return the random string * @since 3.5 */ public static String randomAlphabetic(final int minLengthInclusive, final int maxLengthExclusive) { return randomAlphabetic(RandomUtils.nextInt(minLengthInclusive, maxLengthExclusive)); }
/** * <p>Creates a random string whose length is between the inclusive minimum and * the exclusive maximum.</p> * * <p>Characters will be chosen from the set of \p{Digit} characters.</p> * * @param minLengthInclusive the inclusive minimum length of the string to generate * @param maxLengthExclusive the exclusive maximum length of the string to generate * @return the random string * @since 3.5 */ public static String randomNumeric(final int minLengthInclusive, final int maxLengthExclusive) { return randomNumeric(RandomUtils.nextInt(minLengthInclusive, maxLengthExclusive)); }
/** * <p>Checks if an array of primitive ints is not empty and not {@code null}. * * @param array the array to test * @return {@code true} if the array is not empty and not {@code null} * @since 2.5 */ public static boolean isNotEmpty(final int[] array) { return !isEmpty(array); }
/** * <p>Creates a random string whose length is between the inclusive minimum and * the exclusive maximum.</p> * * <p>Characters will be chosen from the set of \p{Graph} characters.</p> * * @param minLengthInclusive the inclusive minimum length of the string to generate * @param maxLengthExclusive the exclusive maximum length of the string to generate * @return the random string * @since 3.5 */ public static String randomGraph(final int minLengthInclusive, final int maxLengthExclusive) { return randomGraph(RandomUtils.nextInt(minLengthInclusive, maxLengthExclusive)); }
/** * <p>Checks if the value is in the given array. * * <p>The method returns {@code false} if a {@code null} array is passed in. * * @param array the array to search through * @param valueToFind the value to find * @return {@code true} if the array contains the object */ public static boolean contains(final short[] array, final short valueToFind) { return indexOf(array, valueToFind) != INDEX_NOT_FOUND; }
/** * <p>Gets the short class name for a class.</p> * * <p>The short class name is the classname excluding * the package name.</p> * * @param cls the <code>Class</code> to get the short name of * @return the short name */ protected String getShortClassName(final Class<?> cls) { return ClassUtils.getShortClassName(cls); }
/** * <p>Checks if an array of primitive bytes is empty or {@code null}. * * @param array the array to test * @return {@code true} if the array is empty or {@code null} * @since 2.1 */ public static boolean isEmpty(final byte[] array) { return getLength(array) == 0; }
private static void init() { init_X86_32Bit(); init_X86_64Bit(); init_IA64_32Bit(); init_IA64_64Bit(); init_PPC_32Bit(); init_PPC_64Bit(); }
private int run_CharSet(final int loopCount) { int t = 0; for (int i = 0; i < loopCount; i++) { for (final char ch : CHAR_SAMPLES) { final boolean b = CharSet.ASCII_NUMERIC.contains(ch); t += b ? 1 : 0; } } return t; }
/** * <p>Null-safe version of <code>Class.getName()</code></p> * * @param object the object for which to get the class name; may be null * @return the class name or the empty String * @since 3.7 * @see Class#getSimpleName() */ public static String getName(final Object object) { return getName(object, StringUtils.EMPTY); }
/** * Compares this mutable to another in ascending order. * * @param other the other mutable to compare to, not null * @return negative if this is less, zero if equal, positive if greater * where false is less than true */ @Override public int compareTo(final MutableBoolean other) { return BooleanUtils.compare(this.value, other.value); }
/** * Decides if the operating system matches. * * @param osNamePrefix the prefix for the OS name * @return true if matches, or false if not or can't determine */ private static boolean getOsMatchesName(final String osNamePrefix) { return isOSNameMatch(OS_NAME, osNamePrefix); }
/** * <p>Constructs a {@code CharRange} over a single character.</p> * * @param ch only character in this range * @return the new CharRange object * @see CharRange#CharRange(char, char, boolean) * @since 2.5 */ public static CharRange is(final char ch) { return new CharRange(ch, ch, false); }
/** * Adds the given {@link Processor} with the given keys to the map. * * @param keys The keys. * @param processor The {@link Processor} to add. * @throws IllegalStateException If the key already exists. */ private static void addProcessors(final Processor processor, final String... keys) { for (final String key : keys) { addProcessor(key, processor); } }
/** * <p>Checks if an array of primitive floats is not empty and not {@code null}. * * @param array the array to test * @return {@code true} if the array is not empty and not {@code null} * @since 2.5 */ public static boolean isNotEmpty(final float[] array) { return !isEmpty(array); }
/** * <p>Checks if an array of primitive doubles is empty or {@code null}. * * @param array the array to test * @return {@code true} if the array is empty or {@code null} * @since 2.1 */ public static boolean isEmpty(final double[] array) { return getLength(array) == 0; }
/** * <p>Constructs a {@code CharRange} over a set of characters.</p> * * @param start first character, inclusive, in this range * @param end last character, inclusive, in this range * @return the new CharRange object * @see CharRange#CharRange(char, char, boolean) * @since 2.5 */ public static CharRange isIn(final char start, final char end) { return new CharRange(start, end, false); }
/** * <p>Checks if an array of primitive booleans is not empty and not {@code null}. * * @param array the array to test * @return {@code true} if the array is not empty and not {@code null} * @since 2.5 */ public static boolean isNotEmpty(final boolean[] array) { return !isEmpty(array); }
/** * <p>Constructs a negated {@code CharRange} over a set of characters.</p> * * @param start first character, inclusive, in this range * @param end last character, inclusive, in this range * @return the new CharRange object * @see CharRange#CharRange(char, char, boolean) * @since 2.5 */ public static CharRange isNotIn(final char start, final char end) { return new CharRange(start, end, true); }