I'm trying to refactor a piece of code that should handle a null checks the method is:
public static boolean isAnyNullArgs(Supplier<Object>... objs) {
return Stream.of(objs).anyMatch(o -> o.get() == null);
}
and I call it like that:
if (!isAnyNullArgs(() -> value.getField1(),
() -> value.getField1().getField2(),
() -> value.getField1().getField2().getFiled3(),
...
)
is there any way I can refactor my method so that I can call it like this (with only 1 lambda):
if (!isAnyNullArgs(() -> value.getField1(),
,value.getField1().getField2(),
,value.getField1().getField2().getField3(),
...
)