1
0
Fork 0
mirror of https://bitbucket.org/ethauvin/owm-japis.git synced 2025-04-24 17:37:12 -07:00
owm-japis-bak/src/main/kotlin/net/aksingh/owmjapis/model/param/Main.kt
2017-11-09 03:06:02 +05:30

74 lines
3 KiB
Kotlin

/**************************************************************************************************
* Copyright (c) 2013-2017 Ashutosh Kumar Singh <ashutosh@aksingh.net> *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software without *
* restriction, including without limitation the rights to use, copy, modify, merge, publish, *
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies or *
* substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING *
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, *
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
**************************************************************************************************/
package net.aksingh.owmjapis.model.param
import com.google.gson.GsonBuilder
import com.google.gson.annotations.SerializedName
data class Main(
@field:SerializedName("temp")
val temp: Float? = null,
@field:SerializedName("temp_min")
val tempMin: Float? = null,
@field:SerializedName("temp_max")
val tempMax: Float? = null,
@field:SerializedName("pressure")
val pressure: Float? = null,
@field:SerializedName("sea_level")
val seaLevel: Float? = null,
@field:SerializedName("grnd_level")
val groundLevel: Float? = null,
@field:SerializedName("humidity")
val humidity: Int? = null,
@field:SerializedName("temp_kf")
val tempKf: Float? = null
) {
fun hasTemp(): Boolean = temp != null
fun hasTempMax(): Boolean = tempMax != null
fun hasTempMin(): Boolean = tempMin != null
fun hasPressure(): Boolean = pressure != null
fun hasSeaLevel(): Boolean = seaLevel != null
fun hasGroundLevel(): Boolean = groundLevel != null
fun hasHumidity(): Boolean = humidity != null
fun hasTempKf(): Boolean = tempKf != null
fun toJson(): String {
return GsonBuilder().create().toJson(this)
}
fun toJsonPretty(): String {
return GsonBuilder().setPrettyPrinting().create().toJson(this)
}
}