private static Set < VM > newVMs ( Model mo , JSONObject o , String key ) throws JSONConverterException { checkKeys ( o , key ) ; Object x = o . get ( key ) ; if ( ! ( x instanceof JSONArray ) ) { throw new JSONConverterException ( "array expected at key '" + key + "'" ) ; } Set < VM > s = new HashSet <> ( ( ( JSONArray ) x ) . size ( ) ) ; for ( Object i : ( JSONArray ) x ) { int id = ( Integer ) i ; VM vm = mo . newVM ( id ) ; if ( vm == null ) { throw JSONConverterException . vmAlreadyDeclared ( id ) ; } s . add ( vm ) ; } return s ; }
Build VMs from a key .