I have a class where I have injected a field using javax.inject.Inject
annotation
import javax.inject.Inject;
public class Foo extends BaseFoo {
@Inject
private Bar bar;
...
public void execute(){
if (bar == null) {
//log failure message and return
return;
}
//Do your work..
}
...
}
My question is whether in the above example, is null
check needed or not? and why?