Skip to content

Commit

Permalink
Remove prefix of fields
Browse files Browse the repository at this point in the history
Signed-off-by: jk KPADEY <[email protected]>
  • Loading branch information
mivek committed Feb 15, 2020
1 parent 5bd2d08 commit a31f877
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/main/java/io/github/mivek/command/AirportSupplier.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
*/
public final class AirportSupplier implements Supplier<Airport> {
/** Path of airport file. */
private final InputStream fAirportsFile = AbstractParser.class.getClassLoader().getResourceAsStream("data/airports.dat");
private final InputStream airportsFile = AbstractParser.class.getClassLoader().getResourceAsStream("data/airports.dat");
/** Path of countries file. */
private final InputStream fCountriesFile = AbstractParser.class.getClassLoader().getResourceAsStream("data/countries.dat");
private final InputStream countriesFile = AbstractParser.class.getClassLoader().getResourceAsStream("data/countries.dat");
/** Map of countries. */
private Map<String, Country> fCountries;
private Map<String, Country> countries;
/** Map of airports. */
private Map<String, Airport> fAirports;
private Map<String, Airport> airports;

/**
* Constructor.
Expand All @@ -38,22 +38,22 @@ public AirportSupplier() {
* Initiate airports map.
*/
private void initAirports() {
fAirports = new HashMap<>();
airports = new HashMap<>();
String[] line;
try (CSVReader reader = new CSVReader(new InputStreamReader(fAirportsFile, StandardCharsets.UTF_8))) {
try (CSVReader reader = new CSVReader(new InputStreamReader(airportsFile, StandardCharsets.UTF_8))) {
while ((line = reader.readNext()) != null) {
Airport airport = new Airport();
airport.setName(line[1]);
airport.setCity(line[2]);
airport.setCountry(fCountries.get(line[3]));
airport.setCountry(countries.get(line[3]));
airport.setIata(line[4]);
airport.setIcao(line[5]);
airport.setLatitude(Double.parseDouble(line[6]));
airport.setLongitude(Double.parseDouble(line[7]));
airport.setAltitude(Integer.parseInt(line[8]));
airport.setTimezone(line[9]);
airport.setDst(line[10]);
fAirports.put(airport.getIcao(), airport);
airports.put(airport.getIcao(), airport);
}
} catch (IOException | CsvValidationException exception) {
throw new IllegalStateException(exception.getMessage());
Expand All @@ -64,21 +64,21 @@ private void initAirports() {
* Initiate countries map.
*/
private void initCountries() {
fCountries = new HashMap<>();
countries = new HashMap<>();
String[] line;
try (CSVReader reader = new CSVReader(new InputStreamReader(fCountriesFile, StandardCharsets.UTF_8))) {
try (CSVReader reader = new CSVReader(new InputStreamReader(countriesFile, StandardCharsets.UTF_8))) {
while ((line = reader.readNext()) != null) {
Country country = new Country();
country.setName(line[0]);
fCountries.put(country.getName(), country);
countries.put(country.getName(), country);
}
} catch (IOException | CsvValidationException exception) {
throw new IllegalStateException(exception.getMessage());
}
}

@Override public Airport get(final String pIcao) {
return fAirports.get(pIcao);
return airports.get(pIcao);
}
}

0 comments on commit a31f877

Please sign in to comment.