Extract logic for checking string representation of objects into separate methods

This commit is contained in:
Benedikt Ritter 2015-05-01 23:54:03 +02:00
parent 28656559d2
commit e8db7237a9
1 changed files with 11 additions and 4 deletions

View File

@ -2583,10 +2583,7 @@ public abstract class ToStringStyle implements Serializable {
}
final String valueAsString = value.toString();
if (valueAsString.startsWith(getContentStart())
&& valueAsString.endsWith(getContentEnd())
|| valueAsString.startsWith(getArrayStart())
&& valueAsString.startsWith(getArrayEnd())) {
if (isJsonObject(valueAsString) || isJsonArray(valueAsString)) {
buffer.append(value);
return;
}
@ -2594,6 +2591,16 @@ public abstract class ToStringStyle implements Serializable {
appendDetail(buffer, fieldName, valueAsString);
}
private boolean isJsonArray(String valueAsString) {
return valueAsString.startsWith(getArrayStart())
&& valueAsString.startsWith(getArrayEnd());
}
private boolean isJsonObject(String valueAsString) {
return valueAsString.startsWith(getContentStart())
&& valueAsString.endsWith(getContentEnd());
}
/**
* Appends the given String in parenthesis to the given StringBuffer.
*