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

com.fireblocks.sdk.model.WorkflowExecutionOperation Maven / Gradle / Ivy

/*
 * Fireblocks API
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 1.6.2
 * Contact: [email protected]
 *
 * 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.fireblocks.sdk.model;


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 com.fireblocks.sdk.JSON;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.StringJoiner;
import java.util.logging.Level;
import java.util.logging.Logger;

@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
@JsonDeserialize(using = WorkflowExecutionOperation.WorkflowExecutionOperationDeserializer.class)
@JsonSerialize(using = WorkflowExecutionOperation.WorkflowExecutionOperationSerializer.class)
public class WorkflowExecutionOperation extends AbstractOpenApiSchema {
    private static final Logger log = Logger.getLogger(WorkflowExecutionOperation.class.getName());

    public static class WorkflowExecutionOperationSerializer
            extends StdSerializer {
        public WorkflowExecutionOperationSerializer(Class t) {
            super(t);
        }

        public WorkflowExecutionOperationSerializer() {
            this(null);
        }

        @Override
        public void serialize(
                WorkflowExecutionOperation value, JsonGenerator jgen, SerializerProvider provider)
                throws IOException, JsonProcessingException {
            jgen.writeObject(value.getActualInstance());
        }
    }

    public static class WorkflowExecutionOperationDeserializer
            extends StdDeserializer {
        public WorkflowExecutionOperationDeserializer() {
            this(WorkflowExecutionOperation.class);
        }

        public WorkflowExecutionOperationDeserializer(Class vc) {
            super(vc);
        }

        @Override
        public WorkflowExecutionOperation 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 ExecutionConversionOperation
            try {
                boolean attemptParsing = true;
                // ensure that we respect type coercion as set on the client ObjectMapper
                if (ExecutionConversionOperation.class.equals(Integer.class)
                        || ExecutionConversionOperation.class.equals(Long.class)
                        || ExecutionConversionOperation.class.equals(Float.class)
                        || ExecutionConversionOperation.class.equals(Double.class)
                        || ExecutionConversionOperation.class.equals(Boolean.class)
                        || ExecutionConversionOperation.class.equals(String.class)) {
                    attemptParsing = typeCoercion;
                    if (!attemptParsing) {
                        attemptParsing |=
                                ((ExecutionConversionOperation.class.equals(Integer.class)
                                                || ExecutionConversionOperation.class.equals(
                                                        Long.class))
                                        && token == JsonToken.VALUE_NUMBER_INT);
                        attemptParsing |=
                                ((ExecutionConversionOperation.class.equals(Float.class)
                                                || ExecutionConversionOperation.class.equals(
                                                        Double.class))
                                        && token == JsonToken.VALUE_NUMBER_FLOAT);
                        attemptParsing |=
                                (ExecutionConversionOperation.class.equals(Boolean.class)
                                        && (token == JsonToken.VALUE_FALSE
                                                || token == JsonToken.VALUE_TRUE));
                        attemptParsing |=
                                (ExecutionConversionOperation.class.equals(String.class)
                                        && token == JsonToken.VALUE_STRING);
                    }
                }
                if (attemptParsing) {
                    deserialized =
                            tree.traverse(jp.getCodec())
                                    .readValueAs(ExecutionConversionOperation.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 'ExecutionConversionOperation'");
                }
            } catch (Exception e) {
                // deserialization failed, continue
                log.log(
                        Level.FINER,
                        "Input data does not match schema 'ExecutionConversionOperation'",
                        e);
            }

            // deserialize ExecutionDisbursementOperation
            try {
                boolean attemptParsing = true;
                // ensure that we respect type coercion as set on the client ObjectMapper
                if (ExecutionDisbursementOperation.class.equals(Integer.class)
                        || ExecutionDisbursementOperation.class.equals(Long.class)
                        || ExecutionDisbursementOperation.class.equals(Float.class)
                        || ExecutionDisbursementOperation.class.equals(Double.class)
                        || ExecutionDisbursementOperation.class.equals(Boolean.class)
                        || ExecutionDisbursementOperation.class.equals(String.class)) {
                    attemptParsing = typeCoercion;
                    if (!attemptParsing) {
                        attemptParsing |=
                                ((ExecutionDisbursementOperation.class.equals(Integer.class)
                                                || ExecutionDisbursementOperation.class.equals(
                                                        Long.class))
                                        && token == JsonToken.VALUE_NUMBER_INT);
                        attemptParsing |=
                                ((ExecutionDisbursementOperation.class.equals(Float.class)
                                                || ExecutionDisbursementOperation.class.equals(
                                                        Double.class))
                                        && token == JsonToken.VALUE_NUMBER_FLOAT);
                        attemptParsing |=
                                (ExecutionDisbursementOperation.class.equals(Boolean.class)
                                        && (token == JsonToken.VALUE_FALSE
                                                || token == JsonToken.VALUE_TRUE));
                        attemptParsing |=
                                (ExecutionDisbursementOperation.class.equals(String.class)
                                        && token == JsonToken.VALUE_STRING);
                    }
                }
                if (attemptParsing) {
                    deserialized =
                            tree.traverse(jp.getCodec())
                                    .readValueAs(ExecutionDisbursementOperation.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 'ExecutionDisbursementOperation'");
                }
            } catch (Exception e) {
                // deserialization failed, continue
                log.log(
                        Level.FINER,
                        "Input data does not match schema 'ExecutionDisbursementOperation'",
                        e);
            }

            // deserialize ExecutionScreeningOperation
            try {
                boolean attemptParsing = true;
                // ensure that we respect type coercion as set on the client ObjectMapper
                if (ExecutionScreeningOperation.class.equals(Integer.class)
                        || ExecutionScreeningOperation.class.equals(Long.class)
                        || ExecutionScreeningOperation.class.equals(Float.class)
                        || ExecutionScreeningOperation.class.equals(Double.class)
                        || ExecutionScreeningOperation.class.equals(Boolean.class)
                        || ExecutionScreeningOperation.class.equals(String.class)) {
                    attemptParsing = typeCoercion;
                    if (!attemptParsing) {
                        attemptParsing |=
                                ((ExecutionScreeningOperation.class.equals(Integer.class)
                                                || ExecutionScreeningOperation.class.equals(
                                                        Long.class))
                                        && token == JsonToken.VALUE_NUMBER_INT);
                        attemptParsing |=
                                ((ExecutionScreeningOperation.class.equals(Float.class)
                                                || ExecutionScreeningOperation.class.equals(
                                                        Double.class))
                                        && token == JsonToken.VALUE_NUMBER_FLOAT);
                        attemptParsing |=
                                (ExecutionScreeningOperation.class.equals(Boolean.class)
                                        && (token == JsonToken.VALUE_FALSE
                                                || token == JsonToken.VALUE_TRUE));
                        attemptParsing |=
                                (ExecutionScreeningOperation.class.equals(String.class)
                                        && token == JsonToken.VALUE_STRING);
                    }
                }
                if (attemptParsing) {
                    deserialized =
                            tree.traverse(jp.getCodec())
                                    .readValueAs(ExecutionScreeningOperation.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 'ExecutionScreeningOperation'");
                }
            } catch (Exception e) {
                // deserialization failed, continue
                log.log(
                        Level.FINER,
                        "Input data does not match schema 'ExecutionScreeningOperation'",
                        e);
            }

            // deserialize ExecutionTransferOperation
            try {
                boolean attemptParsing = true;
                // ensure that we respect type coercion as set on the client ObjectMapper
                if (ExecutionTransferOperation.class.equals(Integer.class)
                        || ExecutionTransferOperation.class.equals(Long.class)
                        || ExecutionTransferOperation.class.equals(Float.class)
                        || ExecutionTransferOperation.class.equals(Double.class)
                        || ExecutionTransferOperation.class.equals(Boolean.class)
                        || ExecutionTransferOperation.class.equals(String.class)) {
                    attemptParsing = typeCoercion;
                    if (!attemptParsing) {
                        attemptParsing |=
                                ((ExecutionTransferOperation.class.equals(Integer.class)
                                                || ExecutionTransferOperation.class.equals(
                                                        Long.class))
                                        && token == JsonToken.VALUE_NUMBER_INT);
                        attemptParsing |=
                                ((ExecutionTransferOperation.class.equals(Float.class)
                                                || ExecutionTransferOperation.class.equals(
                                                        Double.class))
                                        && token == JsonToken.VALUE_NUMBER_FLOAT);
                        attemptParsing |=
                                (ExecutionTransferOperation.class.equals(Boolean.class)
                                        && (token == JsonToken.VALUE_FALSE
                                                || token == JsonToken.VALUE_TRUE));
                        attemptParsing |=
                                (ExecutionTransferOperation.class.equals(String.class)
                                        && token == JsonToken.VALUE_STRING);
                    }
                }
                if (attemptParsing) {
                    deserialized =
                            tree.traverse(jp.getCodec())
                                    .readValueAs(ExecutionTransferOperation.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 'ExecutionTransferOperation'");
                }
            } catch (Exception e) {
                // deserialization failed, continue
                log.log(
                        Level.FINER,
                        "Input data does not match schema 'ExecutionTransferOperation'",
                        e);
            }

            if (match == 1) {
                WorkflowExecutionOperation ret = new WorkflowExecutionOperation();
                ret.setActualInstance(deserialized);
                return ret;
            }
            throw new IOException(
                    String.format(
                            "Failed deserialization for WorkflowExecutionOperation: %d classes"
                                    + " match result, expected 1",
                            match));
        }

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

    // store a list of schema names defined in oneOf
    public static final Map> schemas = new HashMap<>();

    public WorkflowExecutionOperation() {
        super("oneOf", Boolean.FALSE);
    }

    public WorkflowExecutionOperation(ExecutionConversionOperation o) {
        super("oneOf", Boolean.FALSE);
        setActualInstance(o);
    }

    public WorkflowExecutionOperation(ExecutionDisbursementOperation o) {
        super("oneOf", Boolean.FALSE);
        setActualInstance(o);
    }

    public WorkflowExecutionOperation(ExecutionScreeningOperation o) {
        super("oneOf", Boolean.FALSE);
        setActualInstance(o);
    }

    public WorkflowExecutionOperation(ExecutionTransferOperation o) {
        super("oneOf", Boolean.FALSE);
        setActualInstance(o);
    }

    static {
        schemas.put("ExecutionConversionOperation", ExecutionConversionOperation.class);
        schemas.put("ExecutionDisbursementOperation", ExecutionDisbursementOperation.class);
        schemas.put("ExecutionScreeningOperation", ExecutionScreeningOperation.class);
        schemas.put("ExecutionTransferOperation", ExecutionTransferOperation.class);
        JSON.registerDescendants(
                WorkflowExecutionOperation.class, Collections.unmodifiableMap(schemas));
    }

    @Override
    public Map> getSchemas() {
        return WorkflowExecutionOperation.schemas;
    }

    /**
     * Set the instance that matches the oneOf child schema, check the instance parameter is valid
     * against the oneOf child schemas: ExecutionConversionOperation,
     * ExecutionDisbursementOperation, ExecutionScreeningOperation, ExecutionTransferOperation
     *
     * 

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( ExecutionConversionOperation.class, instance, new HashSet>())) { super.setActualInstance(instance); return; } if (JSON.isInstanceOf( ExecutionDisbursementOperation.class, instance, new HashSet>())) { super.setActualInstance(instance); return; } if (JSON.isInstanceOf( ExecutionScreeningOperation.class, instance, new HashSet>())) { super.setActualInstance(instance); return; } if (JSON.isInstanceOf( ExecutionTransferOperation.class, instance, new HashSet>())) { super.setActualInstance(instance); return; } throw new RuntimeException( "Invalid instance type. Must be ExecutionConversionOperation," + " ExecutionDisbursementOperation, ExecutionScreeningOperation," + " ExecutionTransferOperation"); } /** * Get the actual instance, which can be the following: ExecutionConversionOperation, * ExecutionDisbursementOperation, ExecutionScreeningOperation, ExecutionTransferOperation * * @return The actual instance (ExecutionConversionOperation, ExecutionDisbursementOperation, * ExecutionScreeningOperation, ExecutionTransferOperation) */ @Override public Object getActualInstance() { return super.getActualInstance(); } /** * Get the actual instance of `ExecutionConversionOperation`. If the actual instance is not * `ExecutionConversionOperation`, the ClassCastException will be thrown. * * @return The actual instance of `ExecutionConversionOperation` * @throws ClassCastException if the instance is not `ExecutionConversionOperation` */ public ExecutionConversionOperation getExecutionConversionOperation() throws ClassCastException { return (ExecutionConversionOperation) super.getActualInstance(); } /** * Get the actual instance of `ExecutionDisbursementOperation`. If the actual instance is not * `ExecutionDisbursementOperation`, the ClassCastException will be thrown. * * @return The actual instance of `ExecutionDisbursementOperation` * @throws ClassCastException if the instance is not `ExecutionDisbursementOperation` */ public ExecutionDisbursementOperation getExecutionDisbursementOperation() throws ClassCastException { return (ExecutionDisbursementOperation) super.getActualInstance(); } /** * Get the actual instance of `ExecutionScreeningOperation`. If the actual instance is not * `ExecutionScreeningOperation`, the ClassCastException will be thrown. * * @return The actual instance of `ExecutionScreeningOperation` * @throws ClassCastException if the instance is not `ExecutionScreeningOperation` */ public ExecutionScreeningOperation getExecutionScreeningOperation() throws ClassCastException { return (ExecutionScreeningOperation) super.getActualInstance(); } /** * Get the actual instance of `ExecutionTransferOperation`. If the actual instance is not * `ExecutionTransferOperation`, the ClassCastException will be thrown. * * @return The actual instance of `ExecutionTransferOperation` * @throws ClassCastException if the instance is not `ExecutionTransferOperation` */ public ExecutionTransferOperation getExecutionTransferOperation() throws ClassCastException { return (ExecutionTransferOperation) super.getActualInstance(); } /** * Convert the instance into URL query string. * * @return URL query string */ public String toUrlQueryString() { return toUrlQueryString(null); } /** * Convert the instance into URL query string. * * @param prefix prefix of the query string * @return URL query string */ public String toUrlQueryString(String prefix) { String suffix = ""; String containerSuffix = ""; String containerPrefix = ""; if (prefix == null) { // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; } else { // deepObject style e.g. /pet?id[name]=cat&id[type]=manx prefix = prefix + "["; suffix = "]"; containerSuffix = "]"; containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); if (getActualInstance() instanceof ExecutionScreeningOperation) { if (getActualInstance() != null) { joiner.add( ((ExecutionScreeningOperation) getActualInstance()) .toUrlQueryString(prefix + "one_of_0" + suffix)); } return joiner.toString(); } if (getActualInstance() instanceof ExecutionConversionOperation) { if (getActualInstance() != null) { joiner.add( ((ExecutionConversionOperation) getActualInstance()) .toUrlQueryString(prefix + "one_of_1" + suffix)); } return joiner.toString(); } if (getActualInstance() instanceof ExecutionTransferOperation) { if (getActualInstance() != null) { joiner.add( ((ExecutionTransferOperation) getActualInstance()) .toUrlQueryString(prefix + "one_of_2" + suffix)); } return joiner.toString(); } if (getActualInstance() instanceof ExecutionDisbursementOperation) { if (getActualInstance() != null) { joiner.add( ((ExecutionDisbursementOperation) getActualInstance()) .toUrlQueryString(prefix + "one_of_3" + suffix)); } return joiner.toString(); } return null; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy