@ SuppressWarnings ( "unchecked" ) @ Nullable static List < ? > getList ( Map < String , ? > obj , String key ) { assert key != null ; if ( ! obj . containsKey ( key ) ) { return null ; } Object value = obj . get ( key ) ; if ( ! ( value instanceof List ) ) { throw new ClassCastException ( String . format ( "value '%s' for key '%s' in '%s' is not List" , value , key , obj ) ) ; } return ( List < ? > ) value ; }
Gets a list from an object for the given key . If the key is not present this returns null . If the value is not a List throws an exception .