Whether the interface is null is an implementation detail of MethodCall that clients needn't worry about.
Within MethodCall, the isInterface method (and by extension interfaceMatches) can then use a more null-safe comparison by checking the string against the interface name (as opposed to vice-versa), to obviate the null check, such as:
From SpotBugs:
I'm not sure if this one is a real issue:
The line of note from the SpotBugs report, but I'm not sure why SpotBugs is reporting an issue:
There are some minor simplifications that can be made, relating to encapsulation violations. Consider:
This puts the onus of analyzing the data back into the class that has the data and can be further simplified:
Whether the interface is
null
is an implementation detail ofMethodCall
that clients needn't worry about.Within
MethodCall
, theisInterface
method (and by extensioninterfaceMatches
) can then use a morenull
-safe comparison by checking the string against the interface name (as opposed to vice-versa), to obviate thenull
check, such as: