/**
   * Unmarshal.
   *
   * @param parser the parser
   * @param idNull the id null
   * @param expectedClass the expected class
   * @return the id
   * @throws IOException Signals that an I/O exception has occurred.
   */
  public static Id unmarshal(JsonParser parser, @Nullable Id idNull, Class<Id> expectedClass)
      throws IOException {
    JsonToken token = parser.getCurrentToken();
    if (token == JsonToken.VALUE_EMBEDDED_OBJECT) {
      ObjectId objectId = (ObjectId) parser.getEmbeddedObject();
      return Id.of(objectId.getTime(), objectId.getMachine(), objectId.getInc());
    }

    return Id.fromString(parser.getText());
  }
  /**
   * Unmarshal.
   *
   * @param parser the parser
   * @param instantNull the instant null
   * @param expectedClass the expected class
   * @return the time instant
   * @throws IOException Signals that an I/O exception has occurred.
   */
  public static TimeInstant unmarshal(
      JsonParser parser, @Nullable TimeInstant instantNull, Class<TimeInstant> expectedClass)
      throws IOException {

    JsonToken token = parser.getCurrentToken();
    if (token == JsonToken.VALUE_EMBEDDED_OBJECT) {
      Date date = (Date) parser.getEmbeddedObject();
      return TimeInstant.of(date.getTime());
    }

    return TimeInstant.of(parser.getLongValue());
  }
 {
     jsonparser = ((JsonParser) (jsonparser.getEmbeddedObject()));
     if (jsonparser == null)
     {
         return null;
     }
     if (jsonparser instanceof byte[])
     {
         return Base64Variants.getDefaultVariant().encode((byte[])(byte[])jsonparser, false);
     } else
     {
         return jsonparser.toString();
     }
 }
 @Override
 public JSONObject deserialize(JsonParser jp, DeserializationContext ctxt)
     throws IOException, JsonProcessingException {
   JSONObject ob = new JSONObject();
   JsonToken t = jp.getCurrentToken();
   if (t == JsonToken.START_OBJECT) {
     t = jp.nextToken();
   }
   for (; t == JsonToken.FIELD_NAME; t = jp.nextToken()) {
     String fieldName = jp.getCurrentName();
     t = jp.nextToken();
     try {
       switch (t) {
         case START_ARRAY:
           ob.put(fieldName, JSONArrayDeserializer.instance.deserialize(jp, ctxt));
           continue;
         case START_OBJECT:
           ob.put(fieldName, deserialize(jp, ctxt));
           continue;
         case VALUE_STRING:
           ob.put(fieldName, jp.getText());
           continue;
         case VALUE_NULL:
           ob.put(fieldName, JSONObject.NULL);
           continue;
         case VALUE_TRUE:
           ob.put(fieldName, Boolean.TRUE);
           continue;
         case VALUE_FALSE:
           ob.put(fieldName, Boolean.FALSE);
           continue;
         case VALUE_NUMBER_INT:
           ob.put(fieldName, jp.getNumberValue());
           continue;
         case VALUE_NUMBER_FLOAT:
           ob.put(fieldName, jp.getNumberValue());
           continue;
         case VALUE_EMBEDDED_OBJECT:
           ob.put(fieldName, jp.getEmbeddedObject());
           continue;
       }
     } catch (JSONException e) {
       throw ctxt.mappingException("Failed to construct JSONObject: " + e.getMessage());
     }
     throw ctxt.mappingException("Urecognized or unsupported JsonToken type: " + t);
   }
   return ob;
 }
 public byte[] deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
 {
   JsonToken localJsonToken1 = paramJsonParser.getCurrentToken();
   if (localJsonToken1 == JsonToken.VALUE_STRING)
     return paramJsonParser.getBinaryValue(paramDeserializationContext.getBase64Variant());
   if (localJsonToken1 == JsonToken.VALUE_EMBEDDED_OBJECT)
   {
     Object localObject2 = paramJsonParser.getEmbeddedObject();
     if (localObject2 == null)
       return null;
     if ((localObject2 instanceof byte[]))
       return (byte[])localObject2;
   }
   if (!paramJsonParser.isExpectedStartArrayToken())
     return handleNonArray(paramJsonParser, paramDeserializationContext);
   ArrayBuilders.ByteBuilder localByteBuilder = paramDeserializationContext.getArrayBuilders().getByteBuilder();
   Object localObject1 = (byte[])localByteBuilder.resetAndStart();
   int i = 0;
   JsonToken localJsonToken2 = paramJsonParser.nextToken();
   int j;
   label130: int k;
   if (localJsonToken2 != JsonToken.END_ARRAY)
     if ((localJsonToken2 == JsonToken.VALUE_NUMBER_INT) || (localJsonToken2 == JsonToken.VALUE_NUMBER_FLOAT))
     {
       j = paramJsonParser.getByteValue();
       if (i < localObject1.length)
         break label214;
       byte[] arrayOfByte = (byte[])localByteBuilder.appendCompletedChunk(localObject1, i);
       k = 0;
       localObject1 = arrayOfByte;
     }
   while (true)
   {
     i = k + 1;
     localObject1[k] = j;
     break;
     if (localJsonToken2 != JsonToken.VALUE_NULL)
       throw paramDeserializationContext.mappingException(this._valueClass.getComponentType());
     j = 0;
     break label130;
     return (byte[])localByteBuilder.completeAndClearBuffer(localObject1, i);
     label214: k = i;
   }
 }
 public char[] deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
 {
   JsonToken localJsonToken1 = paramJsonParser.getCurrentToken();
   if (localJsonToken1 == JsonToken.VALUE_STRING)
   {
     char[] arrayOfChar1 = paramJsonParser.getTextCharacters();
     int i = paramJsonParser.getTextOffset();
     int j = paramJsonParser.getTextLength();
     char[] arrayOfChar2 = new char[j];
     System.arraycopy(arrayOfChar1, i, arrayOfChar2, 0, j);
     return arrayOfChar2;
   }
   if (paramJsonParser.isExpectedStartArrayToken())
   {
     StringBuilder localStringBuilder = new StringBuilder(64);
     while (true)
     {
       JsonToken localJsonToken2 = paramJsonParser.nextToken();
       if (localJsonToken2 == JsonToken.END_ARRAY)
         break;
       if (localJsonToken2 != JsonToken.VALUE_STRING)
         throw paramDeserializationContext.mappingException(Character.TYPE);
       String str = paramJsonParser.getText();
       if (str.length() != 1)
         throw JsonMappingException.from(paramJsonParser, "Can not convert a JSON String of length " + str.length() + " into a char element of char array");
       localStringBuilder.append(str.charAt(0));
     }
     return localStringBuilder.toString().toCharArray();
   }
   if (localJsonToken1 == JsonToken.VALUE_EMBEDDED_OBJECT)
   {
     Object localObject = paramJsonParser.getEmbeddedObject();
     if (localObject == null)
       return null;
     if ((localObject instanceof char[]))
       return (char[])localObject;
     if ((localObject instanceof String))
       return ((String)localObject).toCharArray();
     if ((localObject instanceof byte[]))
       return Base64Variants.getDefaultVariant().encode((byte[])localObject, false).toCharArray();
   }
   throw paramDeserializationContext.mappingException(this._valueClass);
 }
 @Override
 public JSONArray deserialize(JsonParser jp, DeserializationContext ctxt)
     throws IOException, JsonProcessingException {
   JSONArray array = new JSONArray();
   JsonToken t;
   while ((t = jp.nextToken()) != JsonToken.END_ARRAY) {
     switch (t) {
       case START_ARRAY:
         array.put(deserialize(jp, ctxt));
         continue;
       case START_OBJECT:
         array.put(JSONObjectDeserializer.instance.deserialize(jp, ctxt));
         continue;
       case VALUE_STRING:
         array.put(jp.getText());
         continue;
       case VALUE_NULL:
         array.put(JSONObject.NULL);
         continue;
       case VALUE_TRUE:
         array.put(Boolean.TRUE);
         continue;
       case VALUE_FALSE:
         array.put(Boolean.FALSE);
         continue;
       case VALUE_NUMBER_INT:
         array.put(jp.getNumberValue());
         continue;
       case VALUE_NUMBER_FLOAT:
         array.put(jp.getNumberValue());
         continue;
       case VALUE_EMBEDDED_OBJECT:
         array.put(jp.getEmbeddedObject());
         continue;
     }
     throw ctxt.mappingException("Urecognized or unsupported JsonToken type: " + t);
   }
   return array;
 }
 @Override
 public String deserialize(JsonParser jp, DeserializationContext ctxt)
     throws IOException, JsonProcessingException {
   // 22-Sep-2012, tatu: For 2.1, use this new method, may force coercion:
   String text = jp.getValueAsString();
   if (text != null) {
     return text;
   }
   // [JACKSON-330]: need to gracefully handle byte[] data, as base64
   JsonToken curr = jp.getCurrentToken();
   if (curr == JsonToken.VALUE_EMBEDDED_OBJECT) {
     Object ob = jp.getEmbeddedObject();
     if (ob == null) {
       return null;
     }
     if (ob instanceof byte[]) {
       return Base64Variants.getDefaultVariant().encode((byte[]) ob, false);
     }
     // otherwise, try conversion using toString()...
     return ob.toString();
   }
   throw ctxt.mappingException(_valueClass, curr);
 }
 @Override
 public OffsetTime deserialize(JsonParser parser, DeserializationContext context)
     throws IOException {
   if (parser.hasToken(JsonToken.VALUE_STRING)) {
     String string = parser.getText().trim();
     if (string.length() == 0) {
       return null;
     }
     try {
       return OffsetTime.parse(string, _formatter);
     } catch (DateTimeException e) {
       _rethrowDateTimeException(parser, context, e, string);
     }
   }
   if (!parser.isExpectedStartArrayToken()) {
     if (parser.hasToken(JsonToken.VALUE_EMBEDDED_OBJECT)) {
       return (OffsetTime) parser.getEmbeddedObject();
     }
     throw context.wrongTokenException(parser, JsonToken.START_ARRAY, "Expected array or string.");
   }
   int hour = parser.nextIntValue(-1);
   if (hour == -1) {
     JsonToken t = parser.getCurrentToken();
     if (t == JsonToken.END_ARRAY) {
       return null;
     }
     if (t != JsonToken.VALUE_NUMBER_INT) {
       _reportWrongToken(parser, context, JsonToken.VALUE_NUMBER_INT, "hours");
     }
     hour = parser.getIntValue();
   }
   int minute = parser.nextIntValue(-1);
   if (minute == -1) {
     JsonToken t = parser.getCurrentToken();
     if (t == JsonToken.END_ARRAY) {
       return null;
     }
     if (t != JsonToken.VALUE_NUMBER_INT) {
       _reportWrongToken(parser, context, JsonToken.VALUE_NUMBER_INT, "minutes");
     }
     minute = parser.getIntValue();
   }
   int partialSecond = 0;
   int second = 0;
   if (parser.nextToken() == JsonToken.VALUE_NUMBER_INT) {
     second = parser.getIntValue();
     if (parser.nextToken() == JsonToken.VALUE_NUMBER_INT) {
       partialSecond = parser.getIntValue();
       if (partialSecond < 1_000
           && !context.isEnabled(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)) {
         partialSecond *= 1_000_000; // value is milliseconds, convert it to nanoseconds
       }
       parser.nextToken();
     }
   }
   if (parser.getCurrentToken() == JsonToken.VALUE_STRING) {
     OffsetTime t =
         OffsetTime.of(hour, minute, second, partialSecond, ZoneOffset.of(parser.getText()));
     if (parser.nextToken() != JsonToken.END_ARRAY) {
       _reportWrongToken(parser, context, JsonToken.END_ARRAY, "timezone");
     }
     return t;
   }
   throw context.wrongTokenException(
       parser, JsonToken.VALUE_STRING, "Expected string for TimeZone after numeric values");
 }
 public T deserialize(
     JsonParser paramJsonParser, DeserializationContext paramDeserializationContext)
     throws IOException {
   Object localObject;
   String str;
   if ((paramJsonParser.getCurrentToken() == JsonToken.START_ARRAY)
       && (paramDeserializationContext.isEnabled(
           DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS))) {
     paramJsonParser.nextToken();
     localObject = deserialize(paramJsonParser, paramDeserializationContext);
     if (paramJsonParser.nextToken() != JsonToken.END_ARRAY) {
       throw paramDeserializationContext.wrongTokenException(
           paramJsonParser,
           JsonToken.END_ARRAY,
           "Attempted to unwrap single value array for single '"
               + this._valueClass.getName()
               + "' value but there was more than a single value in the array");
     }
   } else {
     localObject = paramJsonParser.getValueAsString();
     if (localObject == null) {
       break label194;
     }
     if (((String) localObject).length() != 0) {
       str = ((String) localObject).trim();
       if (str.length() != 0) {
         break label118;
       }
     }
     localObject = _deserializeFromEmptyString();
   }
   return (T) localObject;
   label118:
   paramJsonParser = null;
   try {
     localObject = _deserialize(str, paramDeserializationContext);
     if (localObject != null) {
       return (T) localObject;
     }
   } catch (IllegalArgumentException paramJsonParser) {
     localObject = "not a valid textual representation";
     if (paramJsonParser != null) {
       localObject =
           "not a valid textual representation" + "problem: " + paramJsonParser.getMessage();
     }
     paramDeserializationContext =
         paramDeserializationContext.weirdStringException(
             str, this._valueClass, (String) localObject);
     if (paramJsonParser != null) {
       paramDeserializationContext.initCause(paramJsonParser);
     }
     throw paramDeserializationContext;
   }
   label194:
   if (paramJsonParser.getCurrentToken() == JsonToken.VALUE_EMBEDDED_OBJECT) {
     paramJsonParser = paramJsonParser.getEmbeddedObject();
     if (paramJsonParser == null) {
       return null;
     }
     if (this._valueClass.isAssignableFrom(paramJsonParser.getClass())) {
       return paramJsonParser;
     }
     return (T) _deserializeEmbedded(paramJsonParser, paramDeserializationContext);
   }
   throw paramDeserializationContext.mappingException(this._valueClass);
 }
 /**
  * Method for copying contents of the current event that the given parser instance points to. Note
  * that the method <b>will not</b> copy any other events, such as events contained within Json
  * Array or Object structures.
  *
  * <p>Calling this method will not advance the given parser, although it may cause parser to
  * internally process more data (if it lazy loads contents of value events, for example)
  */
 @Override
 public void copyCurrentEvent(JsonParser jp) throws IOException, JsonProcessingException {
   switch (jp.getCurrentToken()) {
     case START_OBJECT:
       writeStartObject();
       break;
     case END_OBJECT:
       writeEndObject();
       break;
     case START_ARRAY:
       writeStartArray();
       break;
     case END_ARRAY:
       writeEndArray();
       break;
     case FIELD_NAME:
       writeFieldName(jp.getCurrentName());
       break;
     case VALUE_STRING:
       writeString(jp.getText());
       break;
     case VALUE_NUMBER_INT:
       switch (jp.getNumberType()) {
         case INT:
           writeNumber(jp.getIntValue());
           break;
         case BIG_INTEGER:
           writeNumber(jp.getBigIntegerValue());
           break;
         default:
           writeNumber(jp.getLongValue());
       }
       break;
     case VALUE_NUMBER_FLOAT:
       switch (jp.getNumberType()) {
         case BIG_DECIMAL:
           writeNumber(jp.getDecimalValue());
           break;
         case FLOAT:
           writeNumber(jp.getFloatValue());
           break;
         default:
           writeNumber(jp.getDoubleValue());
       }
       break;
     case VALUE_TRUE:
       writeBoolean(true);
       break;
     case VALUE_FALSE:
       writeBoolean(false);
       break;
     case VALUE_NULL:
       writeNull();
       break;
     case VALUE_EMBEDDED_OBJECT:
       writeObject(jp.getEmbeddedObject());
       break;
     default:
       throw new IllegalStateException();
   }
 }