f5ddfc2271fbb6c126f75cf3df760f341cf8667c
[rhynodge.git] / src / main / kotlin / net / pterodactylus / rhynodge / webpages / weather / wettercom / HourState.kt
1 package net.pterodactylus.rhynodge.webpages.weather.wettercom
2
3 import com.fasterxml.jackson.annotation.JsonProperty
4
5 /**
6  * Container for weather conditions of a single hour.
7  *
8  * @author [David ‘Bombe’ Roden](mailto:bombe@pterodactylus.net)
9  */
10 data class HourState(
11         @JsonProperty("hourIndex") val hourIndex: Int,
12         @JsonProperty("temperature") val temperature: Double,
13         @JsonProperty("rainProbability") val rainProbability: Double,
14         @JsonProperty("rainAmount") val rainAmount: Double,
15         @JsonProperty("windDirection") val windDirection: WindDirection,
16         @JsonProperty("windSpeed") val windSpeed: Double,
17         @JsonProperty("description") val description: String,
18         @JsonProperty("image") val image: String) {
19
20     class Builder(private val hourIndex: Int) {
21
22         fun temperature(temperature: Double) = _1(temperature)
23
24         inner class _1(private val temperature: Double) {
25
26             fun rainProbability(rainProbability: Double) = _2(rainProbability)
27
28             inner class _2(private val rainProbability: Double) {
29
30                 fun rainAmount(rainAmount: Double) = _3(rainAmount)
31
32                 inner class _3(private val rainAmount: Double) {
33
34                     fun windFrom(windDirection: WindDirection) = _4(windDirection);
35
36                     inner class _4(private val windDirection: WindDirection) {
37
38                         fun at(windSpeed: Double) = _5(windSpeed)
39
40                         inner class _5(private val windSpeed: Double) {
41
42                             fun describedAs(description: String) = _6(description)
43
44                             inner class _6(private val description: String) {
45
46                                 fun withImage(imageUrl: String) = _7(imageUrl)
47
48                                 inner class _7(private val imageUrl: String) {
49
50                                     fun build(): HourState {
51                                         return HourState(hourIndex, temperature, rainProbability, rainAmount, windDirection, windSpeed, description, imageUrl)
52                                     }
53
54                                 }
55
56                             }
57
58                         }
59
60                     }
61
62                 }
63
64             }
65
66         }
67
68     }
69
70     companion object {
71
72         fun atHour(hourIndex: Int) = Builder(hourIndex)
73
74     }
75
76 }