Tabnine Logo
ArrayUtils
Code IndexAdd Tabnine to your IDE (free)

How to use
ArrayUtils
in
org.ehcache.impl.internal.classes.commonslang

Best Java code snippets using org.ehcache.impl.internal.classes.commonslang.ArrayUtils (Showing top 18 results out of 315)

origin: ehcache/ehcache3

/**
 * <p>Checks if an array of Objects 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 Object[] array) {
  return getLength(array) == 0;
}
origin: ehcache/ehcache3

/**
 * <p>Defensive programming technique to change a {@code null}
 * reference to an empty one.
 *
 * <p>This method returns an empty array for a {@code null} input array.
 *
 * <p>As a memory optimizing technique an empty array passed in will be overridden with
 * the empty {@code public static} references in this class.
 *
 * @param array  the array to check for {@code null} or empty
 * @return the same array, {@code public static} empty array if {@code null} or empty input
 * @since 2.5
 */
public static Object[] nullToEmpty(final Object[] array) {
  if (isEmpty(array)) {
    return EMPTY_OBJECT_ARRAY;
  }
  return array;
}
origin: ehcache/ehcache3

if (!ArrayUtils.isSameLength(classArray, toClassArray)) {
  return false;
origin: ehcache/ehcache3

  throws NoSuchMethodException, IllegalAccessException, InvocationTargetException,
  InstantiationException {
args = ArrayUtils.nullToEmpty(args);
parameterTypes = ArrayUtils.nullToEmpty(parameterTypes);
final Constructor<T> ctor = getMatchingAccessibleConstructor(cls, parameterTypes);
if (ctor == null) {
origin: ehcache/ehcache3

final Class<?> pt = ClassUtils.wrapperToPrimitive(ct);
if(Integer.TYPE.equals(pt)) {
  return toPrimitive((Integer[]) array);
  return toPrimitive((Long[]) array);
  return toPrimitive((Short[]) array);
  return toPrimitive((Double[]) array);
  return toPrimitive((Float[]) array);
origin: ehcache/ehcache3

/**
 * <p>Returns a new instance of the specified class inferring the right constructor
 * from the types of the arguments.</p>
 *
 * <p>This locates and calls a constructor.
 * The constructor signature must match the argument types by assignment compatibility.</p>
 *
 * @param <T> the type to be constructed
 * @param cls  the class to be constructed, not {@code null}
 * @param args  the array of arguments, {@code null} treated as empty
 * @return new instance of {@code cls}, not {@code null}
 *
 * @throws NullPointerException if {@code cls} is {@code null}
 * @throws NoSuchMethodException if a matching constructor cannot be found
 * @throws IllegalAccessException if invocation is not permitted by security
 * @throws InvocationTargetException if an error occurs on invocation
 * @throws InstantiationException if an error occurs on instantiation
 * @see #invokeConstructor(Class, Object[], Class[])
 */
public static <T> T invokeConstructor(final Class<T> cls, Object... args)
    throws NoSuchMethodException, IllegalAccessException, InvocationTargetException,
    InstantiationException {
  args = ArrayUtils.nullToEmpty(args);
  final Class<?> parameterTypes[] = ClassUtils.toClass(args);
  return invokeConstructor(cls, args, parameterTypes);
}
origin: ehcache/ehcache3

varArgsArray = ArrayUtils.toPrimitive(varArgsArray);
origin: ehcache/ehcache3

/**
 * <p>Checks whether two arrays are the same length, treating
 * {@code null} arrays as length {@code 0}.
 *
 * <p>Any multi-dimensional aspects of the arrays are ignored.
 *
 * @param array1 the first array, may be {@code null}
 * @param array2 the second array, may be {@code null}
 * @return {@code true} if length of arrays matches, treating
 *  {@code null} as an empty array
 */
public static boolean isSameLength(final Object[] array1, final Object[] array2) {
  return getLength(array1) == getLength(array2);
}
origin: ehcache/ehcache3

/**
 * <p>Defensive programming technique to change a {@code null}
 * reference to an empty one.
 *
 * <p>This method returns an empty array for a {@code null} input array.
 *
 * <p>As a memory optimizing technique an empty array passed in will be overridden with
 * the empty {@code public static} references in this class.
 *
 * @param array  the array to check for {@code null} or empty
 * @return the same array, {@code public static} empty array if {@code null} or empty input
 * @since 3.2
 */
public static Class<?>[] nullToEmpty(final Class<?>[] array) {
  if (isEmpty(array)) {
    return EMPTY_CLASS_ARRAY;
  }
  return array;
}
origin: org.ehcache/ehcache

  throws NoSuchMethodException, IllegalAccessException, InvocationTargetException,
  InstantiationException {
args = ArrayUtils.nullToEmpty(args);
parameterTypes = ArrayUtils.nullToEmpty(parameterTypes);
final Constructor<T> ctor = getMatchingAccessibleConstructor(cls, parameterTypes);
if (ctor == null) {
origin: org.ehcache/ehcache

final Class<?> pt = ClassUtils.wrapperToPrimitive(ct);
if(Integer.TYPE.equals(pt)) {
  return toPrimitive((Integer[]) array);
  return toPrimitive((Long[]) array);
  return toPrimitive((Short[]) array);
  return toPrimitive((Double[]) array);
  return toPrimitive((Float[]) array);
origin: org.ehcache/ehcache

if (!ArrayUtils.isSameLength(classArray, toClassArray)) {
  return false;
origin: org.ehcache/ehcache

/**
 * <p>Checks if an array of Objects 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 Object[] array) {
  return getLength(array) == 0;
}
origin: org.ehcache/ehcache

/**
 * <p>Defensive programming technique to change a {@code null}
 * reference to an empty one.
 *
 * <p>This method returns an empty array for a {@code null} input array.
 *
 * <p>As a memory optimizing technique an empty array passed in will be overridden with
 * the empty {@code public static} references in this class.
 *
 * @param array  the array to check for {@code null} or empty
 * @return the same array, {@code public static} empty array if {@code null} or empty input
 * @since 2.5
 */
public static Object[] nullToEmpty(final Object[] array) {
  if (isEmpty(array)) {
    return EMPTY_OBJECT_ARRAY;
  }
  return array;
}
origin: org.ehcache/ehcache

/**
 * <p>Returns a new instance of the specified class inferring the right constructor
 * from the types of the arguments.</p>
 *
 * <p>This locates and calls a constructor.
 * The constructor signature must match the argument types by assignment compatibility.</p>
 *
 * @param <T> the type to be constructed
 * @param cls  the class to be constructed, not {@code null}
 * @param args  the array of arguments, {@code null} treated as empty
 * @return new instance of {@code cls}, not {@code null}
 *
 * @throws NullPointerException if {@code cls} is {@code null}
 * @throws NoSuchMethodException if a matching constructor cannot be found
 * @throws IllegalAccessException if invocation is not permitted by security
 * @throws InvocationTargetException if an error occurs on invocation
 * @throws InstantiationException if an error occurs on instantiation
 * @see #invokeConstructor(Class, Object[], Class[])
 */
public static <T> T invokeConstructor(final Class<T> cls, Object... args)
    throws NoSuchMethodException, IllegalAccessException, InvocationTargetException,
    InstantiationException {
  args = ArrayUtils.nullToEmpty(args);
  final Class<?> parameterTypes[] = ClassUtils.toClass(args);
  return invokeConstructor(cls, args, parameterTypes);
}
origin: org.ehcache/ehcache

varArgsArray = ArrayUtils.toPrimitive(varArgsArray);
origin: org.ehcache/ehcache

/**
 * <p>Checks whether two arrays are the same length, treating
 * {@code null} arrays as length {@code 0}.
 *
 * <p>Any multi-dimensional aspects of the arrays are ignored.
 *
 * @param array1 the first array, may be {@code null}
 * @param array2 the second array, may be {@code null}
 * @return {@code true} if length of arrays matches, treating
 *  {@code null} as an empty array
 */
public static boolean isSameLength(final Object[] array1, final Object[] array2) {
  return getLength(array1) == getLength(array2);
}
origin: org.ehcache/ehcache

/**
 * <p>Defensive programming technique to change a {@code null}
 * reference to an empty one.
 *
 * <p>This method returns an empty array for a {@code null} input array.
 *
 * <p>As a memory optimizing technique an empty array passed in will be overridden with
 * the empty {@code public static} references in this class.
 *
 * @param array  the array to check for {@code null} or empty
 * @return the same array, {@code public static} empty array if {@code null} or empty input
 * @since 3.2
 */
public static Class<?>[] nullToEmpty(final Class<?>[] array) {
  if (isEmpty(array)) {
    return EMPTY_CLASS_ARRAY;
  }
  return array;
}
org.ehcache.impl.internal.classes.commonslangArrayUtils

Javadoc

Operations on arrays, primitive arrays (like int[]) and primitive wrapper arrays (like Integer[]).

This class tries to handle null input gracefully. An exception will not be thrown for a nullarray input. However, an Object array that contains a nullelement may throw an exception. Each method documents its behaviour.

#ThreadSafe#

Most used methods

  • getLength
    Returns the length of the specified array. This method can deal with Object arrays and with primitiv
  • isEmpty
    Checks if an array of Objects is empty or null.
  • isSameLength
    Checks whether two arrays are the same length, treating null arrays as length 0. Any multi-dimensio
  • nullToEmpty
    Defensive programming technique to change a nullreference to an empty one. This method returns an e
  • toPrimitive
    Converts an array of object Shorts to primitives. This method returns null for a null input array.

Popular in Java

  • Updating database using SQL prepared statement
  • findViewById (Activity)
  • getExternalFilesDir (Context)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • Path (java.nio.file)
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • JComboBox (javax.swing)
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now