All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.clinia.model.registry.V1BulkResponse Maven / Gradle / Ivy

// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost
// - read more on https://github.com/clinia/api-clients-generation. DO NOT EDIT.

package com.clinia.model.registry;

import com.clinia.exceptions.CliniaRuntimeException;
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.annotation.*;
import java.io.IOException;
import java.util.logging.Logger;

/** V1BulkResponse */
@JsonDeserialize(using = V1BulkResponse.Deserializer.class)
public interface V1BulkResponse {
  class Deserializer extends JsonDeserializer {

    private static final Logger LOGGER = Logger.getLogger(Deserializer.class.getName());

    @Override
    public V1BulkResponse deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
      JsonNode tree = jp.readValueAsTree();
      // deserialize V1BulkSuccessResponse
      if (tree.isObject()) {
        try (JsonParser parser = tree.traverse(jp.getCodec())) {
          return parser.readValueAs(V1BulkSuccessResponse.class);
        } catch (Exception e) {
          // deserialization failed, continue
          LOGGER.finest("Failed to deserialize oneOf V1BulkSuccessResponse (error: " + e.getMessage() + ") (type: V1BulkSuccessResponse)");
        }
      }
      // deserialize V1BulkFailureResponse
      if (tree.isObject()) {
        try (JsonParser parser = tree.traverse(jp.getCodec())) {
          return parser.readValueAs(V1BulkFailureResponse.class);
        } catch (Exception e) {
          // deserialization failed, continue
          LOGGER.finest("Failed to deserialize oneOf V1BulkFailureResponse (error: " + e.getMessage() + ") (type: V1BulkFailureResponse)");
        }
      }
      throw new CliniaRuntimeException(String.format("Failed to deserialize json element: %s", tree));
    }

    /** Handle deserialization of the 'null' value. */
    @Override
    public V1BulkResponse getNullValue(DeserializationContext ctxt) throws JsonMappingException {
      throw new JsonMappingException(ctxt.getParser(), "V1BulkResponse cannot be null");
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy