Class ArrayUtils

  • All Implemented Interfaces:

    
    public final class ArrayUtils
    
                        
    Author:

    Lyubomir Marinov

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      static <T> Array<T> add(Array<T> array, Class<T> componentType, T element) Adds a specific element to a specific array with a specific component type if the array does not contain the element yet.
      static <T> Array<T> insert(T element, Array<T> array, Class<T> componentType) Inserts the given element into an open (null) slot in the array if there is one, otherwise creates a new array and adds all existing elements and the given element
      static <T> Array<T> concat(Array<T> first, Array<T> second) Concatenates two arrays.
      static <T> boolean isNullOrEmpty(Array<T> array) Tests whether the array passed in as an argument is null or empty.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • add

         static <T> Array<T> add(Array<T> array, Class<T> componentType, T element)

        Adds a specific element to a specific array with a specific component type if the array does not contain the element yet.

        Parameters:
        array - the array to add element to
        componentType - the component type of array
        element - the element to add to array
        Returns:

        an array with the specified componentType and containing element. If array contained elementalready, returns array.

      • insert

         static <T> Array<T> insert(T element, Array<T> array, Class<T> componentType)

        Inserts the given element into an open (null) slot in the array if there is one, otherwise creates a new array and adds all existing elements and the given element

        Parameters:
        element - the element to add
        array - the array to add to, if possible
        componentType - the class type of the array (used if a new one needs to be allocated)
        Returns:

        an array containing all the elements in the array that was passed, as well as the given element. May or may not be the original array.

      • isNullOrEmpty

         static <T> boolean isNullOrEmpty(Array<T> array)

        Tests whether the array passed in as an argument is null or empty.