Example #1
0
 @Override
 public FileMemberRemoveActionResult deserialize(JsonParser p)
     throws IOException, JsonParseException {
   FileMemberRemoveActionResult value;
   boolean collapsed;
   String tag;
   if (p.getCurrentToken() == JsonToken.VALUE_STRING) {
     collapsed = true;
     tag = getStringValue(p);
     p.nextToken();
   } else {
     collapsed = false;
     expectStartObject(p);
     tag = readTag(p);
   }
   if (tag == null) {
     throw new JsonParseException(p, "Required field missing: " + TAG_FIELD);
   } else if ("success".equals(tag)) {
     MemberAccessLevelResult fieldValue = null;
     fieldValue = MemberAccessLevelResult.Serializer.INSTANCE.deserialize(p, true);
     value = FileMemberRemoveActionResult.success(fieldValue);
   } else if ("member_error".equals(tag)) {
     FileMemberActionError fieldValue = null;
     expectField("member_error", p);
     fieldValue = FileMemberActionError.Serializer.INSTANCE.deserialize(p);
     value = FileMemberRemoveActionResult.memberError(fieldValue);
   } else {
     value = FileMemberRemoveActionResult.OTHER;
     skipFields(p);
   }
   if (!collapsed) {
     expectEndObject(p);
   }
   return value;
 }
Example #2
0
 @Override
 public void serialize(FileMemberRemoveActionResult value, JsonGenerator g)
     throws IOException, JsonGenerationException {
   switch (value.tag()) {
     case SUCCESS:
       {
         g.writeStartObject();
         writeTag("success", g);
         MemberAccessLevelResult.Serializer.INSTANCE.serialize(value.successValue, g, true);
         g.writeEndObject();
         break;
       }
     case MEMBER_ERROR:
       {
         g.writeStartObject();
         writeTag("member_error", g);
         g.writeFieldName("member_error");
         FileMemberActionError.Serializer.INSTANCE.serialize(value.memberErrorValue, g);
         g.writeEndObject();
         break;
       }
     default:
       {
         g.writeString("other");
       }
   }
 }