I need to filter a list with a response
ResponseEntity<Gruoup> listaGrupo = monstarListaGrupo(login, token);
List<Diretorio> diretorios = lista.stream()
.filter(x-> x.getGrupoAd() == listaGrupo.getBody().getGrupos())
I tried to do it that way but he doesn't let it because it says that one type is list and another is String
Apartment filter of a RespondeEntity in an age list for exam
RespondeEntity:
{
"name": "barry",
"age": 20
},
{
"name": "allan",
"age": 17
},
{
"name": "julie",
"age": 20
},
{
"name": "jord",
"age": 19
}
List:
{
"name": "jhenny",
"age": 20,
"color": "red"
},
{
"name": "barry",
"age": 20,
"color": "black"
},
{
"name": "julie",
"age": 20,
"color": "white"
}
Result final List
{
"name": "barry",
"age": 20,
"color": "black"
},
{
"name": "julie",
"age": 20,
"color": "white"
}
You are trying to compare a
String
with aList<Grupo>
, but it seems you want to filter based on the response entity containing the grupoAd of the directio.First collect the Strings from the List into a Set, then use
contains()
for the filter, somethingh like this: