public static Type getValueOf(final String text) { Type[] values = values(); for (final Type value : values) { if (value.text.equals(text)) { return value; } } throw new IllegalArgumentException(text + " is not a valid account type."); }
@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(); }
@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; }
public static String writeAccountType(final Account.Type type) { return type.toString(); }
public static Account.Type readAccountType(final Object object) { if (object != null) { return Account.Type.getValueOf((String) object); } else { return null; } }