Is this code convertible to a lambda style?
Gernot Neppert
mcnepp02 at googlemail.com
Sun Dec 29 03:04:29 PST 2013
Am 28.12.2013 17:00, schrieb Marcos Antonio:
>
> Maybe at this point you can call me a little paranoid, but I like a code that looks a bit more symmetric (maybe just for aesthetic reasons). This is how my code is now:
>
> return getMetadataReader().getPropertyDescriptors().stream().
> filter(d -> d.getType() == PropertyType.ENTITY).
> filter(d -> hasChildAssociation(d)).
> findFirst().
> map(d -> d.convertToProperty()).
> orElse(null);
>
>
Maybe it would benefit (at least in terms of readability, but also
performance-wise) from combining the two filters like this:
return getMetadataReader().getPropertyDescriptors().stream().
filter(d -> d.getType() == PropertyType.ENTITY && hasChildAssociation(d)).
findFirst().
map(d -> d.convertToProperty()).
orElse(null);
More information about the lambda-dev
mailing list