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