If dynamic in java

0

Suppose I have a list of people (NAME, AGE, FACILITY, CITY, SEX):

new Persona("Paco", 35, 05-05-1991,"Lisboa","H")
new Persona("Luis", 5, 05-05-1981,"Madrid","H")
new Persona("Pepe", 25, 05-05-1971,"Lisboa","H")
new Persona("Maria", 85, 05-05-1961,"Madrid","M")
new Persona("Marcos", 75, 05-05-1951,"Lisboa","H")

And I have a json:

var filter={ciudad:{check:true, value:'Madrid', operator:'='}, 
            fn:{check:true, value:'05-05-19970', operator:'>'}}

How can I do the dynamic ifs, assuming that the var filter can come with N combinations and I just need to recover according to what comes from the filter?

That is to say, with this example I would like all the people who were from 'madrid' and their date of birth is greater than '05 -05-19970 '

I can not put for example:

if (persona.ciudad.equals('Madrid') {
     /// ya que esto no es dinámico no siempre compararé esto por: 
     1- persona.ciudad no siempre será un filtro, entonces tendria código que no usaré
}

NOTE: I really do not have person objects but a json of people

    
asked by sirdaiz 13.06.2017 в 17:14
source

0 answers