Skip to content

Commit

Permalink
Null safe appends to StringBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmay committed Mar 18, 2018
1 parent 28c24da commit 57b5706
Showing 1 changed file with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,9 @@ private void debugString(String string) {
public void debug(Object object, Object... objects) {
if (level <= DEBUG) {
StringBuilder result = new StringBuilder();
result.append(object.toString());
result.append(object);
for (Object obj : objects) {
if (obj == null) {
result.append("null");
} else {
result.append(obj.toString());
}
result.append(obj);
}
debugString(result.toString());
}
Expand Down Expand Up @@ -157,9 +153,9 @@ public void error(Object object) {
public void error(Object object, Object... objects) {
if (level <= ERROR) {
StringBuilder result = new StringBuilder();
result.append(object.toString());
result.append(object);
for (Object obj : objects) {
result.append(obj.toString());
result.append(obj);
}
errorString(result.toString());
}
Expand Down Expand Up @@ -190,9 +186,9 @@ public void info(Object object) {
public void info(Object object, Object... objects) {
if (level <= INFO) {
StringBuilder result = new StringBuilder();
result.append(object.toString());
result.append(object);
for (Object obj : objects) {
result.append(obj.toString());
result.append(obj);
}
infoString(result.toString());
}
Expand All @@ -219,9 +215,9 @@ private void warnString(String string) {
public void warn(Object object, Object... objects) {
if (level <= WARN) {
StringBuilder result = new StringBuilder();
result.append(object.toString());
result.append(object);
for (Object obj : objects) {
result.append(obj.toString());
result.append(obj);
}
warnString(result.toString());
}
Expand Down

0 comments on commit 57b5706

Please sign in to comment.