https://kotlinlang.org logo
Title
m

Matthew Good

04/28/2019, 2:59 PM
is it possible to implement the specification pattern in kotlin? as i tried https://dzone.com/articles/java-using-specification but i get the following undefined references: Predicate CriteriaBuilder Root
d

Dominaezzz

04/28/2019, 3:02 PM
If C# can do it, Kotlin can do it.
p

Pavlo Liapota

04/28/2019, 3:11 PM
m

Matthew Good

04/28/2019, 3:19 PM
oh
the
specification pattern
is used to implement logic such as
val b = v("1").and("2").and("3").and("4")
in
val i = txt("1234")

val a = v("1234")

val b = v("1").and("2").and("3").and("4")

AssertEquals(a.peek() == b.peek())
// fails if both are not equal
in applications such as parser combinators right?
c

Casey Brooks

04/29/2019, 2:50 PM
I’ve actually built a small library for this https://copper-leaf.github.io/trellis/
Pretty easy to do overall, relies heavily on generics and extension functions
m

Matthew Good

04/29/2019, 3:03 PM
ill check it out