uma :
I wrote bellow code to check some condition.
/**
* Returns true if any of the dose detail is an x
* @return boolean
*/
public <DD extends BD<DI>, DI extends BI> boolean Y(final Collection<DD> dds) {
return dds.stream().anyMatch(dd -> dd.M().K());
}
but this method have some risk dds , come as null. I need to return false is dd also null. how can be modify this method using java 8 to null safe ?
madhusdhnn :
Or you can do like this. More or like the same way
return dds != null && dds.stream().anyMatch(dd -> dd.M().K());
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=310330&siteId=1