Skip to content

Commit

Permalink
Now using TypeUtilities from java-util
Browse files Browse the repository at this point in the history
  • Loading branch information
jdereg committed Feb 22, 2025
1 parent 073e526 commit b566b1d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 468 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ss.SSSZ</maven.build.timestamp.format>
<!-- remove source encoding warnings from maven output -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<version.java-util>3.0.3</version.java-util>
<version.java-util>3.1.0</version.java-util>
<!-- testing only -->
<version.junit-jupiter-params>5.11.4</version.junit-jupiter-params>
<version.assertj-core>3.27.3</version.assertj-core>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/cedarsoftware/io/JsonParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ private JsonObject readJsonObject(Type suggestedType) throws IOException {
JsonObject jObj = new JsonObject();

// Set the refined type on the JsonObject.
Type resolvedSuggestedType = TypeUtilities.resolveFieldTypeRecursivelyUsingParent(suggestedType, suggestedType);
Type resolvedSuggestedType = TypeUtilities.resolveTypeRecursivelyUsingParent(suggestedType, suggestedType);
jObj.setType(resolvedSuggestedType);

final FastReader in = input;
Expand Down Expand Up @@ -238,7 +238,7 @@ private JsonObject readJsonObject(Type suggestedType) throws IOException {
// If a field generic type is provided, resolve it using the parent's (i.e. jObj's) resolved type.
if (fieldGenericType != null) {
// Use the parent's type (which has been resolved) as context to resolve the field type.
fieldGenericType = TypeUtilities.resolveFieldTypeRecursivelyUsingParent(suggestedType, fieldGenericType);
fieldGenericType = TypeUtilities.resolveTypeRecursivelyUsingParent(suggestedType, fieldGenericType);
}
Object value = readValue(fieldGenericType);

Expand Down
10 changes: 4 additions & 6 deletions src/main/java/com/cedarsoftware/io/ObjectResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public void assignField(final JsonObject jsonObj, final Injector injector, final
jObj.setType(explicitType);
} else {
// Resolve the field type in the context of the target object.
Type resolvedFieldType = TypeUtilities.resolveFieldTypeUsingInstance(fieldType, target);
Type resolvedFieldType = TypeUtilities.resolveTypeUsingInstance(target, fieldType);
jObj.setType(resolvedFieldType);
}
}
Expand Down Expand Up @@ -253,17 +253,15 @@ protected void handleMissingField(final JsonObject jsonObj, final Object rhs,
* stores the missing field and their values to call back the handler at the end of the resolution, cause some
* reference may need to be resolved later.
*/
private void storeMissingField(Object target, String missingField, Object value)
{
private void storeMissingField(Object target, String missingField, Object value) {
missingFields.add(new Missingfields(target, missingField, value));
}

/**
* @param o Object to turn into a String
* @return .toString() version of o or "null" if o is null.
*/
private static String safeToString(Object o)
{
private static String safeToString(Object o) {
if (o == null) {
return "null";
}
Expand Down Expand Up @@ -577,7 +575,7 @@ private void markUntypedObjects(final Type type, final JsonObject rhs) {
}

// Assuming 'type' is the parent's type and 't' is the field type that needs resolution:
Type resolvedType = TypeUtilities.resolveFieldTypeRecursivelyUsingParent(type, t);
Type resolvedType = TypeUtilities.resolveTypeRecursivelyUsingParent(type, t);
stampTypeOnJsonObject(instance, resolvedType);

if (Map.class.isAssignableFrom(clazz)) {
Expand Down
Loading

0 comments on commit b566b1d

Please sign in to comment.