Class CollectionUtils

java.lang.Object
org.jumpmind.util.CollectionUtils

public class CollectionUtils extends Object
  • Constructor Details

    • CollectionUtils

      public CollectionUtils()
  • Method Details

    • toMap

      public static <T> Map<String,T> toMap(String[] keyNames, T[] values)
    • toMap

      public static Map<String,String> toMap(Properties properties)
    • copyOfRange

      public static <T> T[] copyOfRange(T[] original, int from, int to)
      Copies the specified range of the specified array into a new array. The initial index of the range (from) must lie between zero and original.length, inclusive. The value at original[from] is placed into the initial element of the copy (unless from == original.length or from == to). Values from subsequent elements in the original array are placed into subsequent elements in the copy. The final index of the range (to), which must be greater than or equal to from, may be greater than original.length, in which case null is placed in all elements of the copy whose index is greater than or equal to original.length - from. The length of the returned array will be to - from.

      The resulting array is of exactly the same class as the original array.

      Parameters:
      original - the array from which a range is to be copied
      from - the initial index of the range to be copied, inclusive
      to - the final index of the range to be copied, exclusive. (This index may lie outside the array.)
      Returns:
      a new array containing the specified range from the original array, truncated or padded with nulls to obtain the required length
      Throws:
      ArrayIndexOutOfBoundsException - if from < 0 or from > original.length()
      IllegalArgumentException - if from > to
      NullPointerException - if original is null
      Since:
      1.6
    • copyOfRange

      public static <T, U> T[] copyOfRange(U[] original, int from, int to, Class<? extends T[]> newType)
      Copies the specified range of the specified array into a new array. The initial index of the range (from) must lie between zero and original.length, inclusive. The value at original[from] is placed into the initial element of the copy (unless from == original.length or from == to). Values from subsequent elements in the original array are placed into subsequent elements in the copy. The final index of the range (to), which must be greater than or equal to from, may be greater than original.length, in which case null is placed in all elements of the copy whose index is greater than or equal to original.length - from. The length of the returned array will be to - from. The resulting array is of the class newType.
      Parameters:
      original - the array from which a range is to be copied
      from - the initial index of the range to be copied, inclusive
      to - the final index of the range to be copied, exclusive. (This index may lie outside the array.)
      newType - the class of the copy to be returned
      Returns:
      a new array containing the specified range from the original array, truncated or padded with nulls to obtain the required length
      Throws:
      ArrayIndexOutOfBoundsException - if from < 0 or from > original.length()
      IllegalArgumentException - if from > to
      NullPointerException - if original is null
      ArrayStoreException - if an element copied from original is not of a runtime type that can be stored in an array of class newType.
      Since:
      1.6
    • add

      public static <T> T[] add(T[] one, T[] two)
    • copyOf

      public static <T> T[] copyOf(T[] original, int newLength)
    • copyOf

      public static <T, U> T[] copyOf(U[] original, int newLength, Class<? extends T[]> newType)
    • toCommaSeparatedValues

      public static String toCommaSeparatedValues(Collection<?> list)