From 2d5c3913478acd0c852fa2ca7e776106ebb9b70f Mon Sep 17 00:00:00 2001 From: jk KPADEY Date: Tue, 26 May 2020 19:12:57 +0200 Subject: [PATCH] Clean code in metarParser-parsers module Signed-off-by: jk KPADEY --- .../github/mivek/command/AirportSupplier.java | 4 +- .../io/github/mivek/command/Supplier.java | 7 +- .../mivek/command/common/BaseWindCommand.java | 30 ++-- .../mivek/command/common/CloudCommand.java | 16 +- .../github/mivek/command/common/Command.java | 12 +- .../command/common/CommonCommandSupplier.java | 4 +- .../command/common/MainVisibilityCommand.java | 14 +- .../MainVisibilityNauticalMilesCommand.java | 14 +- .../common/MinimalVisibilityCommand.java | 12 +- .../common/VerticalVisibilityCommand.java | 10 +- .../mivek/command/common/WindCommand.java | 16 +- .../command/common/WindExtremeCommand.java | 20 +-- .../command/common/WindShearCommand.java | 16 +- .../mivek/command/metar/AltimeterCommand.java | 10 +- .../command/metar/AltimeterMecuryCommand.java | 10 +- .../github/mivek/command/metar/Command.java | 12 +- .../metar/MetarParserCommandSupplier.java | 4 +- .../mivek/command/metar/RunwayCommand.java | 14 +- .../command/metar/TemperatureCommand.java | 12 +- .../command/remark/CeilingHeightCommand.java | 12 +- .../remark/CeilingSecondLocationCommand.java | 12 +- .../github/mivek/command/remark/Command.java | 20 +-- .../mivek/command/remark/DefaultCommand.java | 12 +- .../mivek/command/remark/HailSizeCommand.java | 12 +- .../command/remark/ObscurationCommand.java | 12 +- .../remark/PrecipitationBegEndCommand.java | 12 +- .../remark/PrevailingVisibilityCommand.java | 12 +- .../command/remark/RemarkCommandSupplier.java | 4 +- .../remark/SeaLevelPressureCommand.java | 12 +- .../SecondLocationVisibilityCommand.java | 12 +- .../remark/SectorVisibilityCommand.java | 12 +- .../command/remark/SmallHailSizeCommand.java | 12 +- .../command/remark/SnowIncreaseCommand.java | 12 +- .../command/remark/SnowPelletsCommand.java | 12 +- .../remark/SurfaceVisibilityCommand.java | 12 +- .../remark/ThunderStormLocationCommand.java | 12 +- .../ThunderStormLocationMovingCommand.java | 12 +- .../remark/TornadicActivityBegCommand.java | 12 +- .../remark/TornadicActivityBegEndCommand.java | 12 +- .../remark/TornadicActivityEndCommand.java | 12 +- .../remark/TowerVisibilityCommand.java | 12 +- .../command/remark/VariableSkyCommand.java | 12 +- .../remark/VariableSkyHeightCommand.java | 12 +- .../command/remark/VirgaDirectionCommand.java | 12 +- .../mivek/command/remark/WindPeakCommand.java | 14 +- .../command/remark/WindShiftCommand.java | 14 +- .../command/remark/WindShiftFropaCommand.java | 14 +- .../io/github/mivek/exception/ErrorCodes.java | 20 +-- .../mivek/exception/ParseException.java | 22 ++- .../github/mivek/parser/AbstractParser.java | 77 +++++----- .../io/github/mivek/parser/MetarParser.java | 81 ++++++----- .../io/github/mivek/parser/RemarkParser.java | 7 +- .../io/github/mivek/parser/TAFParser.java | 137 +++++++++--------- .../mivek/command/AirportSupplierTest.java | 9 +- .../command/common/CloudCommandTest.java | 18 ++- .../common/CommonCommandArchitectureTest.java | 2 +- .../common/CommonCommandSupplierTest.java | 3 +- .../mivek/command/common/WindCommandTest.java | 12 +- .../metar/MetarCommandArchitectureTest.java | 2 +- .../metar/MetarParserCommandSupplierTest.java | 3 +- .../command/metar/RunwayCommandTest.java | 12 +- .../command/remark/DefaultCommandTest.java | 3 +- .../remark/RemarkCommandArchitectureTest.java | 2 +- .../remark/RemarkCommandSupplierTest.java | 3 +- .../mivek/parser/AbstractParserTest.java | 3 +- .../github/mivek/parser/GeneralParseTest.java | 26 ++-- .../github/mivek/parser/MetarParserTest.java | 11 +- .../github/mivek/parser/RemarkParserTest.java | 117 ++++++++++----- .../io/github/mivek/parser/TAFParserTest.java | 57 +++----- 69 files changed, 624 insertions(+), 582 deletions(-) diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/AirportSupplier.java b/metarParser-parsers/src/main/java/io/github/mivek/command/AirportSupplier.java index 28d364e1..22c9eb14 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/AirportSupplier.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/AirportSupplier.java @@ -21,14 +21,14 @@ public AirportSupplier() { } @Override - public Airport get(final String pIcao) { + public Airport get(final String string) { AirportProvider provider; if (airportLoader.iterator().hasNext()) { provider = airportLoader.iterator().next(); } else { provider = new DefaultAirportProvider(); } - return provider.getAirports().get(pIcao); + return provider.getAirports().get(string); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/Supplier.java b/metarParser-parsers/src/main/java/io/github/mivek/command/Supplier.java index 1c020143..818dfd09 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/Supplier.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/Supplier.java @@ -4,12 +4,13 @@ * @param type of command to return. * @author mivek */ -@FunctionalInterface public interface Supplier { +@FunctionalInterface +public interface Supplier { /** - * @param pString the string to parse. + * @param string the string to parse. * @return the command able to parse the string. */ - T get(String pString); + T get(String string); } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/common/BaseWindCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/common/BaseWindCommand.java index 017a650a..aba32153 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/common/BaseWindCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/common/BaseWindCommand.java @@ -12,26 +12,26 @@ public interface BaseWindCommand extends Command { /** * Sets the elements of the wind. * - * @param pWind the wind element. - * @param pDirection the direction of the wind in degrees. - * @param pSpeed the speed of the wind - * @param pGust the speed of the gust if any - * @param pUnit the unit. + * @param wind the wind element. + * @param directionStr the direction of the wind in degrees. + * @param speed the speed of the wind + * @param gust the speed of the gust if any + * @param unit the unit. */ - default void setWindElements(final Wind pWind, final String pDirection, final String pSpeed, final String pGust, final String pUnit) { - String direction = Converter.degreesToDirection(pDirection); - pWind.setDirection(direction); + default void setWindElements(final Wind wind, final String directionStr, final String speed, final String gust, final String unit) { + String direction = Converter.degreesToDirection(directionStr); + wind.setDirection(direction); if (!direction.equals(Messages.getInstance().getString("Converter.VRB"))) { - pWind.setDirectionDegrees(Integer.parseInt(pDirection)); + wind.setDirectionDegrees(Integer.parseInt(directionStr)); } - pWind.setSpeed(Integer.parseInt(pSpeed)); - if (pGust != null) { - pWind.setGust(Integer.parseInt(pGust)); + wind.setSpeed(Integer.parseInt(speed)); + if (gust != null) { + wind.setGust(Integer.parseInt(gust)); } - if (pUnit == null) { - pWind.setUnit("KT"); + if (unit == null) { + wind.setUnit("KT"); } else { - pWind.setUnit(pUnit); + wind.setUnit(unit); } } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/common/CloudCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/common/CloudCommand.java index a8caba7d..896318c1 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/common/CloudCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/common/CloudCommand.java @@ -22,20 +22,20 @@ public final class CloudCommand implements Command { } @Override - public boolean execute(final AbstractWeatherContainer pContainer, final String pPart) { - Cloud c = parseCloud(pPart); - return pContainer.addCloud(c); + public boolean execute(final AbstractWeatherContainer container, final String part) { + Cloud c = parseCloud(part); + return container.addCloud(c); } /** * This method parses the cloud part of the metar. * - * @param pCloudString string with cloud elements. + * @param cloudString string with cloud elements. * @return a decoded cloud with its quantity, its altitude and its type. */ - protected Cloud parseCloud(final String pCloudString) { + protected Cloud parseCloud(final String cloudString) { Cloud cloud = new Cloud(); - String[] cloudPart = Regex.pregMatch(CLOUD_REGEX, pCloudString); + String[] cloudPart = Regex.pregMatch(CLOUD_REGEX, cloudString); try { CloudQuantity cq = CloudQuantity.valueOf(cloudPart[1]); cloud.setQuantity(cq); @@ -53,8 +53,8 @@ protected Cloud parseCloud(final String pCloudString) { } @Override - public boolean canParse(final String pInput) { - return Regex.find(CLOUD_REGEX, pInput); + public boolean canParse(final String input) { + return Regex.find(CLOUD_REGEX, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/common/Command.java b/metarParser-parsers/src/main/java/io/github/mivek/command/common/Command.java index 95d24152..12d0bd6f 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/common/Command.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/common/Command.java @@ -8,13 +8,13 @@ public interface Command { /** - * Handles the pPart and updates the pContainer. + * Handles the pqrt and updates the container. * - * @param pContainer the container to update. - * @param pPart the string to parse. + * @param container the container to update. + * @param part the string to parse. * @return true if the part has been properly handled false otherwise */ - boolean execute(AbstractWeatherContainer pContainer, String pPart); + boolean execute(AbstractWeatherContainer container, String part); /** * @return the default return value of a command. @@ -24,8 +24,8 @@ default boolean getReturnValue() { } /** - * @param pInput the input string to test. + * @param input the input string to test. * @return true if the input can be handled by the command. */ - boolean canParse(String pInput); + boolean canParse(String input); } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/common/CommonCommandSupplier.java b/metarParser-parsers/src/main/java/io/github/mivek/command/common/CommonCommandSupplier.java index 058c6606..a9ab8b91 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/common/CommonCommandSupplier.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/common/CommonCommandSupplier.java @@ -20,9 +20,9 @@ public CommonCommandSupplier() { } @Override - public Command get(final String pString) { + public Command get(final String string) { for (Command command : commands) { - if (command.canParse(pString)) { + if (command.canParse(string)) { return command; } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/common/MainVisibilityCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/common/MainVisibilityCommand.java index 4d398094..6f31e1da 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/common/MainVisibilityCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/common/MainVisibilityCommand.java @@ -21,17 +21,17 @@ public final class MainVisibilityCommand implements Command { } @Override - public boolean execute(final AbstractWeatherContainer pContainer, final String pPart) { - String[] matches = Regex.pregMatch(MAIN_VISIBILITY_REGEX, pPart); - if (pContainer.getVisibility() == null) { - pContainer.setVisibility(new Visibility()); + public boolean execute(final AbstractWeatherContainer container, final String part) { + String[] matches = Regex.pregMatch(MAIN_VISIBILITY_REGEX, part); + if (container.getVisibility() == null) { + container.setVisibility(new Visibility()); } - pContainer.getVisibility().setMainVisibility(Converter.convertVisibility(matches[1])); + container.getVisibility().setMainVisibility(Converter.convertVisibility(matches[1])); return getReturnValue(); } @Override - public boolean canParse(final String pInput) { - return Regex.find(MAIN_VISIBILITY_REGEX, pInput); + public boolean canParse(final String input) { + return Regex.find(MAIN_VISIBILITY_REGEX, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/common/MainVisibilityNauticalMilesCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/common/MainVisibilityNauticalMilesCommand.java index 04f36afb..707d19bf 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/common/MainVisibilityNauticalMilesCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/common/MainVisibilityNauticalMilesCommand.java @@ -20,17 +20,17 @@ public final class MainVisibilityNauticalMilesCommand implements Command { } @Override - public boolean execute(final AbstractWeatherContainer pContainer, final String pPart) { - String[] matches = Regex.pregMatch(MAIN_VISIBILITY_SM_REGEX, pPart); - if (pContainer.getVisibility() == null) { - pContainer.setVisibility(new Visibility()); + public boolean execute(final AbstractWeatherContainer container, final String part) { + String[] matches = Regex.pregMatch(MAIN_VISIBILITY_SM_REGEX, part); + if (container.getVisibility() == null) { + container.setVisibility(new Visibility()); } - pContainer.getVisibility().setMainVisibility(matches[0]); + container.getVisibility().setMainVisibility(matches[0]); return getReturnValue(); } @Override - public boolean canParse(final String pInput) { - return Regex.find(MAIN_VISIBILITY_SM_REGEX, pInput); + public boolean canParse(final String input) { + return Regex.find(MAIN_VISIBILITY_SM_REGEX, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/common/MinimalVisibilityCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/common/MinimalVisibilityCommand.java index 1cedc8dc..42b08df5 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/common/MinimalVisibilityCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/common/MinimalVisibilityCommand.java @@ -19,15 +19,15 @@ public final class MinimalVisibilityCommand implements Command { } @Override - public boolean execute(final AbstractWeatherContainer pContainer, final String pPart) { - String[] matches = Regex.pregMatch(MIN_VISIBILITY_REGEX, pPart); - pContainer.getVisibility().setMinVisibility(Integer.parseInt(matches[1].substring(0, 4))); - pContainer.getVisibility().setMinDirection(matches[1].substring(4)); + public boolean execute(final AbstractWeatherContainer container, final String part) { + String[] matches = Regex.pregMatch(MIN_VISIBILITY_REGEX, part); + container.getVisibility().setMinVisibility(Integer.parseInt(matches[1].substring(0, 4))); + container.getVisibility().setMinDirection(matches[1].substring(4)); return getReturnValue(); } @Override - public boolean canParse(final String pInput) { - return Regex.find(MIN_VISIBILITY_REGEX, pInput); + public boolean canParse(final String input) { + return Regex.find(MIN_VISIBILITY_REGEX, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/common/VerticalVisibilityCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/common/VerticalVisibilityCommand.java index a4167b0e..ccc6ccbf 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/common/VerticalVisibilityCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/common/VerticalVisibilityCommand.java @@ -19,14 +19,14 @@ public final class VerticalVisibilityCommand implements Command { } @Override - public boolean execute(final AbstractWeatherContainer pContainer, final String pPart) { - String[] matches = Regex.pregMatch(VERTICAL_VISIBILITY, pPart); - pContainer.setVerticalVisibility(100 * Integer.parseInt(matches[1])); + public boolean execute(final AbstractWeatherContainer container, final String part) { + String[] matches = Regex.pregMatch(VERTICAL_VISIBILITY, part); + container.setVerticalVisibility(100 * Integer.parseInt(matches[1])); return getReturnValue(); } @Override - public boolean canParse(final String pInput) { - return Regex.find(VERTICAL_VISIBILITY, pInput); + public boolean canParse(final String input) { + return Regex.find(VERTICAL_VISIBILITY, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/common/WindCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/common/WindCommand.java index 91aa3204..33b1f86f 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/common/WindCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/common/WindCommand.java @@ -23,25 +23,25 @@ public final class WindCommand implements BaseWindCommand { * This method parses the wind part of the metar code. It parses the generic * part. * - * @param pStringWind a string with wind elements. + * @param stringWind a string with wind elements. * @return a Wind element with the informations. */ - protected Wind parseWind(final String pStringWind) { + protected Wind parseWind(final String stringWind) { Wind wind = new Wind(); - String[] windPart = Regex.pregMatch(WIND_REGEX, pStringWind); + String[] windPart = Regex.pregMatch(WIND_REGEX, stringWind); setWindElements(wind, windPart[1], windPart[2], windPart[3], windPart[4]); return wind; } @Override - public boolean execute(final AbstractWeatherContainer pContainer, final String pPart) { - Wind wind = parseWind(pPart); - pContainer.setWind(wind); + public boolean execute(final AbstractWeatherContainer container, final String part) { + Wind wind = parseWind(part); + container.setWind(wind); return getReturnValue(); } @Override - public boolean canParse(final String pInput) { - return Regex.find(WIND_REGEX, pInput); + public boolean canParse(final String input) { + return Regex.find(WIND_REGEX, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/common/WindExtremeCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/common/WindExtremeCommand.java index 6cb3313c..e350bc4c 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/common/WindExtremeCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/common/WindExtremeCommand.java @@ -20,25 +20,25 @@ public final class WindExtremeCommand implements Command { } @Override - public boolean execute(final AbstractWeatherContainer pContainer, final String pPart) { - parseExtremeWind(pContainer.getWind(), pPart); + public boolean execute(final AbstractWeatherContainer container, final String part) { + parseWindVariation(container.getWind(), part); return getReturnValue(); } /** * Parses the wind. * - * @param pWind the wind to update - * @param pExtremeWind String with extreme wind information + * @param wind the wind to update + * @param windVariation String with wind variation information */ - protected void parseExtremeWind(final Wind pWind, final String pExtremeWind) { - String[] matches = Regex.pregMatch(WIND_EXTREME_REGEX, pExtremeWind); - pWind.setExtreme1(Integer.parseInt(matches[1])); - pWind.setExtreme2(Integer.parseInt(matches[2])); + protected void parseWindVariation(final Wind wind, final String windVariation) { + String[] matches = Regex.pregMatch(WIND_EXTREME_REGEX, windVariation); + wind.setMinVariation(Integer.parseInt(matches[1])); + wind.setMaxVariation(Integer.parseInt(matches[2])); } @Override - public boolean canParse(final String pInput) { - return Regex.find(WIND_EXTREME_REGEX, pInput); + public boolean canParse(final String input) { + return Regex.find(WIND_EXTREME_REGEX, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/common/WindShearCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/common/WindShearCommand.java index 1e53b411..dcaae774 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/common/WindShearCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/common/WindShearCommand.java @@ -20,28 +20,28 @@ public final class WindShearCommand implements BaseWindCommand { } @Override - public boolean execute(final AbstractWeatherContainer pContainer, final String pPart) { - WindShear windShear = parseWindShear(pPart); - pContainer.setWindShear(windShear); + public boolean execute(final AbstractWeatherContainer container, final String part) { + WindShear windShear = parseWindShear(part); + container.setWindShear(windShear); return getReturnValue(); } /** * Parses the wind shear part. * - * @param pStringWindShear the string to parse + * @param stringWindShear the string to parse * @return a wind shear object. */ - protected WindShear parseWindShear(final String pStringWindShear) { + protected WindShear parseWindShear(final String stringWindShear) { WindShear wind = new WindShear(); - String[] windPart = Regex.pregMatch(WIND_SHEAR_REGEX, pStringWindShear); + String[] windPart = Regex.pregMatch(WIND_SHEAR_REGEX, stringWindShear); wind.setHeight(100 * Integer.parseInt(windPart[1])); setWindElements(wind, windPart[2], windPart[3], windPart[4], windPart[5]); return wind; } @Override - public boolean canParse(final String pInput) { - return Regex.find(WIND_SHEAR_REGEX, pInput); + public boolean canParse(final String input) { + return Regex.find(WIND_SHEAR_REGEX, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/metar/AltimeterCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/metar/AltimeterCommand.java index 06de399a..d7c84982 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/metar/AltimeterCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/metar/AltimeterCommand.java @@ -20,13 +20,13 @@ public final class AltimeterCommand implements Command { } @Override - public void execute(final Metar pMetar, final String pPart) { - String[] matches = Regex.pregMatch(ALTIMETER_REGEX, pPart); - pMetar.setAltimeter(Integer.parseInt(matches[1])); + public void execute(final Metar metar, final String part) { + String[] matches = Regex.pregMatch(ALTIMETER_REGEX, part); + metar.setAltimeter(Integer.parseInt(matches[1])); } @Override - public boolean canParse(final String pInput) { - return Regex.find(ALTIMETER_REGEX, pInput); + public boolean canParse(final String input) { + return Regex.find(ALTIMETER_REGEX, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/metar/AltimeterMecuryCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/metar/AltimeterMecuryCommand.java index 2ea964d7..59f03c25 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/metar/AltimeterMecuryCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/metar/AltimeterMecuryCommand.java @@ -21,14 +21,14 @@ public final class AltimeterMecuryCommand implements Command { } @Override - public void execute(final Metar pMetar, final String pPart) { - String[] matches = Regex.pregMatch(ALTIMETER_MERCURY_REGEX, pPart); + public void execute(final Metar metar, final String part) { + String[] matches = Regex.pregMatch(ALTIMETER_MERCURY_REGEX, part); double mercury = Double.parseDouble(matches[1]) / 100; - pMetar.setAltimeter((int) Converter.inchesMercuryToHPascal(mercury)); + metar.setAltimeter((int) Converter.inchesMercuryToHPascal(mercury)); } @Override - public boolean canParse(final String pInput) { - return Regex.find(ALTIMETER_MERCURY_REGEX, pInput); + public boolean canParse(final String input) { + return Regex.find(ALTIMETER_MERCURY_REGEX, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/metar/Command.java b/metarParser-parsers/src/main/java/io/github/mivek/command/metar/Command.java index 2208e2eb..8f56f5ef 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/metar/Command.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/metar/Command.java @@ -10,16 +10,16 @@ public interface Command { /** - * Methode handling the pPart to parse. + * Method handling the part to parse. * - * @param pMetar the metar object to handle. - * @param pPart the string to parse. + * @param metar the metar object to handle. + * @param part the string to parse. */ - void execute(Metar pMetar, String pPart); + void execute(Metar metar, String part); /** - * @param pInput the input string to test. + * @param input the input string to test. * @return true if the input can be handled by the command. */ - boolean canParse(String pInput); + boolean canParse(String input); } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/metar/MetarParserCommandSupplier.java b/metarParser-parsers/src/main/java/io/github/mivek/command/metar/MetarParserCommandSupplier.java index c9bdb280..eb7afb68 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/metar/MetarParserCommandSupplier.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/metar/MetarParserCommandSupplier.java @@ -20,9 +20,9 @@ public MetarParserCommandSupplier() { } @Override - public Command get(final String pString) { + public Command get(final String string) { for (Command command : commands) { - if (command.canParse(pString)) { + if (command.canParse(string)) { return command; } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/metar/RunwayCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/metar/RunwayCommand.java index 19762452..e7f52c6e 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/metar/RunwayCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/metar/RunwayCommand.java @@ -26,28 +26,28 @@ public final class RunwayCommand implements Command { } @Override - public void execute(final Metar pMetar, final String pPart) { + public void execute(final Metar metar, final String part) { RunwayInfo ri = new RunwayInfo(); - String[] matches = Regex.pregMatch(RUNWAY_REGEX, pPart); + String[] matches = Regex.pregMatch(RUNWAY_REGEX, part); if (ArrayUtils.isNotEmpty(matches)) { ri.setName(matches[1]); ri.setMinRange(Integer.parseInt(matches[3])); ri.setTrend(Converter.convertTrend(matches[4])); - pMetar.addRunwayInfo(ri); + metar.addRunwayInfo(ri); } - matches = Regex.pregMatch(RUNWAY_MAX_RANGE_REGEX, pPart); + matches = Regex.pregMatch(RUNWAY_MAX_RANGE_REGEX, part); if (ArrayUtils.isNotEmpty(matches)) { ri.setName(matches[1]); ri.setMinRange(Integer.parseInt(matches[2])); ri.setMaxRange(Integer.parseInt(matches[3])); ri.setTrend(Converter.convertTrend(matches[4])); - pMetar.addRunwayInfo(ri); + metar.addRunwayInfo(ri); } } @Override - public boolean canParse(final String pInput) { - return Regex.find(GENERIC_RUNWAY_REGEX, pInput); + public boolean canParse(final String input) { + return Regex.find(GENERIC_RUNWAY_REGEX, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/metar/TemperatureCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/metar/TemperatureCommand.java index 7ec0a3f8..9177ea41 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/metar/TemperatureCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/metar/TemperatureCommand.java @@ -20,14 +20,14 @@ public final class TemperatureCommand implements Command { } @Override - public void execute(final Metar pMetar, final String pPart) { - String[] matches = Regex.pregMatch(TEMPERATURE_REGEX, pPart); - pMetar.setTemperature(Converter.convertTemperature(matches[1])); - pMetar.setDewPoint(Converter.convertTemperature(matches[2])); + public void execute(final Metar metar, final String part) { + String[] matches = Regex.pregMatch(TEMPERATURE_REGEX, part); + metar.setTemperature(Converter.convertTemperature(matches[1])); + metar.setDewPoint(Converter.convertTemperature(matches[2])); } @Override - public boolean canParse(final String pInput) { - return Regex.find(TEMPERATURE_REGEX, pInput); + public boolean canParse(final String input) { + return Regex.find(TEMPERATURE_REGEX, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/CeilingHeightCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/CeilingHeightCommand.java index 96b4a832..08817775 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/CeilingHeightCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/CeilingHeightCommand.java @@ -23,16 +23,16 @@ public final class CeilingHeightCommand implements Command { } @Override - public String execute(final String pRemark, final StringBuilder pStringBuilder) { - String[] ceilingParts = Regex.pregMatch(CEILING_HEIGHT, pRemark); + public String execute(final String remark, final StringBuilder stringBuilder) { + String[] ceilingParts = Regex.pregMatch(CEILING_HEIGHT, remark); int min = Integer.parseInt(ceilingParts[1]) * 100; int max = Integer.parseInt(ceilingParts[2]) * 100; - pStringBuilder.append(messages.getString("Remark.Ceiling.Height", min, max)).append(" "); - return pRemark.replaceFirst(CEILING_HEIGHT.pattern(), "").trim(); + stringBuilder.append(messages.getString("Remark.Ceiling.Height", min, max)).append(" "); + return remark.replaceFirst(CEILING_HEIGHT.pattern(), "").trim(); } @Override - public boolean canParse(final String pInput) { - return Regex.find(CEILING_HEIGHT, pInput); + public boolean canParse(final String input) { + return Regex.find(CEILING_HEIGHT, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/CeilingSecondLocationCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/CeilingSecondLocationCommand.java index 58d08ed9..84134fe9 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/CeilingSecondLocationCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/CeilingSecondLocationCommand.java @@ -23,16 +23,16 @@ public final class CeilingSecondLocationCommand implements Command { } @Override - public String execute(final String pRemark, final StringBuilder pStringBuilder) { - String[] ceilingParts = Regex.pregMatch(CEILING_SECOND_LOCATION, pRemark); + public String execute(final String remark, final StringBuilder stringBuilder) { + String[] ceilingParts = Regex.pregMatch(CEILING_SECOND_LOCATION, remark); int height = 100 * Integer.parseInt(ceilingParts[1]); String location = ceilingParts[2]; - pStringBuilder.append(messages.getString("Remark.Ceiling.Second.Location", height, location)).append(" "); - return pRemark.replaceFirst(CEILING_SECOND_LOCATION.pattern(), "").trim(); + stringBuilder.append(messages.getString("Remark.Ceiling.Second.Location", height, location)).append(" "); + return remark.replaceFirst(CEILING_SECOND_LOCATION.pattern(), "").trim(); } @Override - public boolean canParse(final String pInput) { - return Regex.find(CEILING_SECOND_LOCATION, pInput); + public boolean canParse(final String input) { + return Regex.find(CEILING_SECOND_LOCATION, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/Command.java b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/Command.java index ce74de54..4c54070e 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/Command.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/Command.java @@ -6,28 +6,28 @@ public interface Command { /** - * @param pRemark the remark to parse. - * @param pStringBuilder the string builder containing the decoded remark + * @param remark the remark to parse. + * @param stringBuilder the string builder containing the decoded remark * @return the remark without the parsed part */ - String execute(String pRemark, StringBuilder pStringBuilder); + String execute(String remark, StringBuilder stringBuilder); /** * Checks if the string is null. * - * @param pString the string to test - * @return empty string if null pString otherwise. + * @param string the string to test + * @return empty string if null string otherwise. */ - default String verifyString(final String pString) { - if (pString == null) { + default String verifyString(final String string) { + if (string == null) { return ""; } - return pString; + return string; } /** - * @param pInput the input string to test. + * @param input the input string to test. * @return true if the input can be handled by the command. */ - boolean canParse(String pInput); + boolean canParse(String input); } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/DefaultCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/DefaultCommand.java index 8913530e..12cda40e 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/DefaultCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/DefaultCommand.java @@ -23,20 +23,20 @@ public final class DefaultCommand implements Command { } @Override - public boolean canParse(final String pInput) { + public boolean canParse(final String input) { return true; } /** * Handle the default behavior when a remark token is not recognized by regex. * - * @param pRemark the remark string - * @param pStringBuilder The string builder containing the parsed message of the remark + * @param remark the remark string + * @param stringBuilder The string builder containing the parsed message of the remark * @return the remark string. */ @Override - public String execute(final String pRemark, final StringBuilder pStringBuilder) { - String rmk = pRemark; + public String execute(final String remark, final StringBuilder stringBuilder) { + String rmk = remark; String[] strSlit = rmk.split(" ", 2); String token = strSlit[0]; try { @@ -44,7 +44,7 @@ public String execute(final String pRemark, final StringBuilder pStringBuilder) } catch (MissingResourceException e) { LOGGER.info("Remark token \"" + token + "\" is unknown."); } - pStringBuilder.append(token).append(" "); + stringBuilder.append(token).append(" "); rmk = strSlit.length == 1 ? "" : strSlit[1]; return rmk; } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/HailSizeCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/HailSizeCommand.java index 6b0c73e2..e81a3b36 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/HailSizeCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/HailSizeCommand.java @@ -23,14 +23,14 @@ public final class HailSizeCommand implements Command { } @Override - public String execute(final String pRemark, final StringBuilder pStringBuilder) { - String[] hailParts = Regex.pregMatch(HAIL_SIZE, pRemark); - pStringBuilder.append(messages.getString("Remark.Hail", hailParts[1])).append(" "); - return pRemark.replaceFirst(HAIL_SIZE.pattern(), "").trim(); + public String execute(final String remark, final StringBuilder stringBuilder) { + String[] hailParts = Regex.pregMatch(HAIL_SIZE, remark); + stringBuilder.append(messages.getString("Remark.Hail", hailParts[1])).append(" "); + return remark.replaceFirst(HAIL_SIZE.pattern(), "").trim(); } @Override - public boolean canParse(final String pInput) { - return Regex.find(HAIL_SIZE, pInput); + public boolean canParse(final String input) { + return Regex.find(HAIL_SIZE, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/ObscurationCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/ObscurationCommand.java index 9fd2d023..d5378067 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/ObscurationCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/ObscurationCommand.java @@ -23,17 +23,17 @@ public final class ObscurationCommand implements Command { } @Override - public String execute(final String pRemark, final StringBuilder pStringBuilder) { - String[] obscuration = Regex.pregMatch(OBSCURATION, pRemark); + public String execute(final String remark, final StringBuilder stringBuilder) { + String[] obscuration = Regex.pregMatch(OBSCURATION, remark); String layer = messages.getString("CloudQuantity." + obscuration[2]); int height = Integer.parseInt(obscuration[3]) * 100; String obscDetail = messages.getString("Phenomenon." + obscuration[1]); - pStringBuilder.append(messages.getString("Remark.Obscuration", layer, height, obscDetail)).append(" "); - return pRemark.replaceFirst(OBSCURATION.pattern(), "").trim(); + stringBuilder.append(messages.getString("Remark.Obscuration", layer, height, obscDetail)).append(" "); + return remark.replaceFirst(OBSCURATION.pattern(), "").trim(); } @Override - public boolean canParse(final String pInput) { - return Regex.find(OBSCURATION, pInput); + public boolean canParse(final String input) { + return Regex.find(OBSCURATION, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/PrecipitationBegEndCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/PrecipitationBegEndCommand.java index 253d673c..c80ae84b 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/PrecipitationBegEndCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/PrecipitationBegEndCommand.java @@ -23,16 +23,16 @@ public final class PrecipitationBegEndCommand implements Command { } @Override - public String execute(final String pRemark, final StringBuilder pStringBuilder) { - String[] precipitationBegEnd = Regex.pregMatch(PRECIPITATION_BEG_END, pRemark); - pStringBuilder.append(messages.getString("Remark.Precipitation.Beg.End", precipitationBegEnd[2] == null ? "" : messages.getString("Descriptive." + precipitationBegEnd[2]), + public String execute(final String remark, final StringBuilder stringBuilder) { + String[] precipitationBegEnd = Regex.pregMatch(PRECIPITATION_BEG_END, remark); + stringBuilder.append(messages.getString("Remark.Precipitation.Beg.End", precipitationBegEnd[2] == null ? "" : messages.getString("Descriptive." + precipitationBegEnd[2]), messages.getString("Phenomenon." + precipitationBegEnd[3]), verifyString(precipitationBegEnd[4]), precipitationBegEnd[5], verifyString(precipitationBegEnd[6]), precipitationBegEnd[7])) .append(" "); - return pRemark.replaceFirst(PRECIPITATION_BEG_END.pattern(), "").trim(); + return remark.replaceFirst(PRECIPITATION_BEG_END.pattern(), "").trim(); } @Override - public boolean canParse(final String pInput) { - return Regex.find(PRECIPITATION_BEG_END, pInput); + public boolean canParse(final String input) { + return Regex.find(PRECIPITATION_BEG_END, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/PrevailingVisibilityCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/PrevailingVisibilityCommand.java index 7c9e56ac..0a2bd971 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/PrevailingVisibilityCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/PrevailingVisibilityCommand.java @@ -22,14 +22,14 @@ public final class PrevailingVisibilityCommand implements Command { } @Override - public String execute(final String pRemark, final StringBuilder pStringBuilder) { - String[] visibilityParts = Regex.pregMatch(VARIABLE_PREVAILING_VISIBILITY, pRemark); - pStringBuilder.append(messages.getString("Remark.Variable.Prevailing.Visibility", visibilityParts[1], visibilityParts[5])).append(" "); - return pRemark.replaceFirst(VARIABLE_PREVAILING_VISIBILITY.pattern(), "").trim(); + public String execute(final String remark, final StringBuilder stringBuilder) { + String[] visibilityParts = Regex.pregMatch(VARIABLE_PREVAILING_VISIBILITY, remark); + stringBuilder.append(messages.getString("Remark.Variable.Prevailing.Visibility", visibilityParts[1], visibilityParts[5])).append(" "); + return remark.replaceFirst(VARIABLE_PREVAILING_VISIBILITY.pattern(), "").trim(); } @Override - public boolean canParse(final String pInput) { - return Regex.find(VARIABLE_PREVAILING_VISIBILITY, pInput); + public boolean canParse(final String input) { + return Regex.find(VARIABLE_PREVAILING_VISIBILITY, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/RemarkCommandSupplier.java b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/RemarkCommandSupplier.java index 7abfe2a4..243b9cf7 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/RemarkCommandSupplier.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/RemarkCommandSupplier.java @@ -24,9 +24,9 @@ public RemarkCommandSupplier() { } @Override - public Command get(final String pString) { + public Command get(final String string) { for (Command command : commands) { - if (command.canParse(pString)) { + if (command.canParse(string)) { return command; } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/SeaLevelPressureCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/SeaLevelPressureCommand.java index 4603cecf..ae88f56a 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/SeaLevelPressureCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/SeaLevelPressureCommand.java @@ -23,8 +23,8 @@ public final class SeaLevelPressureCommand implements Command { } @Override - public String execute(final String pRemark, final StringBuilder pStringBuilder) { - String[] sealevelParts = Regex.pregMatch(SEAL_LEVEL_PRESSURE, pRemark); + public String execute(final String remark, final StringBuilder stringBuilder) { + String[] sealevelParts = Regex.pregMatch(SEAL_LEVEL_PRESSURE, remark); StringBuilder pressure = new StringBuilder(); if (sealevelParts[1].startsWith("9")) { pressure.append("9"); @@ -32,13 +32,13 @@ public String execute(final String pRemark, final StringBuilder pStringBuilder) pressure.append("10"); } pressure.append(sealevelParts[1]).append(".").append(sealevelParts[2]); - pStringBuilder.append(messages.getString("Remark.Sea.Level.Pressure", pressure)).append(" "); - return pRemark.replaceFirst(SEAL_LEVEL_PRESSURE.pattern(), "").trim(); + stringBuilder.append(messages.getString("Remark.Sea.Level.Pressure", pressure)).append(" "); + return remark.replaceFirst(SEAL_LEVEL_PRESSURE.pattern(), "").trim(); } @Override - public boolean canParse(final String pInput) { - return Regex.find(SEAL_LEVEL_PRESSURE, pInput); + public boolean canParse(final String input) { + return Regex.find(SEAL_LEVEL_PRESSURE, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/SecondLocationVisibilityCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/SecondLocationVisibilityCommand.java index 88519507..598eac69 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/SecondLocationVisibilityCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/SecondLocationVisibilityCommand.java @@ -24,14 +24,14 @@ public final class SecondLocationVisibilityCommand implements Command { } @Override - public String execute(final String pRemark, final StringBuilder pStringBuilder) { - String[] secondLocationVisibilityParts = Regex.pregMatch(SECOND_LOCATION_VISIBILITY, pRemark); - pStringBuilder.append(messages.getString("Remark.Second.Location.Visibility", secondLocationVisibilityParts[1], secondLocationVisibilityParts[5])).append(" "); - return pRemark.replaceFirst(SECOND_LOCATION_VISIBILITY.pattern(), "").trim(); + public String execute(final String remark, final StringBuilder stringBuilder) { + String[] secondLocationVisibilityParts = Regex.pregMatch(SECOND_LOCATION_VISIBILITY, remark); + stringBuilder.append(messages.getString("Remark.Second.Location.Visibility", secondLocationVisibilityParts[1], secondLocationVisibilityParts[5])).append(" "); + return remark.replaceFirst(SECOND_LOCATION_VISIBILITY.pattern(), "").trim(); } @Override - public boolean canParse(final String pInput) { - return Regex.find(SECOND_LOCATION_VISIBILITY, pInput); + public boolean canParse(final String input) { + return Regex.find(SECOND_LOCATION_VISIBILITY, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/SectorVisibilityCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/SectorVisibilityCommand.java index 59eef6a3..5955918d 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/SectorVisibilityCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/SectorVisibilityCommand.java @@ -23,14 +23,14 @@ public final class SectorVisibilityCommand implements Command { } @Override - public String execute(final String pRemark, final StringBuilder pStringBuilder) { - String[] sectorVisibilityParts = Regex.pregMatch(SECTOR_VISIBILITY, pRemark); - pStringBuilder.append(messages.getString("Remark.Sector.Visibility", messages.getString("Converter." + sectorVisibilityParts[1]), sectorVisibilityParts[2])).append(" "); - return pRemark.replaceFirst(SECTOR_VISIBILITY.pattern(), "").trim(); + public String execute(final String remark, final StringBuilder stringBuilder) { + String[] sectorVisibilityParts = Regex.pregMatch(SECTOR_VISIBILITY, remark); + stringBuilder.append(messages.getString("Remark.Sector.Visibility", messages.getString("Converter." + sectorVisibilityParts[1]), sectorVisibilityParts[2])).append(" "); + return remark.replaceFirst(SECTOR_VISIBILITY.pattern(), "").trim(); } @Override - public boolean canParse(final String pInput) { - return Regex.find(SECTOR_VISIBILITY, pInput); + public boolean canParse(final String input) { + return Regex.find(SECTOR_VISIBILITY, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/SmallHailSizeCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/SmallHailSizeCommand.java index 95ec2d6e..bb6fb6a6 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/SmallHailSizeCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/SmallHailSizeCommand.java @@ -23,14 +23,14 @@ public final class SmallHailSizeCommand implements Command { } @Override - public String execute(final String pRemark, final StringBuilder pStringBuilder) { - String[] hailParts = Regex.pregMatch(HAIL_SIZE_LESS_THAN, pRemark); - pStringBuilder.append(messages.getString("Remark.Hail.LesserThan", hailParts[1])).append(" "); - return pRemark.replaceFirst(HAIL_SIZE_LESS_THAN.pattern(), "").trim(); + public String execute(final String remark, final StringBuilder stringBuilder) { + String[] hailParts = Regex.pregMatch(HAIL_SIZE_LESS_THAN, remark); + stringBuilder.append(messages.getString("Remark.Hail.LesserThan", hailParts[1])).append(" "); + return remark.replaceFirst(HAIL_SIZE_LESS_THAN.pattern(), "").trim(); } @Override - public boolean canParse(final String pInput) { - return Regex.find(HAIL_SIZE_LESS_THAN, pInput); + public boolean canParse(final String input) { + return Regex.find(HAIL_SIZE_LESS_THAN, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/SnowIncreaseCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/SnowIncreaseCommand.java index a4d1ee8e..a649ee08 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/SnowIncreaseCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/SnowIncreaseCommand.java @@ -23,14 +23,14 @@ public final class SnowIncreaseCommand implements Command { } @Override - public String execute(final String pRemark, final StringBuilder pStringBuilder) { - String[] snowParts = Regex.pregMatch(SNOW_INCR_RAPIDLY, pRemark); - pStringBuilder.append(messages.getString("Remark.Snow.Increasing.Rapidly", snowParts[1], snowParts[2])).append(" "); - return pRemark.replaceFirst(SNOW_INCR_RAPIDLY.pattern(), "").trim(); + public String execute(final String remark, final StringBuilder stringBuilder) { + String[] snowParts = Regex.pregMatch(SNOW_INCR_RAPIDLY, remark); + stringBuilder.append(messages.getString("Remark.Snow.Increasing.Rapidly", snowParts[1], snowParts[2])).append(" "); + return remark.replaceFirst(SNOW_INCR_RAPIDLY.pattern(), "").trim(); } @Override - public boolean canParse(final String pInput) { - return Regex.find(SNOW_INCR_RAPIDLY, pInput); + public boolean canParse(final String input) { + return Regex.find(SNOW_INCR_RAPIDLY, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/SnowPelletsCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/SnowPelletsCommand.java index e79946f1..e907eb92 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/SnowPelletsCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/SnowPelletsCommand.java @@ -23,14 +23,14 @@ public final class SnowPelletsCommand implements Command { } @Override - public String execute(final String pRemark, final StringBuilder pStringBuilder) { - String[] intensityParts = Regex.pregMatch(SNOW_PELLETS_INTENSITY, pRemark); - pStringBuilder.append(messages.getString("Remark.Snow.Pellets", messages.getString("Remark." + intensityParts[1]))).append(" "); - return pRemark.replaceFirst(SNOW_PELLETS_INTENSITY.pattern(), "").trim(); + public String execute(final String remark, final StringBuilder stringBuilder) { + String[] intensityParts = Regex.pregMatch(SNOW_PELLETS_INTENSITY, remark); + stringBuilder.append(messages.getString("Remark.Snow.Pellets", messages.getString("Remark." + intensityParts[1]))).append(" "); + return remark.replaceFirst(SNOW_PELLETS_INTENSITY.pattern(), "").trim(); } @Override - public boolean canParse(final String pInput) { - return Regex.find(SNOW_PELLETS_INTENSITY, pInput); + public boolean canParse(final String input) { + return Regex.find(SNOW_PELLETS_INTENSITY, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/SurfaceVisibilityCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/SurfaceVisibilityCommand.java index 862f6ff2..19875262 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/SurfaceVisibilityCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/SurfaceVisibilityCommand.java @@ -23,14 +23,14 @@ public final class SurfaceVisibilityCommand implements Command { } @Override - public String execute(final String pRemark, final StringBuilder pStringBuilder) { - String[] surfaceVisivilityParts = Regex.pregMatch(SURFACE_VISIBILITY, pRemark); - pStringBuilder.append(messages.getString("Remark.Surface.Visibility", surfaceVisivilityParts[1])).append(" "); - return pRemark.replaceFirst(SURFACE_VISIBILITY.pattern(), "").trim(); + public String execute(final String remark, final StringBuilder stringBuilder) { + String[] surfaceVisivilityParts = Regex.pregMatch(SURFACE_VISIBILITY, remark); + stringBuilder.append(messages.getString("Remark.Surface.Visibility", surfaceVisivilityParts[1])).append(" "); + return remark.replaceFirst(SURFACE_VISIBILITY.pattern(), "").trim(); } @Override - public boolean canParse(final String pInput) { - return Regex.find(SURFACE_VISIBILITY, pInput); + public boolean canParse(final String input) { + return Regex.find(SURFACE_VISIBILITY, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/ThunderStormLocationCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/ThunderStormLocationCommand.java index 60400300..21555115 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/ThunderStormLocationCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/ThunderStormLocationCommand.java @@ -24,14 +24,14 @@ public final class ThunderStormLocationCommand implements Command { } @Override - public String execute(final String pRemark, final StringBuilder pStringBuilder) { - String[] thunderStormParts = Regex.pregMatch(THUNDERSTORM_LOCATION, pRemark); - pStringBuilder.append(messages.getString("Remark.Thunderstorm.Location", messages.getString("Converter." + thunderStormParts[1]))).append(" "); - return pRemark.replaceFirst(THUNDERSTORM_LOCATION.pattern(), "").trim(); + public String execute(final String remark, final StringBuilder stringBuilder) { + String[] thunderStormParts = Regex.pregMatch(THUNDERSTORM_LOCATION, remark); + stringBuilder.append(messages.getString("Remark.Thunderstorm.Location", messages.getString("Converter." + thunderStormParts[1]))).append(" "); + return remark.replaceFirst(THUNDERSTORM_LOCATION.pattern(), "").trim(); } @Override - public boolean canParse(final String pInput) { - return Regex.find(THUNDERSTORM_LOCATION, pInput); + public boolean canParse(final String input) { + return Regex.find(THUNDERSTORM_LOCATION, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/ThunderStormLocationMovingCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/ThunderStormLocationMovingCommand.java index 2ed9160b..b037bf20 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/ThunderStormLocationMovingCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/ThunderStormLocationMovingCommand.java @@ -23,16 +23,16 @@ public final class ThunderStormLocationMovingCommand implements Command { } @Override - public String execute(final String pRemark, final StringBuilder pStringBuilder) { - String[] thunderStormParts = Regex.pregMatch(THUNDERSTORM_LOCATION_MOVING, pRemark); - pStringBuilder + public String execute(final String remark, final StringBuilder stringBuilder) { + String[] thunderStormParts = Regex.pregMatch(THUNDERSTORM_LOCATION_MOVING, remark); + stringBuilder .append(messages.getString("Remark.Thunderstorm.Location.Moving", messages.getString("Converter." + thunderStormParts[1]), messages.getString("Converter." + thunderStormParts[2]))) .append(" "); - return pRemark.replaceFirst(THUNDERSTORM_LOCATION_MOVING.pattern(), "").trim(); + return remark.replaceFirst(THUNDERSTORM_LOCATION_MOVING.pattern(), "").trim(); } @Override - public boolean canParse(final String pInput) { - return Regex.find(THUNDERSTORM_LOCATION_MOVING, pInput); + public boolean canParse(final String input) { + return Regex.find(THUNDERSTORM_LOCATION_MOVING, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/TornadicActivityBegCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/TornadicActivityBegCommand.java index ebd602ef..511d3f51 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/TornadicActivityBegCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/TornadicActivityBegCommand.java @@ -22,16 +22,16 @@ public final class TornadicActivityBegCommand implements Command { } @Override - public String execute(final String pRemark, final StringBuilder pStringBuilder) { - String[] tornadicParts = Regex.pregMatch(TORNADIC_ACTIVITY_BEGINNING, pRemark); - pStringBuilder.append(messages + public String execute(final String remark, final StringBuilder stringBuilder) { + String[] tornadicParts = Regex.pregMatch(TORNADIC_ACTIVITY_BEGINNING, remark); + stringBuilder.append(messages .getString("Remark.Tornadic.Activity.Beginning", messages.getString("Remark." + tornadicParts[1].replace(" ", "")), verifyString(tornadicParts[3]), tornadicParts[4], tornadicParts[6], messages.getString("Converter." + tornadicParts[7]))).append(" "); - return pRemark.replaceFirst(TORNADIC_ACTIVITY_BEGINNING.pattern(), "").trim(); + return remark.replaceFirst(TORNADIC_ACTIVITY_BEGINNING.pattern(), "").trim(); } @Override - public boolean canParse(final String pInput) { - return Regex.find(TORNADIC_ACTIVITY_BEGINNING, pInput); + public boolean canParse(final String input) { + return Regex.find(TORNADIC_ACTIVITY_BEGINNING, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/TornadicActivityBegEndCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/TornadicActivityBegEndCommand.java index 241bc42a..2c30dcb8 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/TornadicActivityBegEndCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/TornadicActivityBegEndCommand.java @@ -23,15 +23,15 @@ public final class TornadicActivityBegEndCommand implements Command { } @Override - public String execute(final String pRemark, final StringBuilder pStringBuilder) { - String[] tornadicParts = Regex.pregMatch(TORNADIC_ACTIVITY_BEG_END, pRemark); - pStringBuilder.append(messages.getString("Remark.Tornadic.Activity.BegEnd", messages.getString("Remark." + tornadicParts[1].replace(" ", "")), verifyString(tornadicParts[3]), tornadicParts[4], + public String execute(final String remark, final StringBuilder stringBuilder) { + String[] tornadicParts = Regex.pregMatch(TORNADIC_ACTIVITY_BEG_END, remark); + stringBuilder.append(messages.getString("Remark.Tornadic.Activity.BegEnd", messages.getString("Remark." + tornadicParts[1].replace(" ", "")), verifyString(tornadicParts[3]), tornadicParts[4], verifyString(tornadicParts[6]), tornadicParts[7], tornadicParts[9], messages.getString("Converter." + tornadicParts[10]))).append(" "); - return pRemark.replaceFirst(TORNADIC_ACTIVITY_BEG_END.pattern(), "").trim(); + return remark.replaceFirst(TORNADIC_ACTIVITY_BEG_END.pattern(), "").trim(); } @Override - public boolean canParse(final String pInput) { - return Regex.find(TORNADIC_ACTIVITY_BEG_END, pInput); + public boolean canParse(final String input) { + return Regex.find(TORNADIC_ACTIVITY_BEG_END, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/TornadicActivityEndCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/TornadicActivityEndCommand.java index 4a320a16..6b3a785c 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/TornadicActivityEndCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/TornadicActivityEndCommand.java @@ -23,16 +23,16 @@ public final class TornadicActivityEndCommand implements Command { } @Override - public String execute(final String pRemark, final StringBuilder pStringBuilder) { - String[] tornadicParts = Regex.pregMatch(TORNADIC_ACTIVITY_ENDING, pRemark); - pStringBuilder.append(messages + public String execute(final String remark, final StringBuilder stringBuilder) { + String[] tornadicParts = Regex.pregMatch(TORNADIC_ACTIVITY_ENDING, remark); + stringBuilder.append(messages .getString("Remark.Tornadic.Activity.Ending", messages.getString("Remark." + tornadicParts[1].replace(" ", "")), verifyString(tornadicParts[3]), tornadicParts[4], tornadicParts[6], messages.getString("Converter." + tornadicParts[7]))).append(" "); - return pRemark.replaceFirst(TORNADIC_ACTIVITY_ENDING.pattern(), "").trim(); + return remark.replaceFirst(TORNADIC_ACTIVITY_ENDING.pattern(), "").trim(); } @Override - public boolean canParse(final String pInput) { - return Regex.find(TORNADIC_ACTIVITY_ENDING, pInput); + public boolean canParse(final String input) { + return Regex.find(TORNADIC_ACTIVITY_ENDING, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/TowerVisibilityCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/TowerVisibilityCommand.java index 4274872d..27c570af 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/TowerVisibilityCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/TowerVisibilityCommand.java @@ -23,14 +23,14 @@ public final class TowerVisibilityCommand implements Command { } @Override - public String execute(final String pRemark, final StringBuilder pStringBuilder) { - String[] towerVisibilityParts = Regex.pregMatch(TOWER_VISIBILITY, pRemark); - pStringBuilder.append(messages.getString("Remark.Tower.Visibility", towerVisibilityParts[1])).append(" "); - return pRemark.replaceFirst(TOWER_VISIBILITY.pattern(), "").trim(); + public String execute(final String remark, final StringBuilder stringBuilder) { + String[] towerVisibilityParts = Regex.pregMatch(TOWER_VISIBILITY, remark); + stringBuilder.append(messages.getString("Remark.Tower.Visibility", towerVisibilityParts[1])).append(" "); + return remark.replaceFirst(TOWER_VISIBILITY.pattern(), "").trim(); } @Override - public boolean canParse(final String pInput) { - return Regex.find(TOWER_VISIBILITY, pInput); + public boolean canParse(final String input) { + return Regex.find(TOWER_VISIBILITY, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/VariableSkyCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/VariableSkyCommand.java index 5e23b27e..0e0cf331 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/VariableSkyCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/VariableSkyCommand.java @@ -23,17 +23,17 @@ public final class VariableSkyCommand implements Command { } @Override - public String execute(final String pRemark, final StringBuilder pStringBuilder) { - String[] variableSky = Regex.pregMatch(VARIABLE_SKY, pRemark); + public String execute(final String remark, final StringBuilder stringBuilder) { + String[] variableSky = Regex.pregMatch(VARIABLE_SKY, remark); String layer1 = messages.getString("CloudQuantity." + variableSky[1]); String layer2 = messages.getString("CloudQuantity." + variableSky[2]); - pStringBuilder.append(messages.getString("Remark.Variable.Sky.Condition", layer1, layer2)).append(" "); - return pRemark.replaceFirst(VARIABLE_SKY.pattern(), "").trim(); + stringBuilder.append(messages.getString("Remark.Variable.Sky.Condition", layer1, layer2)).append(" "); + return remark.replaceFirst(VARIABLE_SKY.pattern(), "").trim(); } @Override - public boolean canParse(final String pInput) { - return Regex.find(VARIABLE_SKY, pInput); + public boolean canParse(final String input) { + return Regex.find(VARIABLE_SKY, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/VariableSkyHeightCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/VariableSkyHeightCommand.java index ce9249bc..250c8294 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/VariableSkyHeightCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/VariableSkyHeightCommand.java @@ -23,17 +23,17 @@ public final class VariableSkyHeightCommand implements Command { } @Override - public String execute(final String pRemark, final StringBuilder pStringBuilder) { - String[] variableSky = Regex.pregMatch(VARIABLE_SKY_HEIGHT, pRemark); + public String execute(final String remark, final StringBuilder stringBuilder) { + String[] variableSky = Regex.pregMatch(VARIABLE_SKY_HEIGHT, remark); String layer1 = messages.getString("CloudQuantity." + variableSky[1]); int height = Integer.parseInt(variableSky[2]) * 100; String layer2 = messages.getString("CloudQuantity." + variableSky[3]); - pStringBuilder.append(messages.getString("Remark.Variable.Sky.Condition.Height", height, layer1, layer2)).append(" "); - return pRemark.replaceFirst(VARIABLE_SKY_HEIGHT.pattern(), "").trim(); + stringBuilder.append(messages.getString("Remark.Variable.Sky.Condition.Height", height, layer1, layer2)).append(" "); + return remark.replaceFirst(VARIABLE_SKY_HEIGHT.pattern(), "").trim(); } @Override - public boolean canParse(final String pInput) { - return Regex.find(VARIABLE_SKY_HEIGHT, pInput); + public boolean canParse(final String input) { + return Regex.find(VARIABLE_SKY_HEIGHT, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/VirgaDirectionCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/VirgaDirectionCommand.java index 136115be..f731ed36 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/VirgaDirectionCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/VirgaDirectionCommand.java @@ -23,14 +23,14 @@ public final class VirgaDirectionCommand implements Command { } @Override - public String execute(final String pRemark, final StringBuilder pStringBuilder) { - String[] virgaDirection = Regex.pregMatch(VIRGA_DIRECTION, pRemark); - pStringBuilder.append(messages.getString("Remark.Virga.Direction", messages.getString("Converter." + virgaDirection[1]))).append(" "); - return pRemark.replaceFirst(VIRGA_DIRECTION.pattern(), "").trim(); + public String execute(final String remark, final StringBuilder stringBuilder) { + String[] virgaDirection = Regex.pregMatch(VIRGA_DIRECTION, remark); + stringBuilder.append(messages.getString("Remark.Virga.Direction", messages.getString("Converter." + virgaDirection[1]))).append(" "); + return remark.replaceFirst(VIRGA_DIRECTION.pattern(), "").trim(); } @Override - public boolean canParse(final String pInput) { - return Regex.find(VIRGA_DIRECTION, pInput); + public boolean canParse(final String input) { + return Regex.find(VIRGA_DIRECTION, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/WindPeakCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/WindPeakCommand.java index 304e518d..8cf848bc 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/WindPeakCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/WindPeakCommand.java @@ -24,15 +24,15 @@ public final class WindPeakCommand implements Command { } @Override - public String execute(final String pRemark, final StringBuilder pStringBuilder) { - String[] windPeakParts = Regex.pregMatch(WIND_PEAK, pRemark); - pStringBuilder.append(messages.getString("Remark.PeakWind", windPeakParts[1], windPeakParts[2], verifyString(windPeakParts[3]), windPeakParts[4])); - pStringBuilder.append(" "); - return pRemark.replaceFirst(WIND_PEAK.pattern(), "").trim(); + public String execute(final String remark, final StringBuilder stringBuilder) { + String[] windPeakParts = Regex.pregMatch(WIND_PEAK, remark); + stringBuilder.append(messages.getString("Remark.PeakWind", windPeakParts[1], windPeakParts[2], verifyString(windPeakParts[3]), windPeakParts[4])); + stringBuilder.append(" "); + return remark.replaceFirst(WIND_PEAK.pattern(), "").trim(); } @Override - public boolean canParse(final String pInput) { - return Regex.find(WIND_PEAK, pInput); + public boolean canParse(final String input) { + return Regex.find(WIND_PEAK, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/WindShiftCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/WindShiftCommand.java index 22ab6485..f1148c3a 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/WindShiftCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/WindShiftCommand.java @@ -24,15 +24,15 @@ public final class WindShiftCommand implements Command { } @Override - public String execute(final String pRemark, final StringBuilder pStringBuilder) { - String[] windShiftParts = Regex.pregMatch(WIND_SHIFT, pRemark); - pStringBuilder.append(messages.getString("Remark.WindShift", verifyString(windShiftParts[1]), windShiftParts[2])); - pStringBuilder.append(" "); - return pRemark.replaceFirst(WIND_SHIFT.pattern(), "").trim(); + public String execute(final String remark, final StringBuilder stringBuilder) { + String[] windShiftParts = Regex.pregMatch(WIND_SHIFT, remark); + stringBuilder.append(messages.getString("Remark.WindShift", verifyString(windShiftParts[1]), windShiftParts[2])); + stringBuilder.append(" "); + return remark.replaceFirst(WIND_SHIFT.pattern(), "").trim(); } @Override - public boolean canParse(final String pInput) { - return Regex.find(WIND_SHIFT, pInput); + public boolean canParse(final String input) { + return Regex.find(WIND_SHIFT, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/WindShiftFropaCommand.java b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/WindShiftFropaCommand.java index eef08269..03b26309 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/command/remark/WindShiftFropaCommand.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/command/remark/WindShiftFropaCommand.java @@ -23,15 +23,15 @@ public final class WindShiftFropaCommand implements Command { } @Override - public String execute(final String pRemark, final StringBuilder pStringBuilder) { - String[] windShiftParts = Regex.pregMatch(WIND_SHIFT_FROPA, pRemark); - pStringBuilder.append(messages.getString("Remark.WindShift.FROPA", verifyString(windShiftParts[1]), windShiftParts[2])); - pStringBuilder.append(" "); - return pRemark.replaceFirst(WIND_SHIFT_FROPA.pattern(), ""); + public String execute(final String remark, final StringBuilder stringBuilder) { + String[] windShiftParts = Regex.pregMatch(WIND_SHIFT_FROPA, remark); + stringBuilder.append(messages.getString("Remark.WindShift.FROPA", verifyString(windShiftParts[1]), windShiftParts[2])); + stringBuilder.append(" "); + return remark.replaceFirst(WIND_SHIFT_FROPA.pattern(), ""); } @Override - public boolean canParse(final String pInput) { - return Regex.find(WIND_SHIFT_FROPA, pInput); + public boolean canParse(final String input) { + return Regex.find(WIND_SHIFT_FROPA, input); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/exception/ErrorCodes.java b/metarParser-parsers/src/main/java/io/github/mivek/exception/ErrorCodes.java index e8ec7319..6e1211ec 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/exception/ErrorCodes.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/exception/ErrorCodes.java @@ -4,7 +4,6 @@ /** * @author mivek - * */ public enum ErrorCodes { /** Error for an invalid ICAO. */ @@ -14,32 +13,33 @@ public enum ErrorCodes { /** Error code for when the airport is not found. */ ERROR_CODE_AIRPORT_NOT_FOUND(3, Messages.getInstance().getString("ErrorCode.AirportNotFound")); /** The code of the error. */ - private final int fCode; + private final int code; /** The message of the error. */ - private final String fMessage; + private final String message; /** * constructor. - * @param pCode the code of the error. - * @param pMessage the message to set. + * + * @param code the code of the error. + * @param message the message to set. */ - ErrorCodes(final int pCode, final String pMessage) { - fCode = pCode; - fMessage = pMessage; + ErrorCodes(final int code, final String message) { + this.code = code; + this.message = message; } /** * @return the code */ public int getCode() { - return fCode; + return code; } /** * @return the message */ public String getMessage() { - return fMessage; + return message; } @Override diff --git a/metarParser-parsers/src/main/java/io/github/mivek/exception/ParseException.java b/metarParser-parsers/src/main/java/io/github/mivek/exception/ParseException.java index d066cdf1..9809be51 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/exception/ParseException.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/exception/ParseException.java @@ -2,31 +2,27 @@ /** * @author mivek - * */ public class ParseException extends Exception { - /** - * serialVersionUID. - */ + /** serialVersionUID. */ private static final long serialVersionUID = -9022781702124062628L; - /** - * The error code. - */ - private final ErrorCodes fCode; + /** The error code. */ + private final ErrorCodes codes; /** * Constructor with error code. - * @param pCode the error code. + * + * @param code the error code. */ - public ParseException(final ErrorCodes pCode) { - super(pCode.toString()); - fCode = pCode; + public ParseException(final ErrorCodes code) { + super(code.toString()); + this.codes = code; } /** * @return the error code. */ public ErrorCodes getErrorCode() { - return fCode; + return codes; } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/parser/AbstractParser.java b/metarParser-parsers/src/main/java/io/github/mivek/parser/AbstractParser.java index 49a8f2e0..adb5f389 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/parser/AbstractParser.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/parser/AbstractParser.java @@ -49,14 +49,15 @@ public abstract class AbstractParser { /** * Dependency injection constructor. - * @param pCommonCommandSupplier the common command supplier - * @param pRemarkParser the remark parser. - * @param pAirportSupplier the airport supplier. + * + * @param commonCommandSupplier the common command supplier + * @param remarkParser the remark parser. + * @param airportSupplier the airport supplier. */ - AbstractParser(final CommonCommandSupplier pCommonCommandSupplier, final RemarkParser pRemarkParser, final AirportSupplier pAirportSupplier) { - commonSupplier = pCommonCommandSupplier; - remarkParser = pRemarkParser; - airportSupplier = pAirportSupplier; + AbstractParser(final CommonCommandSupplier commonCommandSupplier, final RemarkParser remarkParser, final AirportSupplier airportSupplier) { + commonSupplier = commonCommandSupplier; + this.remarkParser = remarkParser; + this.airportSupplier = airportSupplier; } /** @@ -94,72 +95,72 @@ WeatherCondition parseWeatherCondition(final String weatherPart) { /** * Parses the string containing the delivery time. * - * @param pWeatherCode The weather code. - * @param pTime the string to parse. + * @param weatherCode The weather code. + * @param time the string to parse. */ - void parseDeliveryTime(final AbstractWeatherCode pWeatherCode, final String pTime) { - pWeatherCode.setDay(Integer.parseInt(pTime.substring(0, 2))); - int hours = Integer.parseInt(pTime.substring(2, 4)); - int minutes = Integer.parseInt(pTime.substring(4, 6)); + void parseDeliveryTime(final AbstractWeatherCode weatherCode, final String time) { + weatherCode.setDay(Integer.parseInt(time.substring(0, 2))); + int hours = Integer.parseInt(time.substring(2, 4)); + int minutes = Integer.parseInt(time.substring(4, 6)); LocalTime t = LocalTime.of(hours, minutes); - pWeatherCode.setTime(t); + weatherCode.setTime(t); } /** * Abstract method parse. * - * @param pCode the message to parse. + * @param code the message to parse. * @return The decoded object. * @throws ParseException when an error occurs during parsing. */ - public abstract T parse(String pCode) throws ParseException; + public abstract T parse(String code) throws ParseException; /** * Method that parses common elements of a abstract weather container. * - * @param pContainer The object to update - * @param pPart the token to parse. - * @return boolean if the token pPart as been parsed. + * @param container The object to update + * @param part the token to parse. + * @return boolean if the token part as been parsed. */ - boolean generalParse(final AbstractWeatherContainer pContainer, final String pPart) { - if (CAVOK.equals(pPart)) { - pContainer.setCavok(true); - if (pContainer.getVisibility() == null) { - pContainer.setVisibility(new Visibility()); + boolean generalParse(final AbstractWeatherContainer container, final String part) { + if (CAVOK.equals(part)) { + container.setCavok(true); + if (container.getVisibility() == null) { + container.setVisibility(new Visibility()); } - pContainer.getVisibility().setMainVisibility(">10km"); + container.getVisibility().setMainVisibility(">10km"); return true; } - Command command = commonSupplier.get(pPart); - if (command != null && command.canParse(pPart)) { - return command.execute(pContainer, pPart); + Command command = commonSupplier.get(part); + if (command != null && command.canParse(part)) { + return command.execute(container, part); } - WeatherCondition wc = parseWeatherCondition(pPart); - return pContainer.addWeatherCondition(wc); + WeatherCondition wc = parseWeatherCondition(part); + return container.addWeatherCondition(wc); } /*** * Adds the remark part to the event. - * @param pContainer the event to update - * @param pParts the tokens of the event + * @param container the event to update + * @param parts the tokens of the event * @param index the RMK index in the event. */ - void parseRMK(final AbstractWeatherContainer pContainer, final String[] pParts, final int index) { - String[] subArray = Arrays.copyOfRange(pParts, index + 1, pParts.length); - pContainer.setRemark(remarkParser.parse(String.join(" ", subArray))); + void parseRMK(final AbstractWeatherContainer container, final String[] parts, final int index) { + String[] subArray = Arrays.copyOfRange(parts, index + 1, parts.length); + container.setRemark(remarkParser.parse(String.join(" ", subArray))); } /** * Splits a string between spaces except if the space is between two digits with * SM. * - * @param pCode the string to parse + * @param code the string to parse * @return a array of tokens */ - String[] tokenize(final String pCode) { - return TOKENIZE_REGEX.split(pCode); + String[] tokenize(final String code) { + return TOKENIZE_REGEX.split(code); } /** diff --git a/metarParser-parsers/src/main/java/io/github/mivek/parser/MetarParser.java b/metarParser-parsers/src/main/java/io/github/mivek/parser/MetarParser.java index 5b4acea3..5f235bb8 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/parser/MetarParser.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/parser/MetarParser.java @@ -40,15 +40,15 @@ private MetarParser() { /** * Dependency injection constructor. * - * @param pCommonCommandSupplier the command command supplier - * @param pRemarkParser the remark parser - * @param pMetarParserCommandSupplier the metar command supplier. - * @param pAirportSupplier the airport supplier + * @param commonCommandSupplier the command command supplier + * @param remarkParser the remark parser + * @param metarParserCommandSupplier the metar command supplier. + * @param airportSupplier the airport supplier */ - protected MetarParser(final CommonCommandSupplier pCommonCommandSupplier, final RemarkParser pRemarkParser, final AirportSupplier pAirportSupplier, - final MetarParserCommandSupplier pMetarParserCommandSupplier) { - super(pCommonCommandSupplier, pRemarkParser, pAirportSupplier); - supplier = pMetarParserCommandSupplier; + protected MetarParser(final CommonCommandSupplier commonCommandSupplier, final RemarkParser remarkParser, final AirportSupplier airportSupplier, + final MetarParserCommandSupplier metarParserCommandSupplier) { + super(commonCommandSupplier, remarkParser, airportSupplier); + supplier = metarParserCommandSupplier; } /** @@ -64,16 +64,17 @@ public static MetarParser getInstance() { * This is the main method of the parser. This method checks if the airport * exists. If it does then the metar code is decoded. * - * @param pMetarCode String representing the metar. + * @param code String representing the metar. * @return a decoded metar object. */ - @Override public Metar parse(final String pMetarCode) { + @Override + public Metar parse(final String code) { Metar m = new Metar(); - String[] metarTab = tokenize(pMetarCode); + String[] metarTab = tokenize(code); Airport airport = getAirportSupplier().get(metarTab[0]); m.setStation(metarTab[0]); m.setAirport(airport); - m.setMessage(pMetarCode); + m.setMessage(code); parseDeliveryTime(m, metarTab[1]); int metarTabLength = metarTab.length; int i = 2; @@ -103,12 +104,12 @@ public static MetarParser getInstance() { /** * Initiate the trend according to string. * - * @param pS the string to parse. + * @param trendpart the string to parse. * @return a concrete Trends object. */ - private AbstractMetarTrend initTrend(final String pS) { + private AbstractMetarTrend initTrend(final String trendpart) { AbstractMetarTrend trend; - if (pS.equals(TEMPO)) { + if (trendpart.equals(TEMPO)) { trend = new TEMPOMetarTrend(); } else { trend = new BECMGMetarTrend(); @@ -119,28 +120,28 @@ private AbstractMetarTrend initTrend(final String pS) { /** * Execute the command given by the supplier. * - * @param pM the metar - * @param pInput the string to parse. + * @param metar the metar + * @param input the string to parse. */ - private void executeCommand(final Metar pM, final String pInput) { - Command command = supplier.get(pInput); + private void executeCommand(final Metar metar, final String input) { + Command command = supplier.get(input); if (command != null) { - command.execute(pM, pInput); + command.execute(metar, input); } } /** * Iterates over an array and parses the trends. * - * @param pIndex the starting index. - * @param pTrend the trend to update - * @param pParts an array of strings + * @param index the starting index. + * @param trend the trend to update + * @param parts an array of strings * @return the next index to parse. */ - private int iterTrend(final int pIndex, final AbstractMetarTrend pTrend, final String[] pParts) { - int i = pIndex + 1; - while (i < pParts.length && !pParts[i].equals(TEMPO) && !pParts[i].equals(BECMG)) { - processChange(pTrend, pParts[i]); + private int iterTrend(final int index, final AbstractMetarTrend trend, final String[] parts) { + int i = index + 1; + while (i < parts.length && !parts[i].equals(TEMPO) && !parts[i].equals(BECMG)) { + processChange(trend, parts[i]); i++; } return i - 1; @@ -149,24 +150,24 @@ private int iterTrend(final int pIndex, final AbstractMetarTrend pTrend, final S /** * Parses a string and updates the trend. * - * @param pTrend the abstractMetarTrend object to update. - * @param pPart The token to parse. + * @param trend the abstractMetarTrend object to update. + * @param part The token to parse. */ - private void processChange(final AbstractMetarTrend pTrend, final String pPart) { - if (pPart.startsWith(AT)) { + private void processChange(final AbstractMetarTrend trend, final String part) { + if (part.startsWith(AT)) { ATTime at = new ATTime(); - at.setTime(Converter.stringToTime(pPart.substring(2))); - pTrend.addTime(at); - } else if (pPart.startsWith(FM)) { + at.setTime(Converter.stringToTime(part.substring(2))); + trend.addTime(at); + } else if (part.startsWith(FM)) { FMTime fm = new FMTime(); - fm.setTime(Converter.stringToTime(pPart.substring(2))); - pTrend.addTime(fm); - } else if (pPart.startsWith(TILL)) { + fm.setTime(Converter.stringToTime(part.substring(2))); + trend.addTime(fm); + } else if (part.startsWith(TILL)) { TLTime tl = new TLTime(); - tl.setTime(Converter.stringToTime(pPart.substring(2))); - pTrend.addTime(tl); + tl.setTime(Converter.stringToTime(part.substring(2))); + trend.addTime(tl); } else { - generalParse(pTrend, pPart); + generalParse(trend, part); } } diff --git a/metarParser-parsers/src/main/java/io/github/mivek/parser/RemarkParser.java b/metarParser-parsers/src/main/java/io/github/mivek/parser/RemarkParser.java index b48fcc4f..8830d170 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/parser/RemarkParser.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/parser/RemarkParser.java @@ -14,6 +14,7 @@ public final class RemarkParser { /** The command supplier. */ private final RemarkCommandSupplier supplier; + /*** * Private constructor. */ @@ -22,11 +23,11 @@ private RemarkParser() { } /** - * @param pRemark the remark to parse. + * @param remark the remark to parse. * @return the remark string */ - public String parse(final String pRemark) { - String rmk = pRemark; + public String parse(final String remark) { + String rmk = remark; StringBuilder sb = new StringBuilder(); while (!"".equals(rmk)) { try { diff --git a/metarParser-parsers/src/main/java/io/github/mivek/parser/TAFParser.java b/metarParser-parsers/src/main/java/io/github/mivek/parser/TAFParser.java index 0d30c5da..c0ff3455 100644 --- a/metarParser-parsers/src/main/java/io/github/mivek/parser/TAFParser.java +++ b/metarParser-parsers/src/main/java/io/github/mivek/parser/TAFParser.java @@ -50,13 +50,14 @@ private TAFParser() { /** * Dependency injection constructor. * - * @param pCommonCommandSupplier the common command supplier - * @param pRemarkParser the remark parser. - * @param pAirportSupplier the airport supplier. + * @param commonCommandSupplier the common command supplier + * @param remarkParser the remark parser. + * @param airportSupplier the airport supplier. */ - protected TAFParser(final CommonCommandSupplier pCommonCommandSupplier, final RemarkParser pRemarkParser, final AirportSupplier pAirportSupplier) { - super(pCommonCommandSupplier, pRemarkParser, pAirportSupplier); + protected TAFParser(final CommonCommandSupplier commonCommandSupplier, final RemarkParser remarkParser, final AirportSupplier airportSupplier) { + super(commonCommandSupplier, remarkParser, airportSupplier); } + /** * @return the instance. */ @@ -65,8 +66,8 @@ public static TAFParser getInstance() { } @Override - public TAF parse(final String pTAFCode) throws ParseException { - String[][] lines = extractLineTokens(pTAFCode); + public TAF parse(final String code) throws ParseException { + String[][] lines = extractLineTokens(code); if (!TAF.equals(lines[0][0])) { throw new ParseException(ErrorCodes.ERROR_CODE_INVALID_MESSAGE); } @@ -88,7 +89,7 @@ public TAF parse(final String pTAFCode) throws ParseException { taf.setStation(line1parts[i]); i++; taf.setAirport(airport); - taf.setMessage(pTAFCode); + taf.setMessage(code); // Day and time parseDeliveryTime(taf, line1parts[i]); // Validity Time @@ -119,17 +120,15 @@ public TAF parse(final String pTAFCode) throws ParseException { /** * Extracts all lines and tokenize them. - * @param pTAFCode raw TAF which may already contains some linebreaks + * + * @param tafCode raw TAF which may already contains some linebreaks * @return 2d jagged array containing lines and their tokens */ - private String[][] extractLineTokens(final String pTAFCode) { - String cleanedInput = pTAFCode - .replace("\n", " ") // remove all linebreaks + private String[][] extractLineTokens(final String tafCode) { + String cleanedInput = tafCode.replace("\n", " ") // remove all linebreaks .replaceAll("\\s{2,}", " "); // remove unnecessary whitespaces - String[] lines = cleanedInput - .replaceAll("\\s(PROB\\d{2}\\sTEMPO|TEMPO|BECMG|FM|PROB)", "\n$1") - .split("\n"); + String[] lines = cleanedInput.replaceAll("\\s(PROB\\d{2}\\sTEMPO|TEMPO|BECMG|FM|PROB)", "\n$1").split("\n"); String[][] lineTokens = Arrays.stream(lines).map(this::tokenize).toArray(String[][]::new); if (lineTokens.length > 1) { // often temperatures are set in the end of the TAF report @@ -146,37 +145,37 @@ private String[][] extractLineTokens(final String pTAFCode) { /** * Handles the parsing of a line. * - * @param pTaf the TAF object to build - * @param pParts the token of the line + * @param taf the TAF object to build + * @param parts the token of the line */ - private void processLines(final TAF pTaf, final String[] pParts) { - if (pParts[0].equals(BECMG)) { + private void processLines(final TAF taf, final String[] parts) { + if (parts[0].equals(BECMG)) { BECMGTafTrend change = new BECMGTafTrend(); - iterChanges(1, pParts, change); - pTaf.addBECMG(change); - } else if (pParts[0].equals(TEMPO)) { + iterChanges(1, parts, change); + taf.addBECMG(change); + } else if (parts[0].equals(TEMPO)) { TEMPOTafTrend change = new TEMPOTafTrend(); - iterChanges(1, pParts, change); - pTaf.addTempo(change); - } else if (pParts[0].startsWith(FM)) { + iterChanges(1, parts, change); + taf.addTempo(change); + } else if (parts[0].startsWith(FM)) { FMTafTrend change = new FMTafTrend(); - change.setValidity(parseBasicValidity(pParts[0])); - for (int k = 1; k < pParts.length; k++) { - processGeneralChanges(change, pParts[k]); + change.setValidity(parseBasicValidity(parts[0])); + for (int k = 1; k < parts.length; k++) { + processGeneralChanges(change, parts[k]); } - pTaf.addFM(change); - } else if (pParts[0].startsWith(PROB)) { - int probability = parseProbability(pParts[0]); - if (pParts.length > 1 && pParts[1].equals(TEMPO)) { + taf.addFM(change); + } else if (parts[0].startsWith(PROB)) { + int probability = parseProbability(parts[0]); + if (parts.length > 1 && parts[1].equals(TEMPO)) { TEMPOTafTrend change = new TEMPOTafTrend(); - iterChanges(2, pParts, change); + iterChanges(2, parts, change); change.setProbability(probability); - pTaf.addTempo(change); + taf.addTempo(change); } else { PROBTafTrend change = new PROBTafTrend(); change.setProbability(probability); - iterChanges(1, pParts, change); - pTaf.addProb(change); + iterChanges(1, parts, change); + taf.addProb(change); } } } @@ -185,45 +184,46 @@ private void processLines(final TAF pTaf, final String[] pParts) { * Updates the change object according to the string. * * @param change the change object to update. - * @param pPart the string to parse. + * @param part the string to parse. */ - private void processChanges(final AbstractTafTrend change, final String pPart) { - if (Regex.match(REGEX_VALIDITY, pPart)) { - change.setValidity(parseValidity(pPart)); + private void processChanges(final AbstractTafTrend change, final String part) { + if (Regex.match(REGEX_VALIDITY, part)) { + change.setValidity(parseValidity(part)); } else { - processGeneralChanges(change, pPart); + processGeneralChanges(change, part); } } /** * Updates the change object according to the string. * - * @param pChange the change object to update. - * @param pPart String containing the information. + * @param change the change object to update. + * @param part String containing the information. */ - protected void processGeneralChanges(final AbstractTafTrend pChange, final String pPart) { - generalParse(pChange, pPart); + protected void processGeneralChanges(final AbstractTafTrend change, final String part) { + generalParse(change, part); } /** * parses the probability out of PROB?? * - * @param pPart the string to parse. + * @param part the string to parse. * @return probability of the trend. */ - protected int parseProbability(final String pPart) { - return Integer.parseInt(pPart.substring(4)); + protected int parseProbability(final String part) { + return Integer.parseInt(part.substring(4)); } /** * Parse the validity part of a {@link TAFParser} or an * {@link AbstractTafTrend}. - * @param pValidity the string representing the validity. + * + * @param validityString the string representing the validity. * @return a {@link Validity} object. */ - protected Validity parseValidity(final String pValidity) { + protected Validity parseValidity(final String validityString) { Validity validity = new Validity(); - String[] validityPart = pValidity.split("/"); + String[] validityPart = validityString.split("/"); validity.setStartDay(Integer.parseInt(validityPart[0].substring(0, 2))); validity.setStartHour(Integer.parseInt(validityPart[0].substring(2))); validity.setEndDay(Integer.parseInt(validityPart[1].substring(0, 2))); @@ -233,41 +233,44 @@ protected Validity parseValidity(final String pValidity) { /** * Parses the validity of a {@link FMTafTrend} object. - * @param pValidity the string to parse + * + * @param validityString the string to parse * @return a {@link BeginningValidity} object. */ - protected BeginningValidity parseBasicValidity(final String pValidity) { + protected BeginningValidity parseBasicValidity(final String validityString) { BeginningValidity validity = new BeginningValidity(); - validity.setStartDay(Integer.parseInt(pValidity.substring(2, 4))); - validity.setStartHour(Integer.parseInt(pValidity.substring(4, 6))); - validity.setStartMinutes(Integer.parseInt(pValidity.substring(6, 8))); + validity.setStartDay(Integer.parseInt(validityString.substring(2, 4))); + validity.setStartHour(Integer.parseInt(validityString.substring(4, 6))); + validity.setStartMinutes(Integer.parseInt(validityString.substring(6, 8))); return validity; } /** * Iterates over the string array and build the abstractWeather change. - * @param pIndex the starting index of the array. - * @param pParts the array of string. - * @param pChange the abstractWeatherChange to update. + * + * @param index the starting index of the array. + * @param parts the array of string. + * @param change the abstractWeatherChange to update. */ - private void iterChanges(final int pIndex, final String[] pParts, final AbstractTafTrend pChange) { - for (int i = pIndex; i < pParts.length; i++) { - if (RMK.equals(pParts[i])) { - parseRMK(pChange, pParts, i); + private void iterChanges(final int index, final String[] parts, final AbstractTafTrend change) { + for (int i = index; i < parts.length; i++) { + if (RMK.equals(parts[i])) { + parseRMK(change, parts, i); } else { - processChanges(pChange, pParts[i]); + processChanges(change, parts[i]); } } } /** * Parse the temperature. - * @param pTempPart the string to parse. + * + * @param tempPart the string to parse. * @return a temperature with its date. */ - protected TemperatureDated parseTemperature(final String pTempPart) { + protected TemperatureDated parseTemperature(final String tempPart) { TemperatureDated temperature = new TemperatureDated(); - String[] parts = pTempPart.split("/"); + String[] parts = tempPart.split("/"); temperature.setTemperature(Converter.convertTemperature(parts[0].substring(2))); temperature.setDay(Integer.parseInt(parts[1].substring(0, 2))); temperature.setHour(Integer.parseInt(parts[1].substring(2, 4))); diff --git a/metarParser-parsers/src/test/java/io/github/mivek/command/AirportSupplierTest.java b/metarParser-parsers/src/test/java/io/github/mivek/command/AirportSupplierTest.java index a5a1a8a5..107bdec3 100644 --- a/metarParser-parsers/src/test/java/io/github/mivek/command/AirportSupplierTest.java +++ b/metarParser-parsers/src/test/java/io/github/mivek/command/AirportSupplierTest.java @@ -14,16 +14,19 @@ public class AirportSupplierTest { private AirportSupplier sut; - @Before public void setUp() { + @Before + public void setUp() { sut = new AirportSupplier(); } - @Test public void testGetWithExistingIcao() { + @Test + public void testGetWithExistingIcao() { Airport res = sut.get("LFPG"); assertNotNull(res); } - @Test public void testWithNonExistingIcao() { + @Test + public void testWithNonExistingIcao() { Airport res = sut.get("AA"); assertNull(res); } diff --git a/metarParser-parsers/src/test/java/io/github/mivek/command/common/CloudCommandTest.java b/metarParser-parsers/src/test/java/io/github/mivek/command/common/CloudCommandTest.java index 416996de..75586ea9 100644 --- a/metarParser-parsers/src/test/java/io/github/mivek/command/common/CloudCommandTest.java +++ b/metarParser-parsers/src/test/java/io/github/mivek/command/common/CloudCommandTest.java @@ -15,11 +15,13 @@ public class CloudCommandTest { private CloudCommand sut; - @Before public void setUp() { + @Before + public void setUp() { sut = new CloudCommand(); } - @Test public void testParseCloudNullCloudQuantity() { + @Test + public void testParseCloudNullCloudQuantity() { String cloud = "AZE015"; Cloud res = sut.parseCloud(cloud); @@ -27,7 +29,8 @@ public class CloudCommandTest { assertNull(res); } - @Test public void testParseCloudSkyClear() { + @Test + public void testParseCloudSkyClear() { String cloud = "SKC"; Cloud res = sut.parseCloud(cloud); @@ -38,7 +41,8 @@ public class CloudCommandTest { assertNull(res.getType()); } - @Test public void testParseCloudWithAltitude() { + @Test + public void testParseCloudWithAltitude() { String cloud = "SCT016"; Cloud res = sut.parseCloud(cloud); @@ -48,7 +52,8 @@ public class CloudCommandTest { assertNull(res.getType()); } - @Test public void testParseCloudWithType() { + @Test + public void testParseCloudWithType() { String cloud = "SCT026CB"; Cloud res = sut.parseCloud(cloud); @@ -60,7 +65,8 @@ public class CloudCommandTest { assertEquals(CloudType.CB, res.getType()); } - @Test public void testParseCloudWithNSC() { + @Test + public void testParseCloudWithNSC() { String cloud = "NSC"; Cloud res = sut.parseCloud(cloud); assertNotNull(res); diff --git a/metarParser-parsers/src/test/java/io/github/mivek/command/common/CommonCommandArchitectureTest.java b/metarParser-parsers/src/test/java/io/github/mivek/command/common/CommonCommandArchitectureTest.java index 8445ffcb..c8b963fe 100644 --- a/metarParser-parsers/src/test/java/io/github/mivek/command/common/CommonCommandArchitectureTest.java +++ b/metarParser-parsers/src/test/java/io/github/mivek/command/common/CommonCommandArchitectureTest.java @@ -15,7 +15,7 @@ * @author mivek */ @RunWith(ArchUnitRunner.class) -@AnalyzeClasses(packages = {"io.github.mivek.command.common"}, importOptions = { ImportOption.DoNotIncludeTests.class }) +@AnalyzeClasses(packages = { "io.github.mivek.command.common" }, importOptions = { ImportOption.DoNotIncludeTests.class }) public class CommonCommandArchitectureTest { @ArchTest diff --git a/metarParser-parsers/src/test/java/io/github/mivek/command/common/CommonCommandSupplierTest.java b/metarParser-parsers/src/test/java/io/github/mivek/command/common/CommonCommandSupplierTest.java index 1b891169..57a1551f 100644 --- a/metarParser-parsers/src/test/java/io/github/mivek/command/common/CommonCommandSupplierTest.java +++ b/metarParser-parsers/src/test/java/io/github/mivek/command/common/CommonCommandSupplierTest.java @@ -13,7 +13,8 @@ */ public class CommonCommandSupplierTest { - @Test public void testBuildCommands() { + @Test + public void testBuildCommands() { List commands = new CommonCommandSupplier().buildCommands(); assertNotNull(commands); diff --git a/metarParser-parsers/src/test/java/io/github/mivek/command/common/WindCommandTest.java b/metarParser-parsers/src/test/java/io/github/mivek/command/common/WindCommandTest.java index 0e04acf4..50cd14a1 100644 --- a/metarParser-parsers/src/test/java/io/github/mivek/command/common/WindCommandTest.java +++ b/metarParser-parsers/src/test/java/io/github/mivek/command/common/WindCommandTest.java @@ -16,11 +16,13 @@ public class WindCommandTest { private WindCommand sut; - @Before public void setUp() { + @Before + public void setUp() { sut = new WindCommand(); } - @Test public void testParseWindSimple() { + @Test + public void testParseWindSimple() { String windPart = "34008KT"; Wind res = sut.parseWind(windPart); @@ -34,7 +36,8 @@ public class WindCommandTest { } - @Test public void testParseWindWithGusts() { + @Test + public void testParseWindWithGusts() { String windPart = "12017G20KT"; Wind res = sut.parseWind(windPart); @@ -47,7 +50,8 @@ public class WindCommandTest { assertEquals("KT", res.getUnit()); } - @Test public void testParseWindVariable() { + @Test + public void testParseWindVariable() { String windPart = "VRB08KT"; Wind res = sut.parseWind(windPart); diff --git a/metarParser-parsers/src/test/java/io/github/mivek/command/metar/MetarCommandArchitectureTest.java b/metarParser-parsers/src/test/java/io/github/mivek/command/metar/MetarCommandArchitectureTest.java index 1c9a3fb3..23f24c01 100644 --- a/metarParser-parsers/src/test/java/io/github/mivek/command/metar/MetarCommandArchitectureTest.java +++ b/metarParser-parsers/src/test/java/io/github/mivek/command/metar/MetarCommandArchitectureTest.java @@ -14,7 +14,7 @@ * @author mivek */ @RunWith(ArchUnitRunner.class) -@AnalyzeClasses(packages = {"io.github.mivek.command.metar"}, importOptions = { ImportOption.DoNotIncludeTests.class }) +@AnalyzeClasses(packages = { "io.github.mivek.command.metar" }, importOptions = { ImportOption.DoNotIncludeTests.class }) public class MetarCommandArchitectureTest { @ArchTest diff --git a/metarParser-parsers/src/test/java/io/github/mivek/command/metar/MetarParserCommandSupplierTest.java b/metarParser-parsers/src/test/java/io/github/mivek/command/metar/MetarParserCommandSupplierTest.java index df444e2c..dafcd5c7 100644 --- a/metarParser-parsers/src/test/java/io/github/mivek/command/metar/MetarParserCommandSupplierTest.java +++ b/metarParser-parsers/src/test/java/io/github/mivek/command/metar/MetarParserCommandSupplierTest.java @@ -13,7 +13,8 @@ */ public class MetarParserCommandSupplierTest { - @Test public void testBuildCommandList() { + @Test + public void testBuildCommandList() { List commands = new MetarParserCommandSupplier().buildCommandList(); assertNotNull(commands); diff --git a/metarParser-parsers/src/test/java/io/github/mivek/command/metar/RunwayCommandTest.java b/metarParser-parsers/src/test/java/io/github/mivek/command/metar/RunwayCommandTest.java index de8bbeae..2b05c5e0 100644 --- a/metarParser-parsers/src/test/java/io/github/mivek/command/metar/RunwayCommandTest.java +++ b/metarParser-parsers/src/test/java/io/github/mivek/command/metar/RunwayCommandTest.java @@ -17,11 +17,13 @@ public class RunwayCommandTest { private RunwayCommand command; - @Before public void setUp() { + @Before + public void setUp() { command = new RunwayCommand(); } - @Test public void testExecuteSimple() { + @Test + public void testExecuteSimple() { String riString = "R26/0600U"; Metar m = new Metar(); command.execute(m, riString); @@ -34,7 +36,8 @@ public class RunwayCommandTest { assertEquals(Messages.getInstance().getString("Converter.U"), ri.getTrend()); } - @Test public void testParseRunWaysComplex() { + @Test + public void testParseRunWaysComplex() { String riString = "R26L/0550V700U"; Metar m = new Metar(); @@ -48,7 +51,8 @@ public class RunwayCommandTest { assertEquals(Messages.getInstance().getString("Converter.U"), ri.getTrend()); } - @Test public void testParseRunWayNull() { + @Test + public void testParseRunWayNull() { String riString = "R26R/AZEZFDFS"; Metar m = new Metar(); diff --git a/metarParser-parsers/src/test/java/io/github/mivek/command/remark/DefaultCommandTest.java b/metarParser-parsers/src/test/java/io/github/mivek/command/remark/DefaultCommandTest.java index 566f4a48..94c323b6 100644 --- a/metarParser-parsers/src/test/java/io/github/mivek/command/remark/DefaultCommandTest.java +++ b/metarParser-parsers/src/test/java/io/github/mivek/command/remark/DefaultCommandTest.java @@ -9,7 +9,8 @@ */ public class DefaultCommandTest { - @Test public void canParse() { + @Test + public void canParse() { assertTrue(new DefaultCommand().canParse("")); } } diff --git a/metarParser-parsers/src/test/java/io/github/mivek/command/remark/RemarkCommandArchitectureTest.java b/metarParser-parsers/src/test/java/io/github/mivek/command/remark/RemarkCommandArchitectureTest.java index 9e315650..a4dbd2d0 100644 --- a/metarParser-parsers/src/test/java/io/github/mivek/command/remark/RemarkCommandArchitectureTest.java +++ b/metarParser-parsers/src/test/java/io/github/mivek/command/remark/RemarkCommandArchitectureTest.java @@ -14,7 +14,7 @@ * @author mivek */ @RunWith(ArchUnitRunner.class) -@AnalyzeClasses(packages = {"io.github.mivek.command.remark"}, importOptions = { ImportOption.DoNotIncludeTests.class }) +@AnalyzeClasses(packages = { "io.github.mivek.command.remark" }, importOptions = { ImportOption.DoNotIncludeTests.class }) public class RemarkCommandArchitectureTest { @ArchTest public static final ArchRule dependancyRule = noClasses().should(). diff --git a/metarParser-parsers/src/test/java/io/github/mivek/command/remark/RemarkCommandSupplierTest.java b/metarParser-parsers/src/test/java/io/github/mivek/command/remark/RemarkCommandSupplierTest.java index dc5080ff..5996e142 100644 --- a/metarParser-parsers/src/test/java/io/github/mivek/command/remark/RemarkCommandSupplierTest.java +++ b/metarParser-parsers/src/test/java/io/github/mivek/command/remark/RemarkCommandSupplierTest.java @@ -13,7 +13,8 @@ */ public class RemarkCommandSupplierTest { - @Test public void testBuildCommandList() { + @Test + public void testBuildCommandList() { List commands = new RemarkCommandSupplier().buildCommandList(); assertNotNull(commands); diff --git a/metarParser-parsers/src/test/java/io/github/mivek/parser/AbstractParserTest.java b/metarParser-parsers/src/test/java/io/github/mivek/parser/AbstractParserTest.java index 18448acf..f5d61206 100644 --- a/metarParser-parsers/src/test/java/io/github/mivek/parser/AbstractParserTest.java +++ b/metarParser-parsers/src/test/java/io/github/mivek/parser/AbstractParserTest.java @@ -14,6 +14,7 @@ /** * Test class for {@link AbstractParser} + * * @author mivek */ @Ignore @@ -69,7 +70,7 @@ public void testParseWCDescriptiveIsNotNullButPhenomenonCanBeEmptyAndIntensityCa public void testTokenize() { // GIVEN a string with 1 1/2SM String code = "METAR KTTN 051853Z 04011KT 1 1/2SM VCTS SN FZFG BKN003 OVC010 M02/M02 A3006 RMK AO2 TSB40 SLP176 P0002 T10171017="; - String[] tokens = {"METAR", "KTTN", "051853Z", "04011KT", "1 1/2SM", "VCTS", "SN", "FZFG", "BKN003", "OVC010", "M02/M02", "A3006", "RMK", "AO2", "TSB40", "SLP176", "P0002", "T10171017"}; + String[] tokens = { "METAR", "KTTN", "051853Z", "04011KT", "1 1/2SM", "VCTS", "SN", "FZFG", "BKN003", "OVC010", "M02/M02", "A3006", "RMK", "AO2", "TSB40", "SLP176", "P0002", "T10171017" }; // WHEN tokenizing the string String[] result = getSut().tokenize(code); // THEN the visibility part is 1 1/2SM diff --git a/metarParser-parsers/src/test/java/io/github/mivek/parser/GeneralParseTest.java b/metarParser-parsers/src/test/java/io/github/mivek/parser/GeneralParseTest.java index 32251297..4ff624a1 100644 --- a/metarParser-parsers/src/test/java/io/github/mivek/parser/GeneralParseTest.java +++ b/metarParser-parsers/src/test/java/io/github/mivek/parser/GeneralParseTest.java @@ -13,7 +13,6 @@ /** * @author mivek - * */ @RunWith(Parameterized.class) public abstract class GeneralParseTest { @@ -23,19 +22,18 @@ public abstract class GeneralParseTest { @Parameters public static Collection data() { - return Arrays.asList(new Object[][] { - { "WS020/24045KT", true }, // Wind shear - { "05009KT", true }, // Wind - { "030V113", true }, // Wind variable - { "9999", true }, // Main visibility - { "6 1/2SM", true}, //Main visibility SM - { "1100w", true }, // Min visibility - { "VV002", true }, // Vertical visibility - { "CAVOK", true }, // CAVOK - { "SCT026CB", true }, // Cloud - { "ZZZ026CB", false }, // Cloud null - { "+SHGSRA", true }, // Weather condition - { "+ZERT", false } // Weather null + return Arrays.asList(new Object[][] { { "WS020/24045KT", true }, // Wind shear + { "05009KT", true }, // Wind + { "030V113", true }, // Wind variable + { "9999", true }, // Main visibility + { "6 1/2SM", true }, //Main visibility SM + { "1100w", true }, // Min visibility + { "VV002", true }, // Vertical visibility + { "CAVOK", true }, // CAVOK + { "SCT026CB", true }, // Cloud + { "ZZZ026CB", false }, // Cloud null + { "+SHGSRA", true }, // Weather condition + { "+ZERT", false } // Weather null }); } diff --git a/metarParser-parsers/src/test/java/io/github/mivek/parser/MetarParserTest.java b/metarParser-parsers/src/test/java/io/github/mivek/parser/MetarParserTest.java index 6b96eba1..9a427f76 100644 --- a/metarParser-parsers/src/test/java/io/github/mivek/parser/MetarParserTest.java +++ b/metarParser-parsers/src/test/java/io/github/mivek/parser/MetarParserTest.java @@ -40,7 +40,6 @@ public void setUp() { fSut = MetarParser.getInstance(); } - /** * =========================== Test ParseMetarAction =========================== */ @@ -260,8 +259,8 @@ public void testParseWithMaximalWind() { assertEquals(15, m.getWind().getSpeed()); assertEquals(25, m.getWind().getGust()); assertEquals("KT", m.getWind().getUnit()); - assertEquals(180, m.getWind().getExtreme1()); - assertEquals(300, m.getWind().getExtreme2()); + assertEquals(180, m.getWind().getMinVariation()); + assertEquals(300, m.getWind().getMaxVariation()); } @@ -342,7 +341,7 @@ public void testParseWithRMK() { @Test public void testParseRMK() { Metar m = new Metar(); - String[] array = {"RMK", "AO2", "TSB40", "SLP176", "P0002", "T10171017="}; + String[] array = { "RMK", "AO2", "TSB40", "SLP176", "P0002", "T10171017=" }; getSut().parseRMK(m, array, 0); String rmk = m.getRemark(); assertNotNull(rmk); @@ -359,8 +358,8 @@ public void alternativeWindForm() { assertEquals(26, m.getWind().getSpeed()); assertEquals(40, m.getWind().getGust()); assertEquals("KT", m.getWind().getUnit()); - assertEquals(240, m.getWind().getExtreme1()); - assertEquals(300, m.getWind().getExtreme2()); + assertEquals(240, m.getWind().getMinVariation()); + assertEquals(300, m.getWind().getMaxVariation()); } @Test diff --git a/metarParser-parsers/src/test/java/io/github/mivek/parser/RemarkParserTest.java b/metarParser-parsers/src/test/java/io/github/mivek/parser/RemarkParserTest.java index 5e9b2eef..ee6a5ec0 100644 --- a/metarParser-parsers/src/test/java/io/github/mivek/parser/RemarkParserTest.java +++ b/metarParser-parsers/src/test/java/io/github/mivek/parser/RemarkParserTest.java @@ -15,11 +15,13 @@ public class RemarkParserTest { public static final String REMARK_SEA_LEVEL_PRESSURE = "Remark.Sea.Level.Pressure"; private RemarkParser sut; - @Before public void setUp() { + @Before + public void setUp() { sut = RemarkParser.getInstance(); } - @Test public void testParseWithAO1() { + @Test + public void testParseWithAO1() { // GIVEN a RMK with AO1 token. String code = "Token AO1 End of remark"; // WHEN parsing the remark. @@ -29,7 +31,8 @@ public class RemarkParserTest { assertThat(remark, containsString(Messages.getInstance().getString("Remark.AO1"))); } - @Test public void testParseWithAO2() { + @Test + public void testParseWithAO2() { // GIVEN a RMK with AO2 token String code = "Token AO2 End of remark"; // WHEN parsing the remark. @@ -39,7 +42,8 @@ public class RemarkParserTest { assertThat(remark, containsString(Messages.getInstance().getString("Remark.AO2"))); } - @Test public void testParseWithWindPeakAtTheHour() { + @Test + public void testParseWithWindPeakAtTheHour() { // GIVEN a RMK with Peak wind at the hour. String code = "AO1 PK WND 28045/15"; // WHEN parsing the remark. @@ -50,7 +54,8 @@ public class RemarkParserTest { assertThat(remark, containsString(rmk)); } - @Test public void testParseWithWindPeakAtAnotherHour() { + @Test + public void testParseWithWindPeakAtAnotherHour() { // GIVEN a RMK with Peak wind at the hour. String code = "AO1 PK WND 28045/1515"; // WHEN parsing the remark. @@ -61,7 +66,8 @@ public class RemarkParserTest { assertThat(remark, containsString(rmk)); } - @Test public void testParseWindShiftAtTheHour() { + @Test + public void testParseWindShiftAtTheHour() { // GIVEN a RMK with Wind shift at the hour String code = "AO1 WSHFT 30"; // WHEN parsing the remark. @@ -72,7 +78,8 @@ public class RemarkParserTest { assertThat(remark, containsString(expectedRmk)); } - @Test public void testParseWindShift() { + @Test + public void testParseWindShift() { // GIVEN a RMK with Wind shift at the hour String code = "AO1 WSHFT 1530"; // WHEN parsing the remark. @@ -83,7 +90,8 @@ public class RemarkParserTest { assertThat(remark, containsString(expectedRmk)); } - @Test public void testParseWindShiftWithFrontal() { + @Test + public void testParseWindShiftWithFrontal() { // GIVEN a RMK with wind shift with frontal passage String code = "AO1 WSHFT 1530 FROPA"; // WHEN parsing the remark @@ -94,7 +102,8 @@ public class RemarkParserTest { assertThat(remark, containsString(expectedRmk)); } - @Test public void testParseWindShiftWithFrontalAtTheHour() { + @Test + public void testParseWindShiftWithFrontalAtTheHour() { // GIVEN a RMK with wind shift with frontal passage String code = "AO1 WSHFT 30 FROPA"; // WHEN parsing the remark @@ -105,7 +114,8 @@ public class RemarkParserTest { assertThat(remark, containsString(expectedRmk)); } - @Test public void testParseTowerVisibility() { + @Test + public void testParseTowerVisibility() { // GIVEN a rmk with tower visibility String code = "AO1 TWR VIS 16 1/2"; // WHEN parsing the remark @@ -115,7 +125,8 @@ public class RemarkParserTest { assertThat(remark, containsString(expectedRmk)); } - @Test public void testParseSurfaceVisibility() { + @Test + public void testParseSurfaceVisibility() { // GIVEN a rmk with surface visibility String code = "AO1 SFC VIS 16 1/2"; // WHEN parsing the remark @@ -125,7 +136,8 @@ public class RemarkParserTest { assertThat(remark, containsString(expectedRmk)); } - @Test public void testParsePrevailingVisibility() { + @Test + public void testParsePrevailingVisibility() { // GIVEN a rmk with variable prevailing visibility String code = "AO1 VIS 1/2V2"; // WHEN parsing the remark @@ -135,7 +147,8 @@ public class RemarkParserTest { assertThat(remark, containsString(expectedRmk)); } - @Test public void testParseSectorVisibility() { + @Test + public void testParseSectorVisibility() { // GIVEN a rmk with sector visibility String code = "AO1 VIS NE 2 1/2"; // WHEN parsing the remark @@ -145,7 +158,8 @@ public class RemarkParserTest { assertThat(remark, containsString(expectedRmk)); } - @Test public void testParseSecondLocationVisibility() { + @Test + public void testParseSecondLocationVisibility() { // GIVEN a rmk with visibility at second location String code = "AO1 VIS 2 1/2 RWY11"; // WHEN parsing the remark @@ -155,7 +169,8 @@ public class RemarkParserTest { assertThat(remark, containsString(expectedRmk)); } - @Test public void testParseTornadicActivityWithTornado() { + @Test + public void testParseTornadicActivityWithTornado() { String code = "AO1 TORNADO B13 6 NE"; String remark = sut.parse(code); String expectedRmk = Messages.getInstance() @@ -163,7 +178,8 @@ public class RemarkParserTest { assertThat(remark, containsString(expectedRmk)); } - @Test public void testParseTornadicActivityWithTornadoAndHour() { + @Test + public void testParseTornadicActivityWithTornadoAndHour() { String code = "AO1 TORNADO B1513 6 NE"; String remark = sut.parse(code); String expectedRmk = Messages.getInstance() @@ -171,7 +187,8 @@ public class RemarkParserTest { assertThat(remark, containsString(expectedRmk)); } - @Test public void testParseTornadicActivityWithFunnelCloud() { + @Test + public void testParseTornadicActivityWithFunnelCloud() { String code = "AO1 FUNNEL CLOUD B1513E1630 6 NE"; String remark = sut.parse(code); String expectedRmk = Messages.getInstance() @@ -179,7 +196,8 @@ public class RemarkParserTest { assertThat(remark, containsString(expectedRmk)); } - @Test public void testParseTornadicActivityWithFunnelCloudAndHourEnd() { + @Test + public void testParseTornadicActivityWithFunnelCloudAndHourEnd() { String code = "AO1 FUNNEL CLOUD B13E1630 6 NE"; String remark = sut.parse(code); String expectedRmk = Messages.getInstance() @@ -187,7 +205,8 @@ public class RemarkParserTest { assertThat(remark, containsString(expectedRmk)); } - @Test public void testParseTornadicActivityWithWaterSproutAndEndingTimeOnlyMinutes() { + @Test + public void testParseTornadicActivityWithWaterSproutAndEndingTimeOnlyMinutes() { String code = "AO1 WATERSPOUT E16 12 NE"; String remark = sut.parse(code); String expectedRmk = Messages.getInstance() @@ -195,7 +214,8 @@ public class RemarkParserTest { assertThat(remark, containsString(expectedRmk)); } - @Test public void testParseTornadicActivityWithWaterSproutAndEndingTime() { + @Test + public void testParseTornadicActivityWithWaterSproutAndEndingTime() { String code = "AO1 WATERSPOUT E1516 12 NE"; String remark = sut.parse(code); String expectedRmk = Messages.getInstance() @@ -203,7 +223,8 @@ public class RemarkParserTest { assertThat(remark, containsString(expectedRmk)); } - @Test public void testParseBeginningEndPrecipitation() { + @Test + public void testParseBeginningEndPrecipitation() { String code = "AO1 RAB05E30SNB1520E1655"; String remark = sut.parse(code); String expectedRmk1 = Messages.getInstance().getString(REMARK_PRECIPITATION_BEG_END, "", Messages.getInstance().getString("Phenomenon.RA"), "", "05", "", "30"); @@ -212,7 +233,8 @@ public class RemarkParserTest { assertThat(remark, containsString(expectedRmk2)); } - @Test public void testParseBeginningEndPrecipitationWithDescriptive() { + @Test + public void testParseBeginningEndPrecipitationWithDescriptive() { String code = "AO1 SHRAB05E30SHSNB20E55"; String remark = sut.parse(code); String expectedRmk1 = Messages.getInstance() @@ -223,76 +245,87 @@ public class RemarkParserTest { assertThat(remark, containsString(expectedRmk2)); } - @Test public void testParseBeginningThunderstorm() { + @Test + public void testParseBeginningThunderstorm() { String code = "AO1 TSB0159E30"; String remark = sut.parse(code); String expectedRmk1 = Messages.getInstance().getString(REMARK_PRECIPITATION_BEG_END, "", Messages.getInstance().getString("Phenomenon.TS"), "01", "59", "", "30"); assertThat(remark, containsString(expectedRmk1)); } - @Test public void testParseThunderStormLocation() { + @Test + public void testParseThunderStormLocation() { String code = "AO1 TS SE"; String remark = sut.parse(code); String expected = Messages.getInstance().getString("Remark.Thunderstorm.Location", Messages.getInstance().getString("Converter.SE")); assertThat(remark, containsString(expected)); } - @Test public void testParseThunderStormLocationWithMoving() { + @Test + public void testParseThunderStormLocationWithMoving() { String code = "AO1 TS SE MOV NE"; String remark = sut.parse(code); String expected = Messages.getInstance().getString("Remark.Thunderstorm.Location.Moving", Messages.getInstance().getString("Converter.SE"), Messages.getInstance().getString(CONVERTER_NE)); assertThat(remark, containsString(expected)); } - @Test public void testParseHailSize() { + @Test + public void testParseHailSize() { String code = "AO1 GR 1 3/4"; String remark = sut.parse(code); String expected = Messages.getInstance().getString("Remark.Hail", "1 3/4"); assertThat(remark, containsString(expected)); } - @Test public void testParseHailSizeWithLesserThan() { + @Test + public void testParseHailSizeWithLesserThan() { String code = "AO1 GR LESS THAN 1/4"; String remark = sut.parse(code); String expected = Messages.getInstance().getString("Remark.Hail.LesserThan", "1/4"); assertThat(remark, containsString(expected)); } - @Test public void testParseSnowPellets() { + @Test + public void testParseSnowPellets() { String code = "AO1 GS MOD"; String remark = sut.parse(code); String expected = Messages.getInstance().getString("Remark.Snow.Pellets", Messages.getInstance().getString("Remark.MOD")); assertThat(remark, containsString(expected)); } - @Test public void testParseVirgaWithDirection() { + @Test + public void testParseVirgaWithDirection() { String code = "AO1 VIRGA SW"; String remark = sut.parse(code); String expected = Messages.getInstance().getString("Remark.Virga.Direction", Messages.getInstance().getString("Converter.SW")); assertThat(remark, containsString(expected)); } - @Test public void testParseVirga() { + @Test + public void testParseVirga() { String code = "AO1 VIRGA"; String remark = sut.parse(code); assertThat(remark, containsString(Messages.getInstance().getString("Remark.VIRGA"))); } - @Test public void testParseCeilingHeight() { + @Test + public void testParseCeilingHeight() { String code = "AO1 CIG 005V010"; String remark = sut.parse(code); String expected = Messages.getInstance().getString("Remark.Ceiling.Height", 500, 1000); assertThat(remark, containsString(expected)); } - @Test public void testParseObscurations() { + @Test + public void testParseObscurations() { String code = "AO1 FU BKN020"; String remark = sut.parse(code); String expected = Messages.getInstance().getString("Remark.Obscuration", Messages.getInstance().getString(CLOUD_QUANTITY_BKN), 2000, Messages.getInstance().getString("Phenomenon.FU")); assertThat(remark, containsString(expected)); } - @Test public void testParseVariableSkyConditionWithoutLayer() { + @Test + public void testParseVariableSkyConditionWithoutLayer() { String code = "BKN V OVC"; String remark = sut.parse(code); String expected = Messages.getInstance() @@ -300,7 +333,8 @@ public class RemarkParserTest { assertThat(remark, containsString(expected)); } - @Test public void testParseVariableSkyCondition() { + @Test + public void testParseVariableSkyCondition() { String code = "BKN014 V OVC"; String remark = sut.parse(code); String expected = Messages.getInstance() @@ -308,35 +342,40 @@ public class RemarkParserTest { assertThat(remark, containsString(expected)); } - @Test public void testParseCeilingSecondLocation() { + @Test + public void testParseCeilingSecondLocation() { String code = "CIG 002 RWY11"; String remark = sut.parse(code); String expected = Messages.getInstance().getString("Remark.Ceiling.Second.Location", 200, "RWY11"); assertThat(remark, containsString(expected)); } - @Test public void testParseSealLevelPressure() { + @Test + public void testParseSealLevelPressure() { String code = "AO1 SLP134"; String remark = sut.parse(code); String expected = Messages.getInstance().getString(REMARK_SEA_LEVEL_PRESSURE, "1013.4"); assertThat(remark, containsString(expected)); } - @Test public void testParseSealLevelPressure2() { + @Test + public void testParseSealLevelPressure2() { String code = "AO1 SLP982"; String remark = sut.parse(code); String expected = Messages.getInstance().getString(REMARK_SEA_LEVEL_PRESSURE, "998.2"); assertThat(remark, containsString(expected)); } - @Test public void testParseSnowIncreasingRapidly() { + @Test + public void testParseSnowIncreasingRapidly() { String code = "AO1 SNINCR 2/10"; String remark = sut.parse(code); String expected = Messages.getInstance().getString("Remark.Snow.Increasing.Rapidly", 2, 10); assertThat(remark, containsString(expected)); } - @Test public void testParseWithRmkSlp() { + @Test + public void testParseWithRmkSlp() { String code = "CF1AC8 CF TR SLP091 DENSITY ALT 200FT"; String remark = sut.parse(code); diff --git a/metarParser-parsers/src/test/java/io/github/mivek/parser/TAFParserTest.java b/metarParser-parsers/src/test/java/io/github/mivek/parser/TAFParserTest.java index 8b519c00..196a1def 100644 --- a/metarParser-parsers/src/test/java/io/github/mivek/parser/TAFParserTest.java +++ b/metarParser-parsers/src/test/java/io/github/mivek/parser/TAFParserTest.java @@ -27,8 +27,8 @@ /** * Test class for {@link TAFParser} - * @author mivek * + * @author mivek */ public class TAFParserTest extends AbstractParserTest { @@ -47,7 +47,6 @@ public void setUp() { fSut = TAFParser.getInstance(); } - @Test public void testProcessGeneralChangesWithTX() { AbstractTafTrend change = new BECMGTafTrend(); @@ -89,7 +88,6 @@ public void testProcessGeneralChangesCloudNull() { assertThat(change.getClouds(), is(empty())); } - @Test public void testParseValidity() { String validityString = "3118/0124"; @@ -134,13 +132,8 @@ public void testParseBeginningValidity() { @Test public void testParseValidWithInvalidLineBreaks() throws ParseException { - String taf = "TAF LFPG 150500Z 1506/1612 17005KT 6000 SCT012 \n" - + "TEMPO 1506/1509 3000 BR BKN006 PROB40 \n" - + "TEMPO 1506/1508 0400 BCFG BKN002 PROB40 \n" - + "TEMPO 1512/1516 4000 -SHRA FEW030TCU BKN040 \n" - + "BECMG 1520/1522 CAVOK \n" - + "TEMPO 1603/1608 3000 BR BKN006 PROB40 \n" - + "TEMPO 1604/1607 0400 BCFG BKN002 TX17/1512Z TN07/1605Z"; + String taf = "TAF LFPG 150500Z 1506/1612 17005KT 6000 SCT012 \n" + "TEMPO 1506/1509 3000 BR BKN006 PROB40 \n" + "TEMPO 1506/1508 0400 BCFG BKN002 PROB40 \n" + + "TEMPO 1512/1516 4000 -SHRA FEW030TCU BKN040 \n" + "BECMG 1520/1522 CAVOK \n" + "TEMPO 1603/1608 3000 BR BKN006 PROB40 \n" + "TEMPO 1604/1607 0400 BCFG BKN002 TX17/1512Z TN07/1605Z"; TAF res = fSut.parse(taf); @@ -275,13 +268,8 @@ public void testParseValidWithInvalidLineBreaks() throws ParseException { @Test public void testParseValidWithoutLineBreaks() throws ParseException { - String taf = "TAF LSZH 292025Z 2921/3103 VRB03KT 9999 FEW020 BKN080 TX20/3014Z TN06/3003Z " + - "PROB30 TEMPO 2921/2923 SHRA " + - "BECMG 3001/3004 4000 MIFG NSC " + - "PROB40 3003/3007 1500 BCFG SCT004 " + - "PROB30 3004/3007 0800 FG VV003 " + - "BECMG 3006/3009 9999 FEW030 " + - "PROB40 TEMPO 3012/3017 30008KT"; + String taf = "TAF LSZH 292025Z 2921/3103 VRB03KT 9999 FEW020 BKN080 TX20/3014Z TN06/3003Z " + "PROB30 TEMPO 2921/2923 SHRA " + "BECMG 3001/3004 4000 MIFG NSC " + + "PROB40 3003/3007 1500 BCFG SCT004 " + "PROB30 3004/3007 0800 FG VV003 " + "BECMG 3006/3009 9999 FEW030 " + "PROB40 TEMPO 3012/3017 30008KT"; TAF res = fSut.parse(taf); @@ -499,8 +487,7 @@ public void testParseValidWithoutLineBreaksAndEndingTemperature() throws ParseEx @Test public void testParseWithFM() throws ParseException { - String message = "TAF KLWT 211120Z 2112/2212 20008KT 9999 SKC \n" + "TEMPO 2112/2116 VRB06KT \n" - + "FM212300 30012G22KT 9999 FEW050 SCT250 \n" + "FM220700 27008KT 9999 FEW030 FEW250"; + String message = "TAF KLWT 211120Z 2112/2212 20008KT 9999 SKC \n" + "TEMPO 2112/2116 VRB06KT \n" + "FM212300 30012G22KT 9999 FEW050 SCT250 \n" + "FM220700 27008KT 9999 FEW030 FEW250"; TAF res = fSut.parse(message); assertNotNull(res); @@ -618,9 +605,8 @@ public void testParseInvalidAirport() throws ParseException { @Test public void testParseWithNauticalMilesVisibility() throws ParseException { // GIVEN a TAF message with nautical miles visibility - String message = "TAF CZBF 300939Z 3010/3022 VRB03KT 6SM -SN OVC015 \r\n" + - "TEMPO 3010/3012 11/2SM -SN OVC009 \nFM301200 10008KT 2SM -SN OVC010 \r\n" + - "TEMPO 3012/3022 3/4SM -SN VV007 RMK FCST BASED ON AUTO OBS. NXT FCST BY 301400Z"; + String message = "TAF CZBF 300939Z 3010/3022 VRB03KT 6SM -SN OVC015 \r\n" + "TEMPO 3010/3012 11/2SM -SN OVC009 \nFM301200 10008KT 2SM -SN OVC010 \r\n" + + "TEMPO 3012/3022 3/4SM -SN VV007 RMK FCST BASED ON AUTO OBS. NXT FCST BY 301400Z"; //WHEN parsing the message. TAF result = fSut.parse(message); @@ -643,13 +629,9 @@ public void testParseWithNauticalMilesVisibility() throws ParseException { @Test public void testParseWithAMDTAF() throws ParseException { //GIVEN an amended TAF - String message = "TAF AMD LFPO 100742Z 1007/1112 21018G35KT 9999 BKN025 \r\n" + - " TEMPO 1007/1009 4000 RA BKN014 SCT020CB PROB40 \r\n" + - " TEMPO 1007/1009 22020G45KT \r\n" + - " TEMPO 1010/1017 24022G45KT SHRA SCT030CB PROB30 \r\n" + - " TEMPO 1012/1016 -TSRA \r\n" + - " BECMG 1020/1023 24013KT SCT023 \r\n" + - " TEMPO 1104/1112 4000 -SHRA BKN012 BKN020TCU"; + String message = "TAF AMD LFPO 100742Z 1007/1112 21018G35KT 9999 BKN025 \r\n" + " TEMPO 1007/1009 4000 RA BKN014 SCT020CB PROB40 \r\n" + " TEMPO 1007/1009 22020G45KT \r\n" + + " TEMPO 1010/1017 24022G45KT SHRA SCT030CB PROB30 \r\n" + " TEMPO 1012/1016 -TSRA \r\n" + " BECMG 1020/1023 24013KT SCT023 \r\n" + + " TEMPO 1104/1112 4000 -SHRA BKN012 BKN020TCU"; //WHEN parsing the message TAF result = fSut.parse(message); //Then the taf is correctly parsed and the amendment attribute is true. @@ -659,11 +641,8 @@ public void testParseWithAMDTAF() throws ParseException { @Test public void testParseWithCavok() throws ParseException { // GIVEN a TAF with CAVOK in the main part and in a BECMG part. - String message = "TAF LFPG 211700Z 2118/2224 VRB03KT CAVOK TX15/2215Z TN02/2205Z \n" + - "BECMG 2122/2124 3000 BR \n" + - "TEMPO 2202/2209 0800 BCFG PROB30 \n" + - "TEMPO 2203/2209 0500 FG \n" + - "BECMG 2211/2213 09006KT CAVOK"; + String message = "TAF LFPG 211700Z 2118/2224 VRB03KT CAVOK TX15/2215Z TN02/2205Z \n" + "BECMG 2122/2124 3000 BR \n" + "TEMPO 2202/2209 0800 BCFG PROB30 \n" + "TEMPO 2203/2209 0500 FG \n" + + "BECMG 2211/2213 09006KT CAVOK"; // WHEN parsing the event. TAF result = fSut.parse(message); @@ -686,8 +665,9 @@ public void testParseWithRMKInTempo() throws ParseException { assertNotNull(result); assertNotNull(result.getTempos().get(1)); assertNotNull(result.getTempos().get(1).getRemark()); - String rmk = Messages.getInstance().getString(REMARK_FCST) + " " + Messages.getInstance().getString("Remark.BASED") + " " + Messages.getInstance().getString("Remark.ON") + " AUTO OBS. " - + Messages.getInstance().getString(REMARK_NXT) + " " + Messages.getInstance().getString(REMARK_FCST) + " BY 301400Z"; + String rmk = + Messages.getInstance().getString(REMARK_FCST) + " " + Messages.getInstance().getString("Remark.BASED") + " " + Messages.getInstance().getString("Remark.ON") + " AUTO OBS. " + Messages + .getInstance().getString(REMARK_NXT) + " " + Messages.getInstance().getString(REMARK_FCST) + " BY 301400Z"; assertThat(result.getTempos().get(1).getRemark(), containsString(rmk)); } @@ -700,8 +680,9 @@ public void testParseWithRMK() throws ParseException { TAF result = fSut.parse(message); // THEN the second tempo contains the remark. assertNotNull(result); - String rmk = Messages.getInstance().getString(REMARK_FCST) + " " + Messages.getInstance().getString("Remark.BASED") + " " + Messages.getInstance().getString("Remark.ON") + " AUTO OBS. " - + Messages.getInstance().getString(REMARK_NXT) + " " + Messages.getInstance().getString(REMARK_FCST) + " BY 301400Z"; + String rmk = + Messages.getInstance().getString(REMARK_FCST) + " " + Messages.getInstance().getString("Remark.BASED") + " " + Messages.getInstance().getString("Remark.ON") + " AUTO OBS. " + Messages + .getInstance().getString(REMARK_NXT) + " " + Messages.getInstance().getString(REMARK_FCST) + " BY 301400Z"; assertThat(result.getRemark(), containsString(rmk)); String description = result.toString(); assertThat(description, containsString(Messages.getInstance().getString("ToString.start.day.month") + "=30"));