Replace some events with Kotlin versions
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / main / VersionParser.kt
1 package net.pterodactylus.sone.main
2
3 import com.fasterxml.jackson.databind.ObjectMapper
4 import com.fasterxml.jackson.dataformat.yaml.YAMLFactory
5
6 @JvmOverloads
7 fun parseVersion(file: String = "/version.yaml"): Version? =
8                 Version::class.java.getResourceAsStream(file)?.use {
9                         objectMapper.readValue(it, Version::class.java)
10                 }
11
12 val parsedVersion by lazy { parseVersion() }
13
14 private val objectMapper = ObjectMapper(YAMLFactory())
15
16 @NoArg
17 data class Version(val id: String, val nice: String)