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 LibraryFrame instance will always be initialized at this point.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With