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