diff options
author | Michael Petretti | 2014-05-07 17:19:57 +0200 |
---|---|---|
committer | Michael Petretti | 2014-05-07 17:19:57 +0200 |
commit | 615da090f14bf75b3bc843f503f9d4357f25641d (patch) | |
tree | 92115e74caba56273b07f731605e7b85220b4fcd /src/main/java/org/openslx/satellitedaemon/util/Util.java | |
parent | fix dependencies (diff) | |
parent | Add DB classes + dummy DbImage class (diff) | |
download | satellite-daemon-615da090f14bf75b3bc843f503f9d4357f25641d.tar.gz satellite-daemon-615da090f14bf75b3bc843f503f9d4357f25641d.tar.xz satellite-daemon-615da090f14bf75b3bc843f503f9d4357f25641d.zip |
Merge branch 'master' of git.openslx.org:bwlp/satellite-daemon
Diffstat (limited to 'src/main/java/org/openslx/satellitedaemon/util/Util.java')
-rw-r--r-- | src/main/java/org/openslx/satellitedaemon/util/Util.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/main/java/org/openslx/satellitedaemon/util/Util.java b/src/main/java/org/openslx/satellitedaemon/util/Util.java new file mode 100644 index 0000000..4f39e71 --- /dev/null +++ b/src/main/java/org/openslx/satellitedaemon/util/Util.java @@ -0,0 +1,32 @@ +package org.openslx.satellitedaemon.util; + +import org.apache.log4j.Logger; + +public class Util +{ + private static Logger log = Logger.getLogger( Util.class ); + + /** + * 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( Object something, String message ) + { + if ( something == null ) { + if ( message != null ) + log.fatal( "[NOTNULL] " + message ); + log.warn( Thread.currentThread().getStackTrace().toString() ); + System.exit( 2 ); + } + } +} |