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

com.fireblocks.sdk.model.PolicyRuleOperators 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.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonValue;
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;

/** Defines users/groups who can initiate the type of transaction to which the rule applies. */
@JsonPropertyOrder({
    PolicyRuleOperators.JSON_PROPERTY_WILDCARD,
    PolicyRuleOperators.JSON_PROPERTY_USERS,
    PolicyRuleOperators.JSON_PROPERTY_USERS_GROUPS,
    PolicyRuleOperators.JSON_PROPERTY_SERVICES
})
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class PolicyRuleOperators {
    /**
     * If used then this property should appear as the only child property * \"*\" - All
     * users are allowed
     */
    public enum WildcardEnum {
        STAR("*");

        private String value;

        WildcardEnum(String value) {
            this.value = value;
        }

        @JsonValue
        public String getValue() {
            return value;
        }

        @Override
        public String toString() {
            return String.valueOf(value);
        }

        @JsonCreator
        public static WildcardEnum fromValue(String value) {
            for (WildcardEnum b : WildcardEnum.values()) {
                if (b.value.equals(value)) {
                    return b;
                }
            }
            throw new IllegalArgumentException("Unexpected value '" + value + "'");
        }
    }

    public static final String JSON_PROPERTY_WILDCARD = "wildcard";
    private WildcardEnum wildcard;

    public static final String JSON_PROPERTY_USERS = "users";
    private List users;

    public static final String JSON_PROPERTY_USERS_GROUPS = "usersGroups";
    private List usersGroups;

    public static final String JSON_PROPERTY_SERVICES = "services";
    private List services;

    public PolicyRuleOperators() {}

    public PolicyRuleOperators wildcard(WildcardEnum wildcard) {
        this.wildcard = wildcard;
        return this;
    }

    /**
     * If used then this property should appear as the only child property * \"*\" - All
     * users are allowed
     *
     * @return wildcard
     */
    @jakarta.annotation.Nullable
    @JsonProperty(JSON_PROPERTY_WILDCARD)
    @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
    public WildcardEnum getWildcard() {
        return wildcard;
    }

    @JsonProperty(JSON_PROPERTY_WILDCARD)
    @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
    public void setWildcard(WildcardEnum wildcard) {
        this.wildcard = wildcard;
    }

    public PolicyRuleOperators users(List users) {
        this.users = users;
        return this;
    }

    public PolicyRuleOperators addUsersItem(String usersItem) {
        if (this.users == null) {
            this.users = new ArrayList<>();
        }
        this.users.add(usersItem);
        return this;
    }

    /**
     * Set of users ids
     *
     * @return users
     */
    @jakarta.annotation.Nullable
    @JsonProperty(JSON_PROPERTY_USERS)
    @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
    public List getUsers() {
        return users;
    }

    @JsonProperty(JSON_PROPERTY_USERS)
    @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
    public void setUsers(List users) {
        this.users = users;
    }

    public PolicyRuleOperators usersGroups(List usersGroups) {
        this.usersGroups = usersGroups;
        return this;
    }

    public PolicyRuleOperators addUsersGroupsItem(String usersGroupsItem) {
        if (this.usersGroups == null) {
            this.usersGroups = new ArrayList<>();
        }
        this.usersGroups.add(usersGroupsItem);
        return this;
    }

    /**
     * Set of group ids
     *
     * @return usersGroups
     */
    @jakarta.annotation.Nullable
    @JsonProperty(JSON_PROPERTY_USERS_GROUPS)
    @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
    public List getUsersGroups() {
        return usersGroups;
    }

    @JsonProperty(JSON_PROPERTY_USERS_GROUPS)
    @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
    public void setUsersGroups(List usersGroups) {
        this.usersGroups = usersGroups;
    }

    public PolicyRuleOperators services(List services) {
        this.services = services;
        return this;
    }

    public PolicyRuleOperators addServicesItem(String servicesItem) {
        if (this.services == null) {
            this.services = new ArrayList<>();
        }
        this.services.add(servicesItem);
        return this;
    }

    /**
     * set of services to initiate transactions
     *
     * @return services
     */
    @jakarta.annotation.Nullable
    @JsonProperty(JSON_PROPERTY_SERVICES)
    @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
    public List getServices() {
        return services;
    }

    @JsonProperty(JSON_PROPERTY_SERVICES)
    @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
    public void setServices(List services) {
        this.services = services;
    }

    /** Return true if this PolicyRule_operators object is equal to o. */
    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        PolicyRuleOperators policyRuleOperators = (PolicyRuleOperators) o;
        return Objects.equals(this.wildcard, policyRuleOperators.wildcard)
                && Objects.equals(this.users, policyRuleOperators.users)
                && Objects.equals(this.usersGroups, policyRuleOperators.usersGroups)
                && Objects.equals(this.services, policyRuleOperators.services);
    }

    @Override
    public int hashCode() {
        return Objects.hash(wildcard, users, usersGroups, services);
    }

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

        // add `users` to the URL query string
        if (getUsers() != null) {
            for (int i = 0; i < getUsers().size(); i++) {
                joiner.add(
                        String.format(
                                "%susers%s%s=%s",
                                prefix,
                                suffix,
                                "".equals(suffix)
                                        ? ""
                                        : String.format(
                                                "%s%d%s", containerPrefix, i, containerSuffix),
                                URLEncoder.encode(
                                                String.valueOf(getUsers().get(i)),
                                                StandardCharsets.UTF_8)
                                        .replaceAll("\\+", "%20")));
            }
        }

        // add `usersGroups` to the URL query string
        if (getUsersGroups() != null) {
            for (int i = 0; i < getUsersGroups().size(); i++) {
                joiner.add(
                        String.format(
                                "%susersGroups%s%s=%s",
                                prefix,
                                suffix,
                                "".equals(suffix)
                                        ? ""
                                        : String.format(
                                                "%s%d%s", containerPrefix, i, containerSuffix),
                                URLEncoder.encode(
                                                String.valueOf(getUsersGroups().get(i)),
                                                StandardCharsets.UTF_8)
                                        .replaceAll("\\+", "%20")));
            }
        }

        // add `services` to the URL query string
        if (getServices() != null) {
            for (int i = 0; i < getServices().size(); i++) {
                joiner.add(
                        String.format(
                                "%sservices%s%s=%s",
                                prefix,
                                suffix,
                                "".equals(suffix)
                                        ? ""
                                        : String.format(
                                                "%s%d%s", containerPrefix, i, containerSuffix),
                                URLEncoder.encode(
                                                String.valueOf(getServices().get(i)),
                                                StandardCharsets.UTF_8)
                                        .replaceAll("\\+", "%20")));
            }
        }

        return joiner.toString();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy