@Override public void serialize(UploadSessionLookupError value, JsonGenerator g) throws IOException, JsonGenerationException { switch (value.tag()) { case NOT_FOUND: { g.writeString("not_found"); break; } case INCORRECT_OFFSET: { g.writeStartObject(); writeTag("incorrect_offset", g); UploadSessionOffsetError.Serializer.INSTANCE.serialize( value.incorrectOffsetValue, g, true); g.writeEndObject(); break; } case CLOSED: { g.writeString("closed"); break; } case NOT_CLOSED: { g.writeString("not_closed"); break; } default: { g.writeString("other"); } } }
@Override public UploadSessionLookupError deserialize(JsonParser p) throws IOException, JsonParseException { UploadSessionLookupError 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 ("not_found".equals(tag)) { value = UploadSessionLookupError.NOT_FOUND; } else if ("incorrect_offset".equals(tag)) { UploadSessionOffsetError fieldValue = null; fieldValue = UploadSessionOffsetError.Serializer.INSTANCE.deserialize(p, true); value = UploadSessionLookupError.incorrectOffset(fieldValue); } else if ("closed".equals(tag)) { value = UploadSessionLookupError.CLOSED; } else if ("not_closed".equals(tag)) { value = UploadSessionLookupError.NOT_CLOSED; } else { value = UploadSessionLookupError.OTHER; skipFields(p); } if (!collapsed) { expectEndObject(p); } return value; }