org.javers.common.collections.Arrays Maven / Gradle / Ivy
package org.javers.common.collections;
import java.lang.reflect.Array;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.javers.common.validation.Validate.argumentCheck;
/**
* @author pawel szymczyk
*/
public class Arrays {
public static Class INT_ARRAY_TYPE = new int[]{}.getClass();
public static Class INTEGER_ARRAY_TYPE = new Integer[]{}.getClass();
public static Class OBJECT_ARRAY_TYPE = new Object[]{}.getClass();
/**
* @return index -> value
*/
public static Map asMap(Object array) {
Map result = new HashMap<>();
if (array == null){
return result;
}
for (int i=0 ;i< Array.getLength(array); i++) {
result.put(i, (T) Array.get(array, i));
}
return result;
}
/**
* @return new list with elements from array
* @throws java.lang.IllegalArgumentException
*/
public static List