private Map < String , String > readConfig ( File f ) throws IOException { Map < String , String > map ; if ( f . getName ( ) . endsWith ( JSON_EXTENSION ) ) { map = flatten ( JSON_MAPPER . readValue ( f , Map . class ) ) ; } else if ( f . getName ( ) . endsWith ( YAML_EXTENSION ) || f . getName ( ) . endsWith ( YML_EXTENSION ) ) { map = flatten ( YAML_MAPPER . readValue ( f , Map . class ) ) ; } else if ( f . getName ( ) . endsWith ( PROPERTIES_EXTENSION ) ) { Properties properties = new Properties ( ) ; properties . load ( new FileInputStream ( f ) ) ; map = propertiesToMap ( properties ) ; } else { throw new IllegalArgumentException ( "Can't read configuration from: [" + f . getName ( ) + "]. Unknown file extension." ) ; } return map ; }
Reads the configuration from the file .