// Are some variables set?
if ((emailWrapper.getTemplateVariables() != null) && (!emailWrapper.getTemplateVariables().isEmpty())) {
// Add all variables
- for (Map.Entry<Object, Object> entry : emailWrapper.getTemplateVariables().entrySet()) {
+ for (final Map.Entry<Object, Object> entry : emailWrapper.getTemplateVariables().entrySet()) {
// Get key/value
- String key = (String) entry.getKey();
- String value = (String) entry.getValue();
+ final String key = (String) entry.getKey();
+ final String value = (String) entry.getValue();
// Both should not be empty
if (null == key) {
// Throw NPE
throw new NullPointerException("key is null"); //NOI18N
+ } else if (key.isEmpty()) {
+ // Throw IAE
+ throw new NullPointerException("key is empty"); //NOI18N
} else if (null == value) {
// Throw NPE again
throw new NullPointerException(MessageFormat.format("value for key={0} is null", key)); //NOI18N