So, I have some legacy java code that I don’t want...
# announcements
m
So, I have some legacy java code that I don’t want to touch, but I would like to add some Kotlin extensions around it to make it easier to work with. The terrible java side (as far as I am constructing it) looks like
Criteria criteria = new Criteria(new Filter(new Filter.FilterConditions("field", "value", FilterConditionOperator.EQ)))
The “FilterConditionOperator” thing really annoys me - and I don’t think I’ve seen a way to sort of “force a static `import`“, right? Would the “idiomatic Kotlin” way to go be maybe to make an infix function for each of the enum values, as a FilterConditionFactory?
e
I think it’s better to wrap all this code generation to your dsl
m
I’m trying to sort of feel my way there. The
Filter.FilterCondition
doesn’t have a default constructor - I was trying to look at some DSL examples, but they seemed to start with a default constructor, then set the fields. That’s when I thought, maybe infix functions as constructors (for that portion) might be the way to go, the way `map`s can use
to
to generate pairs.