public Collection < ? > toCollection ( Object val ) { if ( val == null ) { return Collections . emptyList ( ) ; } else if ( val instanceof Collection < ? > ) { return ( Collection < ? > ) val ; } else if ( val . getClass ( ) . isArray ( ) ) { return newArrayList ( ( Object [ ] ) val ) ; } else if ( val instanceof Map < ? , ? > ) { return ( ( Map < ? , ? > ) val ) . entrySet ( ) ; } else { return newArrayList ( val ) ; } }
Coerce to a collection