- if (appConfig == null) {
- // This shouldn't happen but need to handle it in case...
- throw new ConfigXMLReaderException(
- String.format("%s: Could not create instance for app config binding %s",
- logName, bindingContext.appConfigBindingClass));
- } else {
- return (T) appConfig;
+
+ // This shouldn't happen but need to handle it in case...
+ checkNotNull(appConfig, "%s: Could not create instance for app config binding %s", logName,
+ bindingContext.appConfigBindingClass);
+
+ return (T) appConfig;
+ }
+
+ private static void checkNotNull(final Object reference, final String errorMessageFormat,
+ final Object... formatArgs) throws ConfigXMLReaderException {
+ checkCondition(reference != null, errorMessageFormat, formatArgs);
+ }
+
+ private static void checkCondition(final boolean expression, final String errorMessageFormat,
+ final Object... formatArgs) throws ConfigXMLReaderException {
+ if (!expression) {
+ throw new ConfigXMLReaderException(String.format(errorMessageFormat, formatArgs));