Polish contribution
See gh-23300
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -40,12 +40,13 @@ import org.springframework.util.ObjectUtils;
|
||||
*/
|
||||
public class DefaultValueStyler implements ValueStyler {
|
||||
|
||||
private static final String EMPTY = "[empty]";
|
||||
private static final String EMPTY = "[[empty]]";
|
||||
private static final String NULL = "[null]";
|
||||
private static final String COLLECTION = "collection";
|
||||
private static final String SET = "set";
|
||||
private static final String LIST = "list";
|
||||
private static final String MAP = "map";
|
||||
private static final String EMPTY_MAP = MAP + EMPTY;
|
||||
private static final String ARRAY = "array";
|
||||
|
||||
|
||||
@@ -83,7 +84,7 @@ public class DefaultValueStyler implements ValueStyler {
|
||||
|
||||
private <K, V> String style(Map<K, V> value) {
|
||||
if (value.isEmpty()) {
|
||||
return MAP + '[' + EMPTY + ']';
|
||||
return EMPTY_MAP;
|
||||
}
|
||||
|
||||
StringJoiner result = new StringJoiner(", ", "[", "]");
|
||||
@@ -101,7 +102,7 @@ public class DefaultValueStyler implements ValueStyler {
|
||||
String collectionType = getCollectionTypeString(value);
|
||||
|
||||
if (value.isEmpty()) {
|
||||
return collectionType + '[' + EMPTY + ']';
|
||||
return collectionType + EMPTY;
|
||||
}
|
||||
|
||||
StringJoiner result = new StringJoiner(", ", "[", "]");
|
||||
@@ -125,7 +126,7 @@ public class DefaultValueStyler implements ValueStyler {
|
||||
|
||||
private String styleArray(Object[] array) {
|
||||
if (array.length == 0) {
|
||||
return ARRAY + '<' + ClassUtils.getShortName(array.getClass().getComponentType()) + '>' + '[' + EMPTY + ']';
|
||||
return ARRAY + '<' + ClassUtils.getShortName(array.getClass().getComponentType()) + '>' + EMPTY;
|
||||
}
|
||||
|
||||
StringJoiner result = new StringJoiner(", ", "[", "]");
|
||||
|
||||
@@ -710,11 +710,11 @@ public abstract class ObjectUtils {
|
||||
if (length == 0) {
|
||||
return EMPTY_ARRAY;
|
||||
}
|
||||
StringJoiner sj = new StringJoiner(ARRAY_ELEMENT_SEPARATOR, ARRAY_START, ARRAY_END);
|
||||
StringJoiner stringJoiner = new StringJoiner(ARRAY_ELEMENT_SEPARATOR, ARRAY_START, ARRAY_END);
|
||||
for (Object o : array) {
|
||||
sj.add(String.valueOf(o));
|
||||
stringJoiner.add(String.valueOf(o));
|
||||
}
|
||||
return sj.toString();
|
||||
return stringJoiner.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -734,11 +734,11 @@ public abstract class ObjectUtils {
|
||||
if (length == 0) {
|
||||
return EMPTY_ARRAY;
|
||||
}
|
||||
StringJoiner sj = new StringJoiner(ARRAY_ELEMENT_SEPARATOR, ARRAY_START, ARRAY_END);
|
||||
StringJoiner stringJoiner = new StringJoiner(ARRAY_ELEMENT_SEPARATOR, ARRAY_START, ARRAY_END);
|
||||
for (boolean b : array) {
|
||||
sj.add(String.valueOf(b));
|
||||
stringJoiner.add(String.valueOf(b));
|
||||
}
|
||||
return sj.toString();
|
||||
return stringJoiner.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -758,11 +758,11 @@ public abstract class ObjectUtils {
|
||||
if (length == 0) {
|
||||
return EMPTY_ARRAY;
|
||||
}
|
||||
StringJoiner sj = new StringJoiner(ARRAY_ELEMENT_SEPARATOR, ARRAY_START, ARRAY_END);
|
||||
StringJoiner stringJoiner = new StringJoiner(ARRAY_ELEMENT_SEPARATOR, ARRAY_START, ARRAY_END);
|
||||
for (byte b : array) {
|
||||
sj.add(String.valueOf(b));
|
||||
stringJoiner.add(String.valueOf(b));
|
||||
}
|
||||
return sj.toString();
|
||||
return stringJoiner.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -782,11 +782,11 @@ public abstract class ObjectUtils {
|
||||
if (length == 0) {
|
||||
return EMPTY_ARRAY;
|
||||
}
|
||||
StringJoiner sj = new StringJoiner(ARRAY_ELEMENT_SEPARATOR, ARRAY_START, ARRAY_END);
|
||||
StringJoiner stringJoiner = new StringJoiner(ARRAY_ELEMENT_SEPARATOR, ARRAY_START, ARRAY_END);
|
||||
for (char c : array) {
|
||||
sj.add('\'' + String.valueOf(c) + '\'');
|
||||
stringJoiner.add('\'' + String.valueOf(c) + '\'');
|
||||
}
|
||||
return sj.toString();
|
||||
return stringJoiner.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -806,11 +806,11 @@ public abstract class ObjectUtils {
|
||||
if (length == 0) {
|
||||
return EMPTY_ARRAY;
|
||||
}
|
||||
StringJoiner sj = new StringJoiner(ARRAY_ELEMENT_SEPARATOR, ARRAY_START, ARRAY_END);
|
||||
StringJoiner stringJoiner = new StringJoiner(ARRAY_ELEMENT_SEPARATOR, ARRAY_START, ARRAY_END);
|
||||
for (double d : array) {
|
||||
sj.add(String.valueOf(d));
|
||||
stringJoiner.add(String.valueOf(d));
|
||||
}
|
||||
return sj.toString();
|
||||
return stringJoiner.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -830,11 +830,11 @@ public abstract class ObjectUtils {
|
||||
if (length == 0) {
|
||||
return EMPTY_ARRAY;
|
||||
}
|
||||
StringJoiner sj = new StringJoiner(ARRAY_ELEMENT_SEPARATOR, ARRAY_START, ARRAY_END);
|
||||
StringJoiner stringJoiner = new StringJoiner(ARRAY_ELEMENT_SEPARATOR, ARRAY_START, ARRAY_END);
|
||||
for (float f : array) {
|
||||
sj.add(String.valueOf(f));
|
||||
stringJoiner.add(String.valueOf(f));
|
||||
}
|
||||
return sj.toString();
|
||||
return stringJoiner.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -854,11 +854,11 @@ public abstract class ObjectUtils {
|
||||
if (length == 0) {
|
||||
return EMPTY_ARRAY;
|
||||
}
|
||||
StringJoiner sj = new StringJoiner(ARRAY_ELEMENT_SEPARATOR, ARRAY_START, ARRAY_END);
|
||||
StringJoiner stringJoiner = new StringJoiner(ARRAY_ELEMENT_SEPARATOR, ARRAY_START, ARRAY_END);
|
||||
for (int i : array) {
|
||||
sj.add(String.valueOf(i));
|
||||
stringJoiner.add(String.valueOf(i));
|
||||
}
|
||||
return sj.toString();
|
||||
return stringJoiner.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -878,11 +878,11 @@ public abstract class ObjectUtils {
|
||||
if (length == 0) {
|
||||
return EMPTY_ARRAY;
|
||||
}
|
||||
StringJoiner sj = new StringJoiner(ARRAY_ELEMENT_SEPARATOR, ARRAY_START, ARRAY_END);
|
||||
StringJoiner stringJoiner = new StringJoiner(ARRAY_ELEMENT_SEPARATOR, ARRAY_START, ARRAY_END);
|
||||
for (long l : array) {
|
||||
sj.add(String.valueOf(l));
|
||||
stringJoiner.add(String.valueOf(l));
|
||||
}
|
||||
return sj.toString();
|
||||
return stringJoiner.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -902,11 +902,11 @@ public abstract class ObjectUtils {
|
||||
if (length == 0) {
|
||||
return EMPTY_ARRAY;
|
||||
}
|
||||
StringJoiner sj = new StringJoiner(ARRAY_ELEMENT_SEPARATOR, ARRAY_START, ARRAY_END);
|
||||
StringJoiner stringJoiner = new StringJoiner(ARRAY_ELEMENT_SEPARATOR, ARRAY_START, ARRAY_END);
|
||||
for (short s : array) {
|
||||
sj.add(String.valueOf(s));
|
||||
stringJoiner.add(String.valueOf(s));
|
||||
}
|
||||
return sj.toString();
|
||||
return stringJoiner.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user