Skip to content
Snippets Groups Projects
Commit ac7dfef7 authored by Simon Ehrenstein's avatar Simon Ehrenstein
Browse files

Make parsing yaml to kotlin objects work

parent 7437021d
Branches
Tags
4 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!85Introduce new Benchmark class and Patcher,!83WIP: Re-implementation of Theodolite with Kotlin/Quarkus
package theodolite.benchmark
import org.yaml.snakeyaml.Yaml
import org.yaml.snakeyaml.constructor.BaseConstructor
import org.yaml.snakeyaml.constructor.Constructor
import java.io.File
import java.io.FileInputStream
import java.io.InputStream
class BenchmarkYamlParser<T>: Parser<T> {
override fun parse(path: String): T {
override fun parse(path: String): KubernetesBenchmark? {
val input: InputStream = FileInputStream(File(path))
val parser = Yaml()
return parser.load<T>(input)
val parser = Yaml(Constructor(KubernetesBenchmark::class.java))
return parser.loadAs(input, KubernetesBenchmark::class.java)
}
}
\ No newline at end of file
package theodolite.benchmark
interface Parser<T> {
fun parse(path: String): T //Yaml
fun parse(path: String): KubernetesBenchmark? //Yaml
}
\ No newline at end of file
......@@ -2,8 +2,8 @@ package theodolite.benchmark
class TheodoliteYamlExecutor {
fun run() {
val parser = BenchmarkYamlParser<KubernetesBenchmark>()
val parser = theodolite.benchmark.BenchmarkYamlParser<KubernetesBenchmark>()
val benchmark= parser.parse("./../../../resources/main/yaml/test.yaml")
System.out.println(benchmark.name)
System.out.println(benchmark?.name)
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment