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

com.fireblocks.sdk.model.PolicyCheckResult 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.math.BigDecimal;
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;

/** Policy rules validation result */
@JsonPropertyOrder({
    PolicyCheckResult.JSON_PROPERTY_ERRORS,
    PolicyCheckResult.JSON_PROPERTY_RESULTS
})
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class PolicyCheckResult {
    public static final String JSON_PROPERTY_ERRORS = "errors";
    private BigDecimal errors;

    public static final String JSON_PROPERTY_RESULTS = "results";
    private List results = new ArrayList<>();

    public PolicyCheckResult() {}

    public PolicyCheckResult errors(BigDecimal errors) {
        this.errors = errors;
        return this;
    }

    /**
     * Number of errors
     *
     * @return errors
     */
    @jakarta.annotation.Nonnull
    @JsonProperty(JSON_PROPERTY_ERRORS)
    @JsonInclude(value = JsonInclude.Include.ALWAYS)
    public BigDecimal getErrors() {
        return errors;
    }

    @JsonProperty(JSON_PROPERTY_ERRORS)
    @JsonInclude(value = JsonInclude.Include.ALWAYS)
    public void setErrors(BigDecimal errors) {
        this.errors = errors;
    }

    public PolicyCheckResult results(List results) {
        this.results = results;
        return this;
    }

    public PolicyCheckResult addResultsItem(PolicyRuleCheckResult resultsItem) {
        if (this.results == null) {
            this.results = new ArrayList<>();
        }
        this.results.add(resultsItem);
        return this;
    }

    /**
     * A set of validation results
     *
     * @return results
     */
    @jakarta.annotation.Nonnull
    @JsonProperty(JSON_PROPERTY_RESULTS)
    @JsonInclude(value = JsonInclude.Include.ALWAYS)
    public List getResults() {
        return results;
    }

    @JsonProperty(JSON_PROPERTY_RESULTS)
    @JsonInclude(value = JsonInclude.Include.ALWAYS)
    public void setResults(List results) {
        this.results = results;
    }

    /** Return true if this PolicyCheckResult object is equal to o. */
    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        PolicyCheckResult policyCheckResult = (PolicyCheckResult) o;
        return Objects.equals(this.errors, policyCheckResult.errors)
                && Objects.equals(this.results, policyCheckResult.results);
    }

    @Override
    public int hashCode() {
        return Objects.hash(errors, results);
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("class PolicyCheckResult {\n");
        sb.append("    errors: ").append(toIndentedString(errors)).append("\n");
        sb.append("    results: ").append(toIndentedString(results)).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 `errors` to the URL query string
        if (getErrors() != null) {
            joiner.add(
                    String.format(
                            "%serrors%s=%s",
                            prefix,
                            suffix,
                            URLEncoder.encode(String.valueOf(getErrors()), StandardCharsets.UTF_8)
                                    .replaceAll("\\+", "%20")));
        }

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

        return joiner.toString();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy