jeudi 21 février 2019

Looking for a Design Pattern or Library

Is there a specific design pattern I could use to generate a string expression with some nested conditions?

Given:

Builder.red().and().blue().or(white().and().black()).toString()

Result should be:

red and blue or ( white and black )

Initially I started using the builder pattern (maybe it's not the appropriate one) but I got stuck when I had to generate the nested condition. Ideally the usage should be like in the above snippet (method chaining).

I need that for a java project (version 8) and the generated expression will be used as spring expression language (couldn't find a spring utility class that does that).

Aucun commentaire:

Enregistrer un commentaire