Recently, I have been messing around with new java8 features to better understand them.
When trying to use some elements with, Stream.filterI came across a source Predicate.javain which I found the following implementation of the method isEqual:
static <T> Predicate<T> isEqual(Object targetRef) {
return (null == targetRef)
? Objects::isNull
: object -> targetRef.equals(object);
}
What it made me wonder whether this line: : object -> targetRef.equals(object);.
Maybe I overdid it a lot, but I could not immediately think why this line was not : targetRef::equals;like this:
static <T> Predicate<T> isEqual(Object targetRef) {
return (null == targetRef)
? Objects::isNull
: targetRef::equals;
}
It seems to me that unnecessarily creating a lambda otherwise.
If I didn’t miss something, I don’t care. (Is this the same?) Is there a reason why the current implementation is chosen? Or is it just incredibly small that they just missed it or no one cared.
, : - ? - (, ) ?