How would you model/represent compound expressions with Classes?
Anonymous
I have to store and subsequently evaluate compound expressions in my application. An example of a compound expression would be:
((name == 'John Doe') && (age < 25))
The way that I need to store these expressions, is using a JSON representation. For example, the above expression would end up being something like:
{
"and": [
{
"=": [
{
"variable": "name"
},
"John Doe"
]
},
{
"lt": [
{
"variable": "age"
},
25
]
}
]
}
The general format is <operator>: [<operands>]
I'm finding it a little difficult to map something like this to Classes in my Java application. Would really appreciate some help here! 🙂