From 533d0180e9e536a15e8ec53ed170afa05ab8fa21 Mon Sep 17 00:00:00 2001 From: Tobias Stottrop Date: Sun, 1 Dec 2019 23:38:43 +0100 Subject: [PATCH] added enum for the weather interpretation type. --- .../prediction/WeatherInterpretationType.java | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/common-api/src/main/java/com/mowesta/api/prediction/WeatherInterpretationType.java b/common-api/src/main/java/com/mowesta/api/prediction/WeatherInterpretationType.java index e6986217..614cecf9 100644 --- a/common-api/src/main/java/com/mowesta/api/prediction/WeatherInterpretationType.java +++ b/common-api/src/main/java/com/mowesta/api/prediction/WeatherInterpretationType.java @@ -1,10 +1,19 @@ package com.mowesta.api.prediction; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + import java.util.HashMap; import java.util.Map; +/** + * An enumeration to represent different weather interpretation types. + * The DWD uses an subset of WMO code table FM 94 BUFR/FM 95 CREX code table 0 20 003 – present weather. + * see further at @https://www.dwd.de/DWD/forschung/nwv/fepub/icon_database_main.pdf, page 36. + * + * @author Sebastian, Tobias + */ public enum WeatherInterpretationType { - UNKNOWN(-1), CLEAR_SKY(0), MAINLY_CLEAR(1), @@ -48,6 +57,13 @@ public enum WeatherInterpretationType { } } + /** + * Returns the value for the json representation. + * + * @param weatherInterpretationType The json number. + * @return The weather interpretation type. + */ + @JsonCreator public static WeatherInterpretationType valueOf(int weatherInterpretationType) { if (!map.containsKey(weatherInterpretationType)) { return UNKNOWN; @@ -55,6 +71,12 @@ public enum WeatherInterpretationType { return (WeatherInterpretationType) map.get(weatherInterpretationType); } + /** + * Returns the json representation. + * + * @return The json representation. + */ + @JsonValue public int getValue() { return value; }