Beispiel #1
0
 @Override
 public ShareFolderJobStatus deserialize(JsonParser p) throws IOException, JsonParseException {
   ShareFolderJobStatus 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 ("in_progress".equals(tag)) {
     value = ShareFolderJobStatus.IN_PROGRESS;
   } else if ("complete".equals(tag)) {
     SharedFolderMetadata fieldValue = null;
     fieldValue = SharedFolderMetadata.Serializer.INSTANCE.deserialize(p, true);
     value = ShareFolderJobStatus.complete(fieldValue);
   } else if ("failed".equals(tag)) {
     ShareFolderError fieldValue = null;
     expectField("failed", p);
     fieldValue = ShareFolderError.Serializer.INSTANCE.deserialize(p);
     value = ShareFolderJobStatus.failed(fieldValue);
   } else {
     throw new JsonParseException(p, "Unknown tag: " + tag);
   }
   if (!collapsed) {
     expectEndObject(p);
   }
   return value;
 }
Beispiel #2
0
 @Override
 public void serialize(ShareFolderJobStatus value, JsonGenerator g)
     throws IOException, JsonGenerationException {
   switch (value.tag()) {
     case IN_PROGRESS:
       {
         g.writeString("in_progress");
         break;
       }
     case COMPLETE:
       {
         g.writeStartObject();
         writeTag("complete", g);
         SharedFolderMetadata.Serializer.INSTANCE.serialize(value.completeValue, g, true);
         g.writeEndObject();
         break;
       }
     case FAILED:
       {
         g.writeStartObject();
         writeTag("failed", g);
         g.writeFieldName("failed");
         ShareFolderError.Serializer.INSTANCE.serialize(value.failedValue, g);
         g.writeEndObject();
         break;
       }
     default:
       {
         throw new IllegalArgumentException("Unrecognized tag: " + value.tag());
       }
   }
 }