Collection erhalten:
Set<Rel> x = findByTop(id);
return x.stream()
.filter(r -> r.getBottomOtyp() == otyp)
.collect(Collectors.toSet()); |
Set<Rel> x = findByTop(id);
return x.stream()
.filter(r -> r.getBottomOtyp() == otyp)
.collect(Collectors.toSet());
Collection verkleinern:
Set<Rel> x = findByTop(id);
x.removeIf(r -> (r.getBottomOtyp() != otyp));
return x; |
Set<Rel> x = findByTop(id);
x.removeIf(r -> (r.getBottomOtyp() != otyp));
return x;
weitere Beispiele:
set.stream().findFirst().orElse(null) |
set.stream().findFirst().orElse(null)
set.stream()
.filter(x -> x < 5)
.forEach(x -> System.out.println(x)) |
set.stream()
.filter(x -> x < 5)
.forEach(x -> System.out.println(x))
set.stream()
.filter(x -> x < 5)
.skip(1)
.limit(2)
.forEach(x -> System.out.println(x)) |
set.stream()
.filter(x -> x < 5)
.skip(1)
.limit(2)
.forEach(x -> System.out.println(x))