private static List<Object> arrayToList(final Object array){
  if (array instanceof Object[])   return Arrays.asList((Object[])array);
  List<Object> result=new ArrayList<Object>();
  if (array instanceof int[])   for (  int value : (int[])array)   result.add(value);
 else   if (array instanceof boolean[])   for (  boolean value : (boolean[])array)   result.add(value);
 else   if (array instanceof long[])   for (  long value : (long[])array)   result.add(value);
 else   if (array instanceof float[])   for (  float value : (float[])array)   result.add(value);
 else   if (array instanceof double[])   for (  double value : (double[])array)   result.add(value);
 else   if (array instanceof short[])   for (  short value : (short[])array)   result.add(value);
 else   if (array instanceof byte[])   for (  byte value : (byte[])array)   result.add(value);
 else   if (array instanceof char[])   for (  char value : (char[])array)   result.add(value);
  return result;
}

private static List < Object > arrayToList ( final Object array ) { if ( array instanceof Object [ ] ) return Arrays . asList ( ( Object [ ] ) array ) ; List < Object > result = new ArrayList < Object > ( ) ; if ( array instanceof int [ ] ) for ( int value : ( int [ ] ) array ) result . add ( value ) ; else if ( array instanceof boolean [ ] ) for ( boolean value : ( boolean [ ] ) array ) result . add ( value ) ; else if ( array instanceof long [ ] ) for ( long value : ( long [ ] ) array ) result . add ( value ) ; else if ( array instanceof float [ ] ) for ( float value : ( float [ ] ) array ) result . add ( value ) ; else if ( array instanceof double [ ] ) for ( double value : ( double [ ] ) array ) result . add ( value ) ; else if ( array instanceof short [ ] ) for ( short value : ( short [ ] ) array ) result . add ( value ) ; else if ( array instanceof byte [ ] ) for ( byte value : ( byte [ ] ) array ) result . add ( value ) ; else if ( array instanceof char [ ] ) for ( char value : ( char [ ] ) array ) result . add ( value ) ; return result ; }
represents array of any type as list of objects so we can easily iterate over it
