code: private <L, R> TypeAdapter<Xor<L, R>> xorAdapter(TypeAdapter<L> leftAdapter,
              TypeAdapter<R> rightAdapter) {
          return new TypeAdapter<Xor<L, R>>() {
              @Override
              public Xor<L, R> read(JsonReader in) throws IOException {
                  JsonElement json = TypeAdapters.JSON_ELEMENT.read(in);
                  try {
                      R value = rightAdapter.fromJsonTree(json);
                      return Xor.right(value);
                  } catch (Throwable e) {
                      L value = leftAdapter.fromJsonTree(json);
                      return Xor.left(value);
                  }
              }
  
              @Override
              public void write(JsonWriter out, Xor<L, R> xor) throws IOException {
                  throw new JsonParseException("Writing Xor is not supported");
              }
          };
      }
docs: Creates a generic Xor adapter by combining two other adapters - one for each side of
  the Xor type. It will first try to parse incoming JSON data as the right type and, if
  that does not succeed, it will try again with the left type.
  
  All exceptions besides the possible parsing Exception of the left type are not
  caught.
  
  @param <L> the generic type for the left side of the Xor
  @param <R> the generic type for the right side of the Xor
  @param leftAdapter the left adapter
  @param rightAdapter the right adapter
  @return the Xor adapter