content: /*
   * Management API
   *
   * The version of the OpenAPI document: 3
   *
   *
   * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
   * https://openapi-generator.tech
   * Do not edit the class manually.
   */
  
  package com.adyen.model.management;
  
  import com.fasterxml.jackson.core.JsonGenerator;
  import com.fasterxml.jackson.core.JsonParser;
  import com.fasterxml.jackson.core.JsonProcessingException;
  import com.fasterxml.jackson.core.JsonToken;
  import com.fasterxml.jackson.databind.DeserializationContext;
  import com.fasterxml.jackson.databind.JsonMappingException;
  import com.fasterxml.jackson.databind.JsonNode;
  import com.fasterxml.jackson.databind.MapperFeature;
  import com.fasterxml.jackson.databind.SerializerProvider;
  import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
  import com.fasterxml.jackson.databind.annotation.JsonSerialize;
  import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
  import com.fasterxml.jackson.databind.ser.std.StdSerializer;
  import jakarta.ws.rs.core.GenericType;
  import java.io.IOException;
  import java.util.*;
  import java.util.Arrays;
  import java.util.Collections;
  import java.util.HashSet;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  
  @JsonDeserialize(
      using =
          ScheduleTerminalActionsRequestActionDetails
              .ScheduleTerminalActionsRequestActionDetailsDeserializer.class)
  @JsonSerialize(
      using =
          ScheduleTerminalActionsRequestActionDetails
              .ScheduleTerminalActionsRequestActionDetailsSerializer.class)
  public class ScheduleTerminalActionsRequestActionDetails extends AbstractOpenApiSchema {
    private static final Logger log =
        Logger.getLogger(ScheduleTerminalActionsRequestActionDetails.class.getName());
  
    public static class ScheduleTerminalActionsRequestActionDetailsSerializer
        extends StdSerializer<ScheduleTerminalActionsRequestActionDetails> {
      public ScheduleTerminalActionsRequestActionDetailsSerializer(
          Class<ScheduleTerminalActionsRequestActionDetails> t) {
        super(t);
      }
  
      public ScheduleTerminalActionsRequestActionDetailsSerializer() {
        this(null);
      }
  
      @Override
      public void serialize(
          ScheduleTerminalActionsRequestActionDetails value,
          JsonGenerator jgen,
          SerializerProvider provider)
          throws IOException, JsonProcessingException {
        jgen.writeObject(value.getActualInstance());
      }
    }
  
    public static class ScheduleTerminalActionsRequestActionDetailsDeserializer
        extends StdDeserializer<ScheduleTerminalActionsRequestActionDetails> {
      public ScheduleTerminalActionsRequestActionDetailsDeserializer() {
        this(ScheduleTerminalActionsRequestActionDetails.class);
      }
  
      public ScheduleTerminalActionsRequestActionDetailsDeserializer(Class<?> vc) {
        super(vc);
      }
  
      @Override
      public ScheduleTerminalActionsRequestActionDetails deserialize(
          JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
        JsonNode tree = jp.readValueAsTree();
        Object deserialized = null;
        boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS);
        int match = 0;
        JsonToken token = tree.traverse(jp.getCodec()).nextToken();
        // deserialize InstallAndroidAppDetails
        try {
          boolean attemptParsing = true;
          if (attemptParsing) {
            // Checks if the unique type of the oneOf json matches any of the object TypeEnum values
            boolean typeMatch = false;
            if (tree.findValue("type") != null) {
              typeMatch =
                  Arrays.stream(InstallAndroidAppDetails.TypeEnum.values())
                      .anyMatch((t) -> t.getValue().equals(tree.findValue("type").asText()));
            }
  
            if (typeMatch) {
              deserialized = tree.traverse(jp.getCodec()).readValueAs(InstallAndroidAppDetails.class);
              // TODO: there is no validation against JSON schema constraints
              // (min, max, enum, pattern...), this does not perform a strict JSON
              // validation, which means the 'match' count may be higher than it should be.
              match++;
              log.log(Level.FINER, "Input data matches schema 'InstallAndroidAppDetails'");
            }
          }
        } catch (Exception e) {
          // deserialization failed, continue
          log.log(Level.FINER, "Input data does not match schema 'InstallAndroidAppDetails'", e);
        }
  
        // deserialize InstallAndroidCertificateDetails
        try {
          boolean attemptParsing = true;
          if (attemptParsing) {
            // Checks if the unique type of the oneOf json matches any of the object TypeEnum values
            boolean typeMatch = false;
            if (tree.findValue("type") != null) {
              typeMatch =
                  Arrays.stream(InstallAndroidCertificateDetails.TypeEnum.values())
                      .anyMatch((t) -> t.getValue().equals(tree.findValue("type").asText()));
            }
  
            if (typeMatch) {
              deserialized =
                  tree.traverse(jp.getCodec()).readValueAs(InstallAndroidCertificateDetails.class);
              // TODO: there is no validation against JSON schema constraints
              // (min, max, enum, pattern...), this does not perform a strict JSON
              // validation, which means the 'match' count may be higher than it should be.
              match++;
              log.log(Level.FINER, "Input data matches schema 'InstallAndroidCertificateDetails'");
            }
          }
        } catch (Exception e) {
          // deserialization failed, continue
          log.log(
              Level.FINER, "Input data does not match schema 'InstallAndroidCertificateDetails'", e);
        }
  
        // deserialize ReleaseUpdateDetails
        try {
          boolean attemptParsing = true;
          if (attemptParsing) {
            // Checks if the unique type of the oneOf json matches any of the object TypeEnum values
            boolean typeMatch = false;
            if (tree.findValue("type") != null) {
              typeMatch =
                  Arrays.stream(ReleaseUpdateDetails.TypeEnum.values())
                      .anyMatch((t) -> t.getValue().equals(tree.findValue("type").asText()));
            }
  
            if (typeMatch) {
              deserialized = tree.traverse(jp.getCodec()).readValueAs(ReleaseUpdateDetails.class);
              // TODO: there is no validation against JSON schema constraints
              // (min, max, enum, pattern...), this does not perform a strict JSON
              // validation, which means the 'match' count may be higher than it should be.
              match++;
              log.log(Level.FINER, "Input data matches schema 'ReleaseUpdateDetails'");
            }
          }
        } catch (Exception e) {
          // deserialization failed, continue
          log.log(Level.FINER, "Input data does not match schema 'ReleaseUpdateDetails'", e);
        }
  
        // deserialize UninstallAndroidAppDetails
        try {
          boolean attemptParsing = true;
          if (attemptParsing) {
            // Checks if the unique type of the oneOf json matches any of the object TypeEnum values
            boolean typeMatch = false;
            if (tree.findValue("type") != null) {
              typeMatch =
                  Arrays.stream(UninstallAndroidAppDetails.TypeEnum.values())
                      .anyMatch((t) -> t.getValue().equals(tree.findValue("type").asText()));
            }
  
            if (typeMatch) {
              deserialized =
                  tree.traverse(jp.getCodec()).readValueAs(UninstallAndroidAppDetails.class);
              // TODO: there is no validation against JSON schema constraints
              // (min, max, enum, pattern...), this does not perform a strict JSON
              // validation, which means the 'match' count may be higher than it should be.
              match++;
              log.log(Level.FINER, "Input data matches schema 'UninstallAndroidAppDetails'");
            }
          }
        } catch (Exception e) {
          // deserialization failed, continue
          log.log(Level.FINER, "Input data does not match schema 'UninstallAndroidAppDetails'", e);
        }
  
        // deserialize UninstallAndroidCertificateDetails
        try {
          boolean attemptParsing = true;
          if (attemptParsing) {
            // Checks if the unique type of the oneOf json matches any of the object TypeEnum values
            boolean typeMatch = false;
            if (tree.findValue("type") != null) {
              typeMatch =
                  Arrays.stream(UninstallAndroidCertificateDetails.TypeEnum.values())
                      .anyMatch((t) -> t.getValue().equals(tree.findValue("type").asText()));
            }
  
            if (typeMatch) {
              deserialized =
                  tree.traverse(jp.getCodec()).readValueAs(UninstallAndroidCertificateDetails.class);
              // TODO: there is no validation against JSON schema constraints
              // (min, max, enum, pattern...), this does not perform a strict JSON
              // validation, which means the 'match' count may be higher than it should be.
              match++;
              log.log(Level.FINER, "Input data matches schema 'UninstallAndroidCertificateDetails'");
            }
          }
        } catch (Exception e) {
          // deserialization failed, continue
          log.log(
              Level.FINER,
              "Input data does not match schema 'UninstallAndroidCertificateDetails'",
              e);
        }
  
        if (match == 1) {
          ScheduleTerminalActionsRequestActionDetails ret =
              new ScheduleTerminalActionsRequestActionDetails();
          ret.setActualInstance(deserialized);
          return ret;
        }
        throw new IOException(
            String.format(
                "Failed deserialization for ScheduleTerminalActionsRequestActionDetails: %d classes match result, expected 1",
                match));
      }
  
      /** Handle deserialization of the 'null' value. */
      @Override
      public ScheduleTerminalActionsRequestActionDetails getNullValue(DeserializationContext ctxt)
          throws JsonMappingException {
        throw new JsonMappingException(
            ctxt.getParser(), "ScheduleTerminalActionsRequestActionDetails cannot be null");
      }
    }
  
    // store a list of schema names defined in oneOf
    public static final Map<String, GenericType<?>> schemas = new HashMap<>();
  
    public ScheduleTerminalActionsRequestActionDetails() {
      super("oneOf", Boolean.FALSE);
    }
  
    public ScheduleTerminalActionsRequestActionDetails(InstallAndroidAppDetails o) {
      super("oneOf", Boolean.FALSE);
      setActualInstance(o);
    }
  
    public ScheduleTerminalActionsRequestActionDetails(InstallAndroidCertificateDetails o) {
      super("oneOf", Boolean.FALSE);
      setActualInstance(o);
    }
  
    public ScheduleTerminalActionsRequestActionDetails(ReleaseUpdateDetails o) {
      super("oneOf", Boolean.FALSE);
      setActualInstance(o);
    }
  
    public ScheduleTerminalActionsRequestActionDetails(UninstallAndroidAppDetails o) {
      super("oneOf", Boolean.FALSE);
      setActualInstance(o);
    }
  
    public ScheduleTerminalActionsRequestActionDetails(UninstallAndroidCertificateDetails o) {
      super("oneOf", Boolean.FALSE);
      setActualInstance(o);
    }
  
    static {
      schemas.put("InstallAndroidAppDetails", new GenericType<InstallAndroidAppDetails>() {});
      schemas.put(
          "InstallAndroidCertificateDetails", new GenericType<InstallAndroidCertificateDetails>() {});
      schemas.put("ReleaseUpdateDetails", new GenericType<ReleaseUpdateDetails>() {});
      schemas.put("UninstallAndroidAppDetails", new GenericType<UninstallAndroidAppDetails>() {});
      schemas.put(
          "UninstallAndroidCertificateDetails",
          new GenericType<UninstallAndroidCertificateDetails>() {});
      JSON.registerDescendants(
          ScheduleTerminalActionsRequestActionDetails.class, Collections.unmodifiableMap(schemas));
    }
  
    @Override
    public Map<String, GenericType<?>> getSchemas() {
      return ScheduleTerminalActionsRequestActionDetails.schemas;
    }
  
    /**
     * Set the instance that matches the oneOf child schema, check the instance parameter is valid
     * against the oneOf child schemas: InstallAndroidAppDetails, InstallAndroidCertificateDetails,
     * ReleaseUpdateDetails, UninstallAndroidAppDetails, UninstallAndroidCertificateDetails
     *
     * <p>It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a
     * composed schema (allOf, anyOf, oneOf).
     */
    @Override
    public void setActualInstance(Object instance) {
      if (JSON.isInstanceOf(InstallAndroidAppDetails.class, instance, new HashSet<>())) {
        super.setActualInstance(instance);
        return;
      }
  
      if (JSON.isInstanceOf(InstallAndroidCertificateDetails.class, instance, new HashSet<>())) {
        super.setActualInstance(instance);
        return;
      }
  
      if (JSON.isInstanceOf(ReleaseUpdateDetails.class, instance, new HashSet<>())) {
        super.setActualInstance(instance);
        return;
      }
  
      if (JSON.isInstanceOf(UninstallAndroidAppDetails.class, instance, new HashSet<>())) {
        super.setActualInstance(instance);
        return;
      }
  
      if (JSON.isInstanceOf(UninstallAndroidCertificateDetails.class, instance, new HashSet<>())) {
        super.setActualInstance(instance);
        return;
      }
  
      throw new RuntimeException(
          "Invalid instance type. Must be InstallAndroidAppDetails, InstallAndroidCertificateDetails, ReleaseUpdateDetails, UninstallAndroidAppDetails, UninstallAndroidCertificateDetails");
    }
  
    /**
     * Get the actual instance, which can be the following: InstallAndroidAppDetails,
     * InstallAndroidCertificateDetails, ReleaseUpdateDetails, UninstallAndroidAppDetails,
     * UninstallAndroidCertificateDetails
     *
     * @return The actual instance (InstallAndroidAppDetails, InstallAndroidCertificateDetails,
     *     ReleaseUpdateDetails, UninstallAndroidAppDetails, UninstallAndroidCertificateDetails)
     */
    @Override
    public Object getActualInstance() {
      return super.getActualInstance();
    }
  
    /**
     * Get the actual instance of `InstallAndroidAppDetails`. If the actual instance is not
     * `InstallAndroidAppDetails`, the ClassCastException will be thrown.
     *
     * @return The actual instance of `InstallAndroidAppDetails`
     * @throws ClassCastException if the instance is not `InstallAndroidAppDetails`
     */
    public InstallAndroidAppDetails getInstallAndroidAppDetails() throws ClassCastException {
      return (InstallAndroidAppDetails) super.getActualInstance();
    }
  
    /**
     * Get the actual instance of `InstallAndroidCertificateDetails`. If the actual instance is not
     * `InstallAndroidCertificateDetails`, the ClassCastException will be thrown.
     *
     * @return The actual instance of `InstallAndroidCertificateDetails`
     * @throws ClassCastException if the instance is not `InstallAndroidCertificateDetails`
     */
    public InstallAndroidCertificateDetails getInstallAndroidCertificateDetails()
        throws ClassCastException {
      return (InstallAndroidCertificateDetails) super.getActualInstance();
    }
  
    /**
     * Get the actual instance of `ReleaseUpdateDetails`. If the actual instance is not
     * `ReleaseUpdateDetails`, the ClassCastException will be thrown.
     *
     * @return The actual instance of `ReleaseUpdateDetails`
     * @throws ClassCastException if the instance is not `ReleaseUpdateDetails`
     */
    public ReleaseUpdateDetails getReleaseUpdateDetails() throws ClassCastException {
      return (ReleaseUpdateDetails) super.getActualInstance();
    }
  
    /**
     * Get the actual instance of `UninstallAndroidAppDetails`. If the actual instance is not
     * `UninstallAndroidAppDetails`, the ClassCastException will be thrown.
     *
     * @return The actual instance of `UninstallAndroidAppDetails`
     * @throws ClassCastException if the instance is not `UninstallAndroidAppDetails`
     */
    public UninstallAndroidAppDetails getUninstallAndroidAppDetails() throws ClassCastException {
      return (UninstallAndroidAppDetails) super.getActualInstance();
    }
  
    /**
     * Get the actual instance of `UninstallAndroidCertificateDetails`. If the actual instance is not
     * `UninstallAndroidCertificateDetails`, the ClassCastException will be thrown.
     *
     * @return The actual instance of `UninstallAndroidCertificateDetails`
     * @throws ClassCastException if the instance is not `UninstallAndroidCertificateDetails`
     */
    public UninstallAndroidCertificateDetails getUninstallAndroidCertificateDetails()
        throws ClassCastException {
      return (UninstallAndroidCertificateDetails) super.getActualInstance();
    }
  
    /**
     * Create an instance of ScheduleTerminalActionsRequestActionDetails given an JSON string
     *
     * @param jsonString JSON string
     * @return An instance of ScheduleTerminalActionsRequestActionDetails
     * @throws IOException if the JSON string is invalid with respect to
     *     ScheduleTerminalActionsRequestActionDetails
     */
    public static ScheduleTerminalActionsRequestActionDetails fromJson(String jsonString)
        throws IOException {
      return JSON.getMapper()
          .readValue(jsonString, ScheduleTerminalActionsRequestActionDetails.class);
    }
  
    /**
     * Convert an instance of ScheduleTerminalActionsRequestActionDetails to an JSON string
     *
     * @return JSON string
     */
    public String toJson() throws JsonProcessingException {
      return JSON.getMapper().writeValueAsString(this);
    }
  }
  