diff --git a/src/main/java/com/github/prominence/openweathermap/api/annotation/SubscriptionAvailability.java b/src/main/java/com/github/prominence/openweathermap/api/annotation/SubscriptionAvailability.java index 61d365e..1e499aa 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/annotation/SubscriptionAvailability.java +++ b/src/main/java/com/github/prominence/openweathermap/api/annotation/SubscriptionAvailability.java @@ -29,6 +29,9 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +/** + * Marker-type annotation to specify what type of license it needs to have to use API method. + */ @Target(ElementType.METHOD) @Retention(RetentionPolicy.CLASS) public @interface SubscriptionAvailability { diff --git a/src/main/java/com/github/prominence/openweathermap/api/enums/Language.java b/src/main/java/com/github/prominence/openweathermap/api/enums/Language.java index c4ef6ce..df73bae 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/enums/Language.java +++ b/src/main/java/com/github/prominence/openweathermap/api/enums/Language.java @@ -22,8 +22,11 @@ package com.github.prominence.openweathermap.api.enums; +/** + * An enumeration which lists all available languages for API usage. + * Usually it could be specified to get response with some fields translated into desired language. + */ public enum Language { - ARABIC("ar"), BULGARIAN("bg"), CATALAN("ca"), diff --git a/src/main/java/com/github/prominence/openweathermap/api/enums/SubscriptionPlan.java b/src/main/java/com/github/prominence/openweathermap/api/enums/SubscriptionPlan.java index 46fd194..c70c4fa 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/enums/SubscriptionPlan.java +++ b/src/main/java/com/github/prominence/openweathermap/api/enums/SubscriptionPlan.java @@ -22,6 +22,10 @@ package com.github.prominence.openweathermap.api.enums; +/** + * An enumeration with all available subscription plans. + * More information at official website. + */ public enum SubscriptionPlan { FREE, STARTUP, diff --git a/src/main/java/com/github/prominence/openweathermap/api/enums/TimeFrame.java b/src/main/java/com/github/prominence/openweathermap/api/enums/TimeFrame.java index c133ef7..284bc5a 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/enums/TimeFrame.java +++ b/src/main/java/com/github/prominence/openweathermap/api/enums/TimeFrame.java @@ -22,6 +22,7 @@ package com.github.prominence.openweathermap.api.enums; +@Deprecated public enum TimeFrame { YEAR, MONTH, diff --git a/src/main/java/com/github/prominence/openweathermap/api/enums/UnitSystem.java b/src/main/java/com/github/prominence/openweathermap/api/enums/UnitSystem.java index 3457a1f..6387ed1 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/enums/UnitSystem.java +++ b/src/main/java/com/github/prominence/openweathermap/api/enums/UnitSystem.java @@ -22,8 +22,10 @@ package com.github.prominence.openweathermap.api.enums; +/** + * An enumeration for supported unit systems with helper methods. + */ public enum UnitSystem { - METRIC("metric"), IMPERIAL("imperial"), STANDARD("standard"); @@ -34,8 +36,8 @@ public enum UnitSystem { this.value = value; } - public static String getWindUnit(UnitSystem type) { - switch (type) { + public String getWindUnit() { + switch (this) { case IMPERIAL: return "miles/hour"; case STANDARD: @@ -45,8 +47,8 @@ public enum UnitSystem { } } - public static String getTemperatureUnit(UnitSystem type) { - switch (type) { + public String getTemperatureUnit() { + switch (this) { case METRIC: return "℃"; case IMPERIAL: diff --git a/src/main/java/com/github/prominence/openweathermap/api/exception/InvalidAuthTokenException.java b/src/main/java/com/github/prominence/openweathermap/api/exception/InvalidAuthTokenException.java index 9e7dd20..50640fa 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/exception/InvalidAuthTokenException.java +++ b/src/main/java/com/github/prominence/openweathermap/api/exception/InvalidAuthTokenException.java @@ -22,10 +22,13 @@ package com.github.prominence.openweathermap.api.exception; +/** + * An exception that could be thrown in case of your API key is invalid or your subscription plan does not cover requested functionality. + * Subscription plans information you can find here. + * API Keys could be checked in your profile. + */ public class InvalidAuthTokenException extends RuntimeException { - public InvalidAuthTokenException() { super("Authentication token wasn't set or requested functionality is not permitted for your subscription plan. Please, check https://home.openweathermap.org/api_keys/ and https://openweathermap.org/price."); } - } diff --git a/src/main/java/com/github/prominence/openweathermap/api/exception/NoDataFoundException.java b/src/main/java/com/github/prominence/openweathermap/api/exception/NoDataFoundException.java index 4f66b53..33a6593 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/exception/NoDataFoundException.java +++ b/src/main/java/com/github/prominence/openweathermap/api/exception/NoDataFoundException.java @@ -22,8 +22,15 @@ package com.github.prominence.openweathermap.api.exception; +/** + * An exception that could be thrown in several cases: + * + */ public class NoDataFoundException extends RuntimeException { - public NoDataFoundException() { super("Data for provided parameters wasn't found. Please, check requested location."); } @@ -31,5 +38,4 @@ public class NoDataFoundException extends RuntimeException { public NoDataFoundException(Throwable throwable) { super(throwable.getMessage(), throwable.getCause()); } - } diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastResponseMapper.java b/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastResponseMapper.java index eeff46d..428e493 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastResponseMapper.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/forecast/free/FiveDayThreeHourStepForecastResponseMapper.java @@ -151,7 +151,7 @@ public class FiveDayThreeHourStepForecastResponseMapper { private Temperature parseTemperature(JsonNode rootNode) { final double tempValue = rootNode.get("temp").asDouble(); - Temperature temperature = Temperature.forValue(tempValue, UnitSystem.getTemperatureUnit(unitSystem)); + Temperature temperature = Temperature.forValue(tempValue, unitSystem.getTemperatureUnit()); final JsonNode tempMaxNode = rootNode.get("temp_max"); if (tempMaxNode != null) { @@ -192,7 +192,7 @@ public class FiveDayThreeHourStepForecastResponseMapper { final JsonNode windNode = root.get("wind"); double speed = windNode.get("speed").asDouble(); - Wind wind = Wind.forValue(speed, UnitSystem.getWindUnit(unitSystem)); + Wind wind = Wind.forValue(speed, unitSystem.getWindUnit()); final JsonNode degNode = windNode.get("deg"); if (degNode != null) { wind.setDegrees(degNode.asDouble()); diff --git a/src/main/java/com/github/prominence/openweathermap/api/request/weather/CurrentWeatherResponseMapper.java b/src/main/java/com/github/prominence/openweathermap/api/request/weather/CurrentWeatherResponseMapper.java index 2eb16f0..e0302ca 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/request/weather/CurrentWeatherResponseMapper.java +++ b/src/main/java/com/github/prominence/openweathermap/api/request/weather/CurrentWeatherResponseMapper.java @@ -147,7 +147,7 @@ public class CurrentWeatherResponseMapper implements ResponseMapper { final JsonNode mainNode = rootNode.get("main"); final double tempValue = mainNode.get("temp").asDouble(); - temperature = Temperature.forValue(tempValue, UnitSystem.getTemperatureUnit(unitSystem)); + temperature = Temperature.forValue(tempValue, unitSystem.getTemperatureUnit()); final JsonNode feelsLikeNode = mainNode.get("feels_like"); if (feelsLikeNode != null) { @@ -191,7 +191,7 @@ public class CurrentWeatherResponseMapper implements ResponseMapper { final JsonNode windNode = rootNode.get("wind"); double speed = windNode.get("speed").asDouble(); - Wind wind = Wind.forValue(speed, UnitSystem.getWindUnit(unitSystem)); + Wind wind = Wind.forValue(speed, unitSystem.getWindUnit()); final JsonNode degNode = windNode.get("deg"); if (degNode != null) { diff --git a/src/main/java/com/github/prominence/openweathermap/api/utils/RequestUtils.java b/src/main/java/com/github/prominence/openweathermap/api/utils/RequestUtils.java index 40e5568..d7a2458 100644 --- a/src/main/java/com/github/prominence/openweathermap/api/utils/RequestUtils.java +++ b/src/main/java/com/github/prominence/openweathermap/api/utils/RequestUtils.java @@ -53,7 +53,6 @@ public final class RequestUtils { * @return InputStream instance containing http response body. * @throws InvalidAuthTokenException in case if authentication token wasn't set or requested functionality is not permitted for its subscription plan. * @throws NoDataFoundException in case if there is no any data for requested location(s) or request is invalid. - * @throws IllegalStateException in case of unexpected response or error. */ private static InputStream executeRequest(URL requestUrl) { InputStream resultStream;