A small DSL for fiber
If you had a ConfigNode
called a
:
val a = ConfigNode("Foo", "Bar", false)
Transform your old, unreadable builders from:
val value = ConfigValueBuilder(Int::class.java)
.withName("Baz")
.withComment("Qux")
.withListener(BiConsumer { old, new -> println("Baz just changed from $old to $new") })
.withDefaultValue(2)
.constraints()
.composite(CompositeType.OR)
.minNumerical(5)
.maxNumerical(0)
.finishComposite()
.finish()
.build()
To a beautiful type-safe DSL:
val value = a.value<Int> {
name { "Baz" }
comment { "Qux" }
listener { old, new ->
println("Baz just changed from $old to $new")
}
defaultValue { 2 }
constrained {
or {
min { 5 }
max { 0 }
}
}
}