How to loop list object and getting it's element by index?

You can use Stream API to map your collection:

List<Employe> listEmploye  = ids.stream()
.map(Long::valueOf)
.map(BigDecimal::valueOf)
.map(this::findByIdPointage)
.collect(Collectors.toList());

 List<Employe> listEmploye = ids.stream()
          .mapToLong(Long::parseLong)
          .mapToObj(BigDecimal::valueOf)
          .map(this::findByIdPointage)
          .collect(Collectors.toList());

Well there is a BigDecimal constructor that takes a String, thus this can be simplified to :

List<Employe> listEmploye = ids.stream()
           .map(BigDecimal::new) 
           .map(this::findByIdPointage)
           .collect(Collectors.toList())   

public List<Employee> getEmployees(Set<String> ids) {
    return ids.stream()
              .map(id -> BigDecimal.valueOf(Long.parseLong(id)))
              .map(this::findByIdPointage)
              .collect(Collectors.toList());
}

Tags:

Java

Java 8