summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/imagemaster/util/Util.java
diff options
context:
space:
mode:
authorSimon Rettberg2015-09-08 18:16:50 +0200
committerSimon Rettberg2015-09-08 18:16:50 +0200
commit05c598c830d4ff10b926a3f413e8a6129fd4337a (patch)
treefccd910f1739e97b2132e8119fdda26893b75264 /src/main/java/org/openslx/imagemaster/util/Util.java
parentCompilable... (diff)
downloadmasterserver-05c598c830d4ff10b926a3f413e8a6129fd4337a.tar.gz
masterserver-05c598c830d4ff10b926a3f413e8a6129fd4337a.tar.xz
masterserver-05c598c830d4ff10b926a3f413e8a6129fd4337a.zip
Stuff
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