private Object getFieldValue(FieldAttributes f, Object obj) { try { return f.get(obj); } catch (IllegalAccessException e) { throw new RuntimeException(e); } }
@SuppressWarnings("unchecked") private static Type getMoreSpecificType(Type type, Object obj, FieldAttributes fieldAttributes) { try { if (obj != null && (Object.class == type || type instanceof TypeVariable)) { Object fieldValue = fieldAttributes.get(obj); if (fieldValue != null) { type = fieldValue.getClass(); } } } catch (IllegalAccessException e) { } return type; }
public boolean visitFieldUsingCustomHandler( FieldAttributes f, Type declaredTypeOfField, Object parent) { try { $Gson$Preconditions.checkState(root.isJsonObject()); Object obj = f.get(parent); if (obj == null) { if (serializeNulls) { addChildAsElement(f, JsonNull.INSTANCE); } return true; } ObjectTypePair objTypePair = new ObjectTypePair(obj, declaredTypeOfField, false, false); JsonElement child = findAndInvokeCustomSerializer(objTypePair); if (child != null) { addChildAsElement(f, child); return true; } return false; } catch (IllegalAccessException e) { throw new RuntimeException(); } catch (CircularReferenceException e) { throw e.createDetailedException(f); } }