类 ArrayUtils

java.lang.Object
committee.nova.mods.avaritia.api.util.java.ArrayUtils

public class ArrayUtils extends Object
Created by covers1624 on 3/27/2016.
  • 构造器概要

    构造器
    构造器
    说明
     
  • 方法概要

    修饰符和类型
    方法
    说明
    static <T> List<T>
    addAllNoNull(T[] array, List<T> list)
    Adds all elements from the array that are not null to the list.
    static <T> T[]
    addToArrayFirstNull(T[] array, T value)
    Adds the value at the first null index in the array.
    static <I, O> List<O>
    applyArray(Function<I,O> function, I... array)
    Apples the Specified function to the entire array and returns a new List of the result.
    static void
    arrayCopy(Object src, int srcPos, Object dst, int destPos, int length)
    Basically a wrapper for System.arraycopy with support for CCL Copyable's
    static String[]
    Converts an String array to lowercase.
    static <T> boolean
    contains(T[] input, T element)
    Checks if an array contains any of the specified element.
    static <T> boolean
    containsKeys(Map<T,?> map, T... keys)
    Checks if a map contains all keys passed in.
    static Map<String,String>
    Converts and array of "key=value" to a map.
    static <T> int
    count(T[] array, Function<T,Boolean> check)
    Counts elements in the array that conform to the Function check.
    static <T> int
    countNoNull(T[] array)
    Counts the elements in the array that are not null.
    static <T> T[]
    createNewArray(T[] array)
    Create a new array using the provided array as a template for both type and length.
    static <T> T[]
    createNewArray(T[] array, int length)
    Create a new array using the provided array as a template for the type and with the provided length.
    static <T> T[]
    fill(T[] array, T value)
    Fills the array with the specified value.
    static <T> void
    fillArray(T[] array, T value, Function<T,Boolean> check)
    Fills the array with the specified value.
    static <T> int
    indexOf(T[] array, T object)
    Returns the index of the first occurrence of the specified element in the array.
    static <T> int
    indexOfRef(T[] array, T object)
    Returns the index of the first occurrence of the specified element in the array with the same identity.
    static <T> T[]
    inverse(T[] input, T[] allElements)
    Creates the inverse of an array.
    static <T> boolean
    isEmpty(T[] array)
    Checks if the array is all null.
    static <T> boolean
    Checks if the specified array is empty or contains a null entry.
    static <T> T[]
    newArray(Class<T> arrayClass, int length)
    Creates a new array form its component class.
    static List<String>
    Prefixes a string array with the desired value.
    static <T> T[]
    rollArray(T[] input, int shift)
    Rolls the array based on the shift.
    static List<Integer>
    toList(int[] arr)
    Convert an int array to a list of Integers.

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 构造器详细资料

    • ArrayUtils

      public ArrayUtils()
  • 方法详细资料

    • arrayToLowercase

      public static String[] arrayToLowercase(String[] array)
      Converts an String array to lowercase.
      参数:
      array - Array to convert.
      返回:
      Converted array.
    • convertKeyValueArrayToMap

      public static Map<String,String> convertKeyValueArrayToMap(String[] array)
      Converts and array of "key=value" to a map.
      参数:
      array - Array to convert.
      返回:
      Map of values.
    • prefixStringList

      public static List<String> prefixStringList(String prefix, List<String> list)
      Prefixes a string array with the desired value.
      参数:
      prefix - The prefix to apply.
      list - The list to apply the prefix to.
      返回:
      The list with the prefix applied.
    • containsKeys

      @SafeVarargs public static <T> boolean containsKeys(Map<T,?> map, T... keys)
      Checks if a map contains all keys passed in.
      类型参数:
      T - The type of data in the map key.
      参数:
      map - Map to check.
      keys - Keys that must exist.
      返回:
      False if fail.
    • addToArrayFirstNull

      public static <T> T[] addToArrayFirstNull(T[] array, T value)
      Adds the value at the first null index in the array.
      类型参数:
      T - Type of value.
      参数:
      array - Array to add to.
      value - Value to add.
      返回:
      Returns a new array in the event the input was expanded.
    • addAllNoNull

      public static <T> List<T> addAllNoNull(T[] array, List<T> list)
      Adds all elements from the array that are not null to the list.
      类型参数:
      T - What we are dealing with.
      参数:
      array - Array to grab from.
      list - List to add to.
      返回:
      The modified list.
    • isEmpty

      public static <T> boolean isEmpty(T[] array)
      Checks if the array is all null.
      类型参数:
      T - What we are dealing with.
      参数:
      array - The array to check.
      返回:
      True if the array only contains nulls.
    • countNoNull

      public static <T> int countNoNull(T[] array)
      Counts the elements in the array that are not null.
      类型参数:
      T - What we are dealing with.
      参数:
      array - The array to check.
      返回:
      The count of non-null objects in the array.
    • count

      public static <T> int count(T[] array, Function<T,Boolean> check)
      Counts elements in the array that conform to the Function check.
      类型参数:
      T - What we are dealing with.
      参数:
      array - The array to check.
      check - The Function to apply to each element.
      返回:
      The count.
    • fill

      public static <T> T[] fill(T[] array, T value)
      Fills the array with the specified value. If the value is an instance of Copyable it will call copy.
      类型参数:
      T - What we are dealing with.
      参数:
      array - Array to fill.
      value - Value to fill with.
    • fillArray

      public static <T> void fillArray(T[] array, T value, Function<T,Boolean> check)
      Fills the array with the specified value. A Function is used to check if the value should be replaced. If the value is an instance of Copyable it will call copy.
      类型参数:
      T - What we are dealing with.
      参数:
      array - Array to fill.
      value - Value to fill with.
      check - Called to decide if the value should be replaced.
    • applyArray

      public static <I, O> List<O> applyArray(Function<I,O> function, I... array)
      Apples the Specified function to the entire array and returns a new List of the result. The input to the function may be null.
      类型参数:
      I - The Input generic.
      O - The Output generic.
      参数:
      function - The function to apply.
      array - The array to apply the function to.
      返回:
      A list of the output of the specified function.
    • arrayCopy

      public static void arrayCopy(Object src, int srcPos, Object dst, int destPos, int length)
      Basically a wrapper for System.arraycopy with support for CCL Copyable's
      参数:
      src - The source array.
      srcPos - Starting position in the source array.
      dst - The destination array.
      destPos - Starting position in the destination array.
      length - The number of elements to copy.
    • indexOf

      public static <T> int indexOf(T[] array, T object)
      Returns the index of the first occurrence of the specified element in the array. Will return -1 if the element is non existent in the array.
      类型参数:
      T - What we are dealing with.
      参数:
      array - The array to search.
      object - Element to find.
      返回:
      The index in the array of the object.
    • indexOfRef

      public static <T> int indexOfRef(T[] array, T object)
      Returns the index of the first occurrence of the specified element in the array with the same identity. (Ref compare). Will return -1 if the element is non existent in the array.
      参数:
      array - The array to search.
      object - Element to find.
      返回:
      The index in the array of the object.
    • createNewArray

      public static <T> T[] createNewArray(T[] array)
      Create a new array using the provided array as a template for both type and length.
      类型参数:
      T - The type.
      参数:
      array - The template.
      返回:
      The new array.
    • createNewArray

      public static <T> T[] createNewArray(T[] array, int length)
      Create a new array using the provided array as a template for the type and with the provided length.
      类型参数:
      T - The type.
      参数:
      array - The type template.
      length - The new array's length.
      返回:
      The new array.
    • newArray

      public static <T> T[] newArray(Class<T> arrayClass, int length)
      Creates a new array form its component class.
      类型参数:
      T - The thing.
      参数:
      arrayClass - The component class.
      length - The length.
      返回:
      The new array.
    • rollArray

      public static <T> T[] rollArray(T[] input, int shift)
      Rolls the array based on the shift. Positive shift means the array will roll to the right. Negative shift means the array will roll to the left.
      类型参数:
      T - The thing.
      参数:
      input - The input array.
      shift - The shift amount.
      返回:
      The new array.
    • contains

      public static <T> boolean contains(T[] input, T element)
      Checks if an array contains any of the specified element.
      类型参数:
      T - The thing.
      参数:
      input - The input
      element - The thing to test against.
      返回:
      If the element exists at all.
    • inverse

      public static <T> T[] inverse(T[] input, T[] allElements)
      Creates the inverse of an array. If the input array does not contain an element from the allElements array, then it is added to the output.
      类型参数:
      T - The thing.
      参数:
      input - The input.
      allElements - All possible values.
      返回:
      The inverse array.
    • isNullOrContainsNull

      public static <T> boolean isNullOrContainsNull(T[] input)
      Checks if the specified array is empty or contains a null entry.
      类型参数:
      T - The thing.
      参数:
      input - The input.
      返回:
      If the array is null or contains null.
    • toList

      public static List<Integer> toList(int[] arr)
      Convert an int array to a list of Integers.
      参数:
      arr - in.
      返回:
      out.