com.ancientlightstudios.simplegen.YamlReader.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of simplegen Show documentation
Show all versions of simplegen Show documentation
SimpleGen is a simple code generator. This is the actual code generator.
package com.ancientlightstudios.simplegen
import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory
import java.io.InputStream
import java.util.*
object YamlReader {
/**
* Reads a yaml stream into a map.
* @param stream the stream to read
* @return the resulting map.
*/
fun readToMap(stream: InputStream): Map {
val typeRef = object : TypeReference>() {}
return ObjectMapper(YAMLFactory()).readValue(stream, typeRef)
}
/**
* Reads a yaml stream into a pojo.
* @param stream the stream to read
* @param type the pojo type
* @return the resulting pojo
*/
fun readToPojo(stream: InputStream, type: Class): T = ObjectMapper(YAMLFactory()).readValue(stream, type)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy