|
@@ -59,9 +59,12 @@ public final class DataFormatUtil {
|
|
|
}
|
|
|
|
|
|
public static String toString(Object source) {
|
|
|
- if (Objects.isNull(source)) return null;
|
|
|
- if (source instanceof String || source instanceof Number)
|
|
|
+ if (Objects.isNull(source)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (source instanceof String || source instanceof Number) {
|
|
|
return source.toString();
|
|
|
+ }
|
|
|
if (source instanceof LocalDate result) {
|
|
|
return result.format(dateTimeFormatter);
|
|
|
}
|
|
@@ -123,7 +126,9 @@ public final class DataFormatUtil {
|
|
|
}
|
|
|
|
|
|
public static Map<?, ?> toMap(Object value) {
|
|
|
- if (Objects.isNull(value)) return null;
|
|
|
+ if (Objects.isNull(value)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
if (value instanceof Map<?, ?> map) {
|
|
|
return map;
|
|
|
}
|
|
@@ -135,17 +140,17 @@ public final class DataFormatUtil {
|
|
|
return stringToMap(str);
|
|
|
} catch (JsonProcessingException e) {
|
|
|
try {
|
|
|
- return new HashMap<>() {{
|
|
|
- put("root", toJsonNode(str));
|
|
|
- }};
|
|
|
+ HashMap<Object, Object> data = new HashMap<>();
|
|
|
+ data.put("root", toJsonNode(str));
|
|
|
+ return data;
|
|
|
} catch (JsonProcessingException ex) {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return new HashMap<>() {{
|
|
|
- put("root", value);
|
|
|
- }};
|
|
|
+ HashMap<Object, Object> data = new HashMap<>();
|
|
|
+ data.put("root", value);
|
|
|
+ return data;
|
|
|
}
|
|
|
}
|