private Object getFieldValue(FieldAttributes f, Object obj) { try { return f.get(obj); } catch (IllegalAccessException e) { throw new RuntimeException(e); } }
public boolean visitFieldUsingCustomHandler( FieldAttributes f, Type declaredTypeOfField, Object parent) { try { Preconditions.checkState(root.isJsonObject()); Object obj = f.get(parent); if (obj == null) { if (serializeNulls) { addChildAsElement(f, JsonNull.createJsonNull()); } return true; } ObjectTypePair objTypePair = new ObjectTypePair(obj, declaredTypeOfField, 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); } }