jeudi 24 mars 2016

Multiple conditions in an If statement - correct use of brackets?

In my If-Statement below I am trying to add all People objects from one list to another if they satisfy ALL the following conditions:

 1. Their status is neither RUNNING, WALKING OR SLEEPING
 2. Their Delete status is either null or equals "No"
 3. Their Birthday is less than 12 months ago. 

I think I must be missing a bracket somewhere as my program is not behaving as expected?

 if ((personList.get(i).getStatus() != PersonStatus.RUNNING
                            && personList.get(i).getStatus() != PersonStatus.WALKING
                            && personList.get(i).getStatus() != PersonStatus.SLEEPING)
                            && (personList.get(i).getDeleteStatus == null || personList.get(i).getDeleteStatus().equals("No"))
                            &&  (personList.get(i).getBirthday().isAfter(DateTime.now().minusMonths(12)))) {

                        idsOfPeople.add(personList.get(i).getId());
                    }

Aucun commentaire:

Enregistrer un commentaire