improved npe safety formatMessage method
This commit is contained in:
parent
14a0f7d687
commit
7ada30807d
|
@ -425,13 +425,13 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String formatMessage(String theMessage, Object... theMessageArguments) {
|
public String formatMessage(String theMessage, Object... theMessageArguments) {
|
||||||
String message;
|
String message = theMessage;
|
||||||
if (theMessageArguments != null && theMessageArguments.length > 0) {
|
if (Objects.nonNull(i18Nmessages) && i18Nmessages.containsKey(theMessage)) {
|
||||||
|
if (Objects.nonNull(theMessageArguments) && theMessageArguments.length > 0) {
|
||||||
message = MessageFormat.format(i18Nmessages.getString(theMessage), theMessageArguments);
|
message = MessageFormat.format(i18Nmessages.getString(theMessage), theMessageArguments);
|
||||||
} else if (i18Nmessages.containsKey(theMessage)) {
|
|
||||||
message = i18Nmessages.getString(theMessage);
|
|
||||||
} else {
|
} else {
|
||||||
message = theMessage;
|
message = i18Nmessages.getString(theMessage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
|
@ -464,13 +464,13 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String formatMessage(String theMessage, Object... theMessageArguments) {
|
public String formatMessage(String theMessage, Object... theMessageArguments) {
|
||||||
String message;
|
String message = theMessage;
|
||||||
if (theMessageArguments != null && theMessageArguments.length > 0) {
|
if (Objects.nonNull(i18Nmessages) && i18Nmessages.containsKey(theMessage)) {
|
||||||
|
if (Objects.nonNull(theMessageArguments) && theMessageArguments.length > 0) {
|
||||||
message = MessageFormat.format(i18Nmessages.getString(theMessage), theMessageArguments);
|
message = MessageFormat.format(i18Nmessages.getString(theMessage), theMessageArguments);
|
||||||
} else if (i18Nmessages.containsKey(theMessage)) {
|
|
||||||
message = i18Nmessages.getString(theMessage);
|
|
||||||
} else {
|
} else {
|
||||||
message = theMessage;
|
message = i18Nmessages.getString(theMessage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1197,13 +1197,13 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String formatMessage(String theMessage, Object... theMessageArguments) {
|
public String formatMessage(String theMessage, Object... theMessageArguments) {
|
||||||
String message;
|
String message = theMessage;
|
||||||
if (theMessageArguments != null && theMessageArguments.length > 0) {
|
if (Objects.nonNull(i18Nmessages) && i18Nmessages.containsKey(theMessage)) {
|
||||||
|
if (Objects.nonNull(theMessageArguments) && theMessageArguments.length > 0) {
|
||||||
message = MessageFormat.format(i18Nmessages.getString(theMessage), theMessageArguments);
|
message = MessageFormat.format(i18Nmessages.getString(theMessage), theMessageArguments);
|
||||||
} else if (i18Nmessages.containsKey(theMessage)) {
|
|
||||||
message = i18Nmessages.getString(theMessage);
|
|
||||||
} else {
|
} else {
|
||||||
message = theMessage;
|
message = i18Nmessages.getString(theMessage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1297,13 +1297,13 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String formatMessage(String theMessage, Object... theMessageArguments) {
|
public String formatMessage(String theMessage, Object... theMessageArguments) {
|
||||||
String message;
|
String message = theMessage;
|
||||||
if (theMessageArguments != null && theMessageArguments.length > 0) {
|
if (Objects.nonNull(i18Nmessages) && i18Nmessages.containsKey(theMessage)) {
|
||||||
|
if (Objects.nonNull(theMessageArguments) && theMessageArguments.length > 0) {
|
||||||
message = MessageFormat.format(i18Nmessages.getString(theMessage), theMessageArguments);
|
message = MessageFormat.format(i18Nmessages.getString(theMessage), theMessageArguments);
|
||||||
} else if (i18Nmessages.containsKey(theMessage)) {
|
|
||||||
message = i18Nmessages.getString(theMessage);
|
|
||||||
} else {
|
} else {
|
||||||
message = theMessage;
|
message = i18Nmessages.getString(theMessage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue