Is it necessary to Assert.notNull of a Singleton Object?
I have a class:
public class ComponentFactory {
private static LibraryFrame libraryFrame;
public static synchronized LibraryFrame getLibraryFrame() {
if (libraryFrame == null) {
libraryFrame = new LibraryFrame();
}
return libraryFrame;
}
}
Now is it needed to use as:
LibraryFrame libraryFrame = ComponentFactory.getLibraryFrame();
Assert.notNull(libraryFrame);
// other part
Here Assert class is org.springframework.util.Assert.
If Assertion failed is there anyway to call System.exit(0) after failure occurred?
The Assert is not necessary since the
LibraryFrameinstance will always be initialized at this point.