[rules-users] use of enum with "in" on LHS

Vincent LEGENDRE vincent.legendre at eurodecision.com
Wed May 16 11:07:26 EDT 2012


Another potentiel trick :

In State enum, add a method to build a State list from a list of string
enum State {
    ...
    static List<State> buildList(String listAsStr) {
        // well, don't need to detail that ...
        // ... but think to keep a cache somewhere to avoid unecessary iterations at each rule's evaluation ...
    }
}

and in your DSL :
[*][when]- state is {stateList}=state in (State.buildList({stateList}))


Don't know if it really works, just an idea that could be better than replacing all NEW/OLD strings ...
If ot works, it can even be better to handle weird items list in a big string ...


More information about the rules-users mailing list