What is the lambdaj code for the following iteration

152 Views Asked by At

The following is the code which normally write to iterate and based on some condtion,i am adding to some other list.How can i write the same in the Lambdaj. Thanks in advance and your suggestion is appreciable.

List<Person> authorizedPerson = new ArrayList<Person>();
 for(Person person : Pesrsons) {
  if(person .getAuthorized()) {
    authorizedPerson.add(person);
   }
}
1

There are 1 best solutions below

1
On

The following is the answer for the above,I investigated and found the solution, If it is wrong please correct me.

 List<Person> authorizedPesrson = select(persons, having(on(Person.class).getAuthorized().equals(true)));