How can I optimize this using streams ?
List<String> prepared = new ArrayList<>(); availableFieldsFromImage.forEach(field -> { if(field.contains(".")){ prepared.add(field.split("\\.")[0]); } else { prepared.add(field); } }); maybe
List<String> prepared=availableFieldsFromImage.stream() .map(i->i.contains(".") ? i.split("\\.")[0] : i) .collect(Collectors.toList())