deleted unused visitCollectionField method in the visitor. All of this functionality has now been replaced with the default CollectionTypeAdapter
This commit is contained in:
parent
0b6bbaf5f1
commit
bcd1baefd5
|
@ -106,10 +106,6 @@ final class JsonArrayDeserializationVisitor<T> extends JsonDeserializationVisito
|
|||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void visitCollectionField(Field f, Type typeOfF, Object obj) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void visitObjectField(Field f, Type typeOfF, Object obj) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
|
|
@ -76,32 +76,6 @@ final class JsonObjectDeserializationVisitor<T> extends JsonDeserializationVisit
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void visitCollectionField(Field f, Type typeOfF, Object obj) {
|
||||
try {
|
||||
JsonObject jsonObject = json.getAsJsonObject();
|
||||
String fName = getFieldName(f);
|
||||
JsonArray jsonArray = (JsonArray) jsonObject.get(fName);
|
||||
if (jsonArray != null) {
|
||||
Collection collection = (Collection) objectConstructor.construct(typeOfF);
|
||||
f.set(obj, collection);
|
||||
Type childType = TypeUtils.getActualTypeForFirstTypeVariable(typeOfF);
|
||||
for (JsonElement jsonChild : jsonArray) {
|
||||
Object child = visitChild(childType, jsonChild);
|
||||
if (childType == Object.class) {
|
||||
throw new JsonParseException(fName +
|
||||
" can not be a raw collection. Try making it a genericized collection instead");
|
||||
}
|
||||
collection.add(child);
|
||||
}
|
||||
} else {
|
||||
f.set(obj, null);
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void visitArrayField(Field f, Type typeOfF, Object obj) {
|
||||
try {
|
||||
JsonObject jsonObject = json.getAsJsonObject();
|
||||
|
|
|
@ -71,11 +71,6 @@ final class JsonPrimitiveDeserializationVisitor<T> extends JsonDeserializationVi
|
|||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
public void visitCollectionField(Field f, Type typeOfF, Object obj) {
|
||||
// should not be called since this case should invoke JsonArrayDeserializationVisitor
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
public void visitArrayField(Field f, Type typeOfF, Object obj) {
|
||||
// should not be called since this case should invoke JsonArrayDeserializationVisitor
|
||||
throw new IllegalStateException();
|
||||
|
|
|
@ -77,20 +77,6 @@ final class JsonSerializationVisitor implements ObjectNavigator.Visitor {
|
|||
}
|
||||
}
|
||||
|
||||
public void visitCollectionField(Field f, Type typeOfF, Object obj) {
|
||||
if (isFieldNull(f, obj)) {
|
||||
if (serializeNulls) {
|
||||
addChildAsElement(f, JsonNull.INSTANCE);
|
||||
}
|
||||
} else {
|
||||
if (typeOfF == null) {
|
||||
throw new RuntimeException("Can not handle non-generic collections");
|
||||
}
|
||||
Object collection = getFieldValue(f, obj);
|
||||
addAsChildOfObject(f, typeOfF, collection);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void visitEnum(Object obj, Type objType) {
|
||||
JsonSerializer serializer = serializers.getHandlerFor(objType);
|
||||
|
|
|
@ -54,11 +54,6 @@ final class ObjectNavigator {
|
|||
*/
|
||||
void visitObjectField(Field f, Type typeOfF, Object obj);
|
||||
|
||||
/**
|
||||
* This is called to visit a field of type Collection of the current object
|
||||
*/
|
||||
void visitCollectionField(Field f, Type typeOfF, Object obj);
|
||||
|
||||
/**
|
||||
* This is called to visit an array field of the current object
|
||||
*/
|
||||
|
@ -165,12 +160,8 @@ final class ObjectNavigator {
|
|||
boolean visitedWithCustomHandler =
|
||||
visitor.visitFieldUsingCustomHandler(f, actualTypeOfField, obj);
|
||||
if (!visitedWithCustomHandler) {
|
||||
if (fieldTypeInfo.isCollectionOrArray()) {
|
||||
if (fieldTypeInfo.isArray()) {
|
||||
visitor.visitArrayField(f, actualTypeOfField, obj);
|
||||
} else { // must be Collection
|
||||
visitor.visitCollectionField(f, actualTypeOfField, obj);
|
||||
}
|
||||
if (fieldTypeInfo.isArray()) {
|
||||
visitor.visitArrayField(f, actualTypeOfField, obj);
|
||||
} else if (fieldTypeInfo.isPrimitiveOrStringAndNotAnArray()) {
|
||||
visitor.visitPrimitiveField(f, actualTypeOfField, obj);
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue
Block a user