private Map<String, Object> toMap(final Account account) { final Map<String, Object> map = new HashMap<String, Object>(); map.put("sid", writeSid(account.getSid())); map.put("date_created", writeDateTime(account.getDateCreated())); map.put("date_updated", writeDateTime(account.getDateUpdated())); map.put("email_address", account.getEmailAddress()); map.put("friendly_name", account.getFriendlyName()); map.put("parent_sid", writeSid(account.getParentSid())); map.put("type", writeAccountType(account.getType())); map.put("status", writeAccountStatus(account.getStatus())); map.put("auth_token", account.getAuthToken()); map.put("role", account.getRole()); map.put("uri", writeUri(account.getUri())); map.put("organization_sid", writeSid(account.getOrganizationSid())); return map; } }
@Override public JsonElement serialize(final Account account, final Type type, final JsonSerializationContext context) { final JsonObject object = new JsonObject(); writeSid(account.getSid(), object); object.addProperty("organization", account.getOrganizationSid().toString()); writeFriendlyName(account.getFriendlyName(), object); writeEmailAddress(account, object); writeType(account.getType().toString(), object); writeStatus(account.getStatus().toString(), object); writeRoleInfo(account.getRole(), object); writeDateCreated(account.getDateCreated(), object); writeDateUpdated(account.getDateUpdated(), object); writeAuthToken(account, object); writeUri(account, object); writeSubResourceUris(account, object); return object; }
@Override public void marshal(final Object object, final HierarchicalStreamWriter writer, final MarshallingContext context) { final Account account = (Account) object; writer.startNode("Account"); writeSid(account.getSid(), writer); writer.startNode("organization"); writer.setValue(account.getOrganizationSid().toString()); writer.endNode(); writeFriendlyName(account.getFriendlyName(), writer); writeEmailAddress(account, writer); writeStatus(account.getStatus().toString(), writer); writeRoleInfo(account.getRole(), writer); writeType(account.getType().toString(), writer); writeDateCreated(account.getDateCreated(), writer); writeDateUpdated(account.getDateUpdated(), writer); writeAuthToken(account, writer); writeUri(account.getUri(), writer); writeSubResourceUris(account, writer); writer.endNode(); }