I have a method that filters in a List containing enums i
if (availableImageSizes.stream()
.filter(t -> t.getNameSuffix().equals("-xs"))
.findFirst().isPresent())
{
int width = availableImageSizes.stream()
.filter(t -> t.getNameSuffix().equals("-xs"))
.findFirst().getWidth();
int height = availableImageSizes.stream()
.filter(t -> t.getNameSuffix().equals("-xs"))
.findFirst().getHeight();
}
As you see I try to filter the list according to its NameSuffix and after filtering I want to map that value's width and height to a variable. But the code is wrong and even if it works, it is so ugly.
Can I map multiple variable in one lambda? If so, how can I achieve this?