1515 */
1616package org .utplsql .sqldev .model ;
1717
18+ import java .lang .reflect .Method ;
1819import java .util .Collection ;
1920import java .util .List ;
2021import java .util .Map ;
@@ -34,48 +35,51 @@ public class UtplsqlValueStyler extends DefaultValueStyler {
3435 private static final String MAP = "map" ;
3536 private static final String EMPTY_MAP = MAP + EMPTY ;
3637 private static final String ARRAY = "array" ;
37-
38+
3839 @ Override
3940 public String style (@ Nullable Object value ) {
4041 if (value == null ) {
4142 return super .style (value );
43+ } else if (value instanceof String ) {
44+ return super .style (value );
45+ } else if (value instanceof Class ) {
46+ return super .style (value );
47+ } else if (value instanceof Method ) {
48+ return super .style (value );
4249 } else if (value instanceof Map ) {
43- return styleMap ((Map <?, ?>) value );
50+ return style ((Map <?, ?>) value );
4451 } else if (value instanceof Map .Entry ) {
45- return styleMapEntry ((Map .Entry <?, ?>) value );
52+ return style ((Map .Entry <?, ?>) value );
4653 } else if (value instanceof Collection ) {
47- return styleCollection ((Collection <?>) value );
54+ return style ((Collection <?>) value );
4855 } else if (value .getClass ().isArray ()) {
49- return styleArray (ObjectUtils .toObjectArray (value ));
56+ return style (ObjectUtils .toObjectArray (value ));
5057 } else {
5158 return super .style (value );
5259 }
5360 }
5461
55- private <K , V > String styleMap (Map <K , V > value ) {
62+ private <K , V > String style (Map <K , V > value ) {
5663 if (value .isEmpty ()) {
5764 return EMPTY_MAP ;
5865 }
59-
60- StringJoiner result = new StringJoiner (",\n " , "[" , "]" );
66+ StringJoiner result = new StringJoiner (",\n " , "[\n " , "]" );
6167 for (Map .Entry <K , V > entry : value .entrySet ()) {
62- result .add (styleMapEntry (entry ));
68+ result .add (style (entry ));
6369 }
6470 return MAP + result ;
6571 }
6672
67- private String styleMapEntry (Map .Entry <?, ?> value ) {
73+ private String style (Map .Entry <?, ?> value ) {
6874 return style (value .getKey ()) + " -> " + style (value .getValue ());
6975 }
7076
71- private String styleCollection (Collection <?> value ) {
77+ private String style (Collection <?> value ) {
7278 String collectionType = getCollectionTypeString (value );
73-
7479 if (value .isEmpty ()) {
7580 return collectionType + EMPTY ;
7681 }
77-
78- StringJoiner result = new StringJoiner (",\n " , "[" , "]" );
82+ StringJoiner result = new StringJoiner (",\n " , "[\n " , "]" );
7983 for (Object o : value ) {
8084 result .add (style (o ));
8185 }
@@ -92,16 +96,14 @@ private String getCollectionTypeString(Collection<?> value) {
9296 }
9397 }
9498
95- private String styleArray (Object [] array ) {
99+ private String style (Object [] array ) {
96100 if (array .length == 0 ) {
97101 return ARRAY + '<' + ClassUtils .getShortName (array .getClass ().getComponentType ()) + '>' + EMPTY ;
98102 }
99-
100- StringJoiner result = new StringJoiner (",\n " , "[" , "]" );
103+ StringJoiner result = new StringJoiner (",\n " , "[\n " , "]" );
101104 for (Object o : array ) {
102105 result .add (style (o ));
103106 }
104107 return ARRAY + '<' + ClassUtils .getShortName (array .getClass ().getComponentType ()) + '>' + result ;
105108 }
106-
107109}
0 commit comments