tjb
11/26/2018, 3:03 AMfun match(block: MatchBuilder.() -> Unit = {}) {
val matchBuilder = MatchBuilder()
matchBuilder.block()
match = match.plus(matchBuilder.build())
}
dave08
11/26/2018, 3:16 AMreturn matchBuilder.build()
?infix fun Regex.with(toMatch: String) = toMatch.match(this)
tjb
11/26/2018, 3:18 PMmatch
is an array of Match
objects. I need to be able to have multiple match
blocks in my DSLval m = builder {
match {
optional = true
node {
alias = "firstField"
node = "Field"
parameters = hashMapOf("id" to "12345", "hasTime" to false)
}
}
match {
node {
alias = "secondField"
node = "Field"
parameters = hashMapOf("id" to "12345", "hasTime" to false)
}
}
}
dave08
11/26/2018, 3:28 PMm
once and re-use it?tjb
11/26/2018, 3:29 PMdave08
11/26/2018, 3:30 PMtjb
11/26/2018, 3:31 PMWITH
clause and im struggling how to implement the WITH
clause since its a separate method over MATCH
.WITH
its own builder but it seems like that shouldnt be the right move.match {
node {
alias = "secondField"
node = "Field"
parameters = hashMapOf("id" to "12345", "hasTime" to false)
}
}
with "hello, world, right, here"
but not sure how to implement the with
heredave08
11/26/2018, 3:33 PMtjb
11/26/2018, 3:34 PMdave08
11/26/2018, 3:35 PM