@ SuppressWarnings ( { "unchecked" , "rawtypes" } ) public static List < Object > arrayAsList ( Object value ) { if ( value instanceof List ) { return ( List < Object > ) value ; } List list = null ; if ( value instanceof int [ ] ) { list = new ArrayList ( ) ; int [ ] array = ( int [ ] ) value ; for ( int i : array ) { list . add ( i ) ; } } else if ( value instanceof short [ ] ) { list = new ArrayList ( ) ; short [ ] array = ( short [ ] ) value ; for ( short i : array ) { list . add ( i ) ; } } else if ( value instanceof char [ ] ) { list = new ArrayList ( ) ; char [ ] array = ( char [ ] ) value ; for ( char i : array ) { list . add ( i ) ; } } else if ( value instanceof byte [ ] ) { list = new ArrayList ( ) ; byte [ ] array = ( byte [ ] ) value ; for ( byte i : array ) { list . add ( i ) ; } } else if ( value instanceof long [ ] ) { list = new ArrayList ( ) ; long [ ] array = ( long [ ] ) value ; for ( long i : array ) { list . add ( i ) ; } } else if ( value instanceof double [ ] ) { list = new ArrayList ( ) ; double [ ] array = ( double [ ] ) value ; for ( double i : array ) { list . add ( i ) ; } } else if ( value instanceof float [ ] ) { list = new ArrayList ( ) ; float [ ] array = ( float [ ] ) value ; for ( float i : array ) { list . add ( i ) ; } } else if ( value instanceof boolean [ ] ) { list = new ArrayList ( ) ; boolean [ ] array = ( boolean [ ] ) value ; for ( boolean i : array ) { list . add ( i ) ; } } else if ( value . getClass ( ) . isArray ( ) ) { Object [ ] array = ( Object [ ] ) value ; list = Arrays . asList ( array ) ; } return list ; }
Transforms any array to a matching list