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()
?dave08
11/26/2018, 3:18 AMinfix fun Regex.with(toMatch: String) = toMatch.match(this)
dave08
11/26/2018, 7:34 AMtjb
11/26/2018, 3:18 PMmatch
is an array of Match
objects. I need to be able to have multiple match
blocks in my DSLtjb
11/26/2018, 3:19 PMtjb
11/26/2018, 3:19 PMval 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 PMtjb
11/26/2018, 3:30 PMdave08
11/26/2018, 3:30 PMdave08
11/26/2018, 3:31 PMtjb
11/26/2018, 3:31 PMWITH
clause and im struggling how to implement the WITH
clause since its a separate method over MATCH
.tjb
11/26/2018, 3:31 PMWITH
its own builder but it seems like that shouldnt be the right move.tjb
11/26/2018, 3:32 PMmatch {
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 PMdave08
11/26/2018, 3:33 PMdave08
11/26/2018, 3:34 PMtjb
11/26/2018, 3:34 PMtjb
11/26/2018, 3:34 PMdave08
11/26/2018, 3:35 PM