My object is a collection of profiles that inside has a set of PerfilMenunode
public class Perfil {
[...]
@OneToMany(cascade = CascadeType.ALL)
@JoinColumn(name = "ID_PERFIL")
@LazyCollection(LazyCollectionOption.FALSE)
private List<PerfilMenunode> perfilMenunodes;
What I want to do is this function but only using stream
public PerfilMenunode darPerfilMenuNode(List<Perfil> perfiles) {
PerfilMenunode perfilMenunode = null;
for (Perfil perfil : perfiles) {
perfilMenunode = perfil.getPerfilMenunodes().stream().filter(pm -> pm.getMenunode().getNombreCorto().equals(Constante.MENU_ADMINPERFIL_NOMBRECORTO)).findFirst().orElse(null);
if(perfilMenunode!=null) {
return perfilMenunode;
}
}
return perfilMenunode;
}
Any solution?