code: void writeSimple(Class<?> declaredType, Object value) throws IOException {
          // simple types have no need to write a type object
          Class<?> realType = value.getClass();
          if (realType == Integer.class) {
              output.writeInt(((Integer) value).intValue());
              return;
          } else if (realType == Double.class) {
              output.writeDouble(((Double) value).doubleValue());
              return;
          } else if (realType == Float.class) {
              output.writeFloat(((Float) value).floatValue());
              return;
          } else if (realType == Boolean.class) {
              output.writeBoolean(((Boolean) value).booleanValue());
              return;
          }
  
          // handle no declared type and subclasses
          Class<?> effectiveType = getAndSerializeEffectiveTypeIfRequired(value, declaredType);
  
          // long/short/byte only processed now to ensure that a distinction can be made between Integer and Long
          if (realType == Long.class) {
              output.writeLong(((Long) value).longValue());
              return;
          } else if (realType == Short.class) {
              output.writeInt(((Short) value).shortValue());
              return;
          } else if (realType == Byte.class) {
              output.writeInt(((Byte) value).byteValue());
              return;
          } else if (realType == byte[].class) {
              output.writeBytes((byte[]) value);
              return;
          }
  
          // write as a string
          try {
              writeObjectAsString(value, effectiveType);
          } catch (RuntimeException ex) {
              throw new IllegalArgumentException("Unable to convert type " + effectiveType.getName() + " declared as " + declaredType.getName(), ex);
          }
      }
docs: -----------------------------------------------------------------------