0
Gentlemen I made a simple code to filter a list by passing the id and the goal would be to return an object. To make use of the stream configured the libs annimon:stream and retrolamba, I would like a critique of the code below, since it is my first contact with these functions of Java 8
return Stream.of(lista)
.filter( e -> e.getId() == id)
.map(e -> new Especialidade(e.getId(), e.getNome()))
.collect(Collectors.toList())
.get(0);
Hi, Julio, hello, Julio! Yes the goal is to return an object, as I am sending an id to the filter so it should return a single object or null, thank you very much for the answer.
– Robson