This method compares two strings. One of them comes from an object. If the strings match, the id is returned by the object.
private static Long getDefaultKag(Long mandandId) {
List<MandantKagAccountEntity> mandantKagAccountEntities = new MandantKagAccountManager().findAllKags(mandandId);
for (MandantKagAccountEntity mandantKagAccountEntity : mandantKagAccountEntities) {
if (mandantKagAccountEntity.getKagText().equals("Default_kag")) {
return mandantKagAccountEntity.getMandantKagId();
}
}
return null;
}
Is there any way to solve this with streams? My approach, but I can't get any further.
private static long getDefaultKag(Long mandandId) {
return new MandantKagAccountManager().findAllKags(mandandId).stream()
.filter(m -> m.getKagText().equals("Default_Kag"))
...
...
...
}
Do you have any idea how to solve this? I would also like to know which of the two variants is more efficient for large amounts of data.