public static Meta fromUrl ( URL url ) { InputStream stream = null ; try { stream = url . openStream ( ) ; Gson gson = new GsonBuilder ( ) . registerTypeAdapter ( PropertyForm . class , new TypeAdapter < PropertyForm > ( ) { @ Override public void write ( JsonWriter out , PropertyForm value ) throws IOException { out . value ( value . name ( ) . toLowerCase ( ) ) ; } @ Override public PropertyForm read ( JsonReader in ) throws IOException { return PropertyForm . valueOf ( in . nextString ( ) . toUpperCase ( ) ) ; } } ) . create ( ) ; Map < String , Type > types = gson . fromJson ( new InputStreamReader ( stream ) , new TypeToken < Map < String , Type > > ( ) { } . getType ( ) ) ; return new Meta ( types ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } finally { if ( stream != null ) { try { stream . close ( ) ; } catch ( Exception e ) { } } } }
Reads a JSON object from the given metadata URL and generates a new Meta object containing all types .