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

com.fireblocks.sdk.model.ParameterWithValue 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.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.StringJoiner;

/** ParameterWithValue */
@JsonPropertyOrder({
    ParameterWithValue.JSON_PROPERTY_NAME,
    ParameterWithValue.JSON_PROPERTY_DESCRIPTION,
    ParameterWithValue.JSON_PROPERTY_INTERNAL_TYPE,
    ParameterWithValue.JSON_PROPERTY_TYPE,
    ParameterWithValue.JSON_PROPERTY_COMPONENTS,
    ParameterWithValue.JSON_PROPERTY_VALUE,
    ParameterWithValue.JSON_PROPERTY_FUNCTION_VALUE
})
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class ParameterWithValue {
    public static final String JSON_PROPERTY_NAME = "name";
    private String name;

    public static final String JSON_PROPERTY_DESCRIPTION = "description";
    private String description;

    public static final String JSON_PROPERTY_INTERNAL_TYPE = "internalType";
    private String internalType;

    public static final String JSON_PROPERTY_TYPE = "type";
    private String type;

    public static final String JSON_PROPERTY_COMPONENTS = "components";
    private List components;

    public static final String JSON_PROPERTY_VALUE = "value";
    private String value;

    public static final String JSON_PROPERTY_FUNCTION_VALUE = "functionValue";
    private LeanAbiFunction functionValue;

    public ParameterWithValue() {}

    public ParameterWithValue name(String name) {
        this.name = name;
        return this;
    }

    /**
     * The name of the parameter as it appears in the ABI
     *
     * @return name
     */
    @jakarta.annotation.Nonnull
    @JsonProperty(JSON_PROPERTY_NAME)
    @JsonInclude(value = JsonInclude.Include.ALWAYS)
    public String getName() {
        return name;
    }

    @JsonProperty(JSON_PROPERTY_NAME)
    @JsonInclude(value = JsonInclude.Include.ALWAYS)
    public void setName(String name) {
        this.name = name;
    }

    public ParameterWithValue description(String description) {
        this.description = description;
        return this;
    }

    /**
     * A description of the parameter, fetched from the devdoc of this contract
     *
     * @return description
     */
    @jakarta.annotation.Nullable
    @JsonProperty(JSON_PROPERTY_DESCRIPTION)
    @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
    public String getDescription() {
        return description;
    }

    @JsonProperty(JSON_PROPERTY_DESCRIPTION)
    @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
    public void setDescription(String description) {
        this.description = description;
    }

    public ParameterWithValue internalType(String internalType) {
        this.internalType = internalType;
        return this;
    }

    /**
     * The internal type of the parameter as it appears in the ABI
     *
     * @return internalType
     */
    @jakarta.annotation.Nullable
    @JsonProperty(JSON_PROPERTY_INTERNAL_TYPE)
    @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
    public String getInternalType() {
        return internalType;
    }

    @JsonProperty(JSON_PROPERTY_INTERNAL_TYPE)
    @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
    public void setInternalType(String internalType) {
        this.internalType = internalType;
    }

    public ParameterWithValue type(String type) {
        this.type = type;
        return this;
    }

    /**
     * The type of the parameter as it appears in the ABI
     *
     * @return type
     */
    @jakarta.annotation.Nonnull
    @JsonProperty(JSON_PROPERTY_TYPE)
    @JsonInclude(value = JsonInclude.Include.ALWAYS)
    public String getType() {
        return type;
    }

    @JsonProperty(JSON_PROPERTY_TYPE)
    @JsonInclude(value = JsonInclude.Include.ALWAYS)
    public void setType(String type) {
        this.type = type;
    }

    public ParameterWithValue components(List components) {
        this.components = components;
        return this;
    }

    public ParameterWithValue addComponentsItem(Parameter componentsItem) {
        if (this.components == null) {
            this.components = new ArrayList<>();
        }
        this.components.add(componentsItem);
        return this;
    }

    /**
     * Get components
     *
     * @return components
     */
    @jakarta.annotation.Nullable
    @JsonProperty(JSON_PROPERTY_COMPONENTS)
    @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
    public List getComponents() {
        return components;
    }

    @JsonProperty(JSON_PROPERTY_COMPONENTS)
    @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
    public void setComponents(List components) {
        this.components = components;
    }

    public ParameterWithValue value(String value) {
        this.value = value;
        return this;
    }

    /**
     * The value of the parameter. can also be ParameterWithValue
     *
     * @return value
     */
    @jakarta.annotation.Nullable
    @JsonProperty(JSON_PROPERTY_VALUE)
    @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
    public String getValue() {
        return value;
    }

    @JsonProperty(JSON_PROPERTY_VALUE)
    @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
    public void setValue(String value) {
        this.value = value;
    }

    public ParameterWithValue functionValue(LeanAbiFunction functionValue) {
        this.functionValue = functionValue;
        return this;
    }

    /**
     * The function value of this param (if has one). If this is set, the `value`
     * shouldn`t be. Used for proxies
     *
     * @return functionValue
     */
    @jakarta.annotation.Nullable
    @JsonProperty(JSON_PROPERTY_FUNCTION_VALUE)
    @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
    public LeanAbiFunction getFunctionValue() {
        return functionValue;
    }

    @JsonProperty(JSON_PROPERTY_FUNCTION_VALUE)
    @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
    public void setFunctionValue(LeanAbiFunction functionValue) {
        this.functionValue = functionValue;
    }

    /** Return true if this ParameterWithValue object is equal to o. */
    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        ParameterWithValue parameterWithValue = (ParameterWithValue) o;
        return Objects.equals(this.name, parameterWithValue.name)
                && Objects.equals(this.description, parameterWithValue.description)
                && Objects.equals(this.internalType, parameterWithValue.internalType)
                && Objects.equals(this.type, parameterWithValue.type)
                && Objects.equals(this.components, parameterWithValue.components)
                && Objects.equals(this.value, parameterWithValue.value)
                && Objects.equals(this.functionValue, parameterWithValue.functionValue);
    }

    @Override
    public int hashCode() {
        return Objects.hash(
                name, description, internalType, type, components, value, functionValue);
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("class ParameterWithValue {\n");
        sb.append("    name: ").append(toIndentedString(name)).append("\n");
        sb.append("    description: ").append(toIndentedString(description)).append("\n");
        sb.append("    internalType: ").append(toIndentedString(internalType)).append("\n");
        sb.append("    type: ").append(toIndentedString(type)).append("\n");
        sb.append("    components: ").append(toIndentedString(components)).append("\n");
        sb.append("    value: ").append(toIndentedString(value)).append("\n");
        sb.append("    functionValue: ").append(toIndentedString(functionValue)).append("\n");
        sb.append("}");
        return sb.toString();
    }

    /**
     * Convert the given object to string with each line indented by 4 spaces (except the first
     * line).
     */
    private String toIndentedString(Object o) {
        if (o == null) {
            return "null";
        }
        return o.toString().replace("\n", "\n    ");
    }

    /**
     * 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("&");

        // add `name` to the URL query string
        if (getName() != null) {
            joiner.add(
                    String.format(
                            "%sname%s=%s",
                            prefix,
                            suffix,
                            URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8)
                                    .replaceAll("\\+", "%20")));
        }

        // add `description` to the URL query string
        if (getDescription() != null) {
            joiner.add(
                    String.format(
                            "%sdescription%s=%s",
                            prefix,
                            suffix,
                            URLEncoder.encode(
                                            String.valueOf(getDescription()),
                                            StandardCharsets.UTF_8)
                                    .replaceAll("\\+", "%20")));
        }

        // add `internalType` to the URL query string
        if (getInternalType() != null) {
            joiner.add(
                    String.format(
                            "%sinternalType%s=%s",
                            prefix,
                            suffix,
                            URLEncoder.encode(
                                            String.valueOf(getInternalType()),
                                            StandardCharsets.UTF_8)
                                    .replaceAll("\\+", "%20")));
        }

        // add `type` to the URL query string
        if (getType() != null) {
            joiner.add(
                    String.format(
                            "%stype%s=%s",
                            prefix,
                            suffix,
                            URLEncoder.encode(String.valueOf(getType()), StandardCharsets.UTF_8)
                                    .replaceAll("\\+", "%20")));
        }

        // add `components` to the URL query string
        if (getComponents() != null) {
            for (int i = 0; i < getComponents().size(); i++) {
                if (getComponents().get(i) != null) {
                    joiner.add(
                            getComponents()
                                    .get(i)
                                    .toUrlQueryString(
                                            String.format(
                                                    "%scomponents%s%s",
                                                    prefix,
                                                    suffix,
                                                    "".equals(suffix)
                                                            ? ""
                                                            : String.format(
                                                                    "%s%d%s",
                                                                    containerPrefix,
                                                                    i,
                                                                    containerSuffix))));
                }
            }
        }

        // add `value` to the URL query string
        if (getValue() != null) {
            joiner.add(
                    String.format(
                            "%svalue%s=%s",
                            prefix,
                            suffix,
                            URLEncoder.encode(String.valueOf(getValue()), StandardCharsets.UTF_8)
                                    .replaceAll("\\+", "%20")));
        }

        // add `functionValue` to the URL query string
        if (getFunctionValue() != null) {
            joiner.add(getFunctionValue().toUrlQueryString(prefix + "functionValue" + suffix));
        }

        return joiner.toString();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy