zeroeightysix / fiber-dsl

A kotlin DSL extension for https://github.com/DaemonicLabs/fiber

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fiber-dsl

A small DSL for fiber

Usage

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 }
        }
    }
}

About

A kotlin DSL extension for https://github.com/DaemonicLabs/fiber


Languages

Language:Kotlin 100.0%