summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/imagemaster/util/Util.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/openslx/imagemaster/util/Util.java')
-rw-r--r--src/main/java/org/openslx/imagemaster/util/Util.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/main/java/org/openslx/imagemaster/util/Util.java b/src/main/java/org/openslx/imagemaster/util/Util.java
index ca595b5..79589c4 100644
--- a/src/main/java/org/openslx/imagemaster/util/Util.java
+++ b/src/main/java/org/openslx/imagemaster/util/Util.java
@@ -41,6 +41,28 @@ public class Util
}
/**
+ * Check if the given object is null, abort program if true.
+ * An optional message to be printed can be passed. A stack trace
+ * will be printed, too. Finally the application terminates with
+ * exit code 2.
+ *
+ * This comes in handy if something must not be null, and you want
+ * user friendly output. A perfect example would be reading settings
+ * from a config file. You can use this on mandatory fields.
+ *
+ * @param something the object to compare to null
+ * @param message the message to be printed if something is null
+ */
+ public static void notNullFatal( int number, String message )
+ {
+ if ( number == 0 ) {
+ if ( message != null )
+ log.fatal( "[NOTNULL] " + message, new NullPointerException() );
+ System.exit( 2 );
+ }
+ }
+
+ /**
* Check if String is null or empty, abort program if so.
* An optional message to be printed can be passed. A stack trace
* will be printed, too. Finally the application terminates with