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

software.crldev.elrondspringbootstarterreactive.properties.ErdClientProperties Maven / Gradle / Ivy

Go to download

A SpringBoot Starter solution designed to ensure easy and efficient integration with the Elrond Network using a Reactive API layer.

The newest version!
package software.crldev.elrondspringbootstarterreactive.properties;

import org.springframework.boot.context.properties.ConfigurationProperties;
import software.crldev.elrondspringbootstarterreactive.error.exception.GatewayException;
import java.util.Locale;

/**
 * Configuration class for spring properties mapping
 *
 * @author carlo_stanciu
 */
@ConfigurationProperties(prefix = "spring.elrond.client")
public class ErdClientProperties {
    private String gateway;
    private long readTimeoutMillis = 10000L;
    private long writeTimeoutMillis = 10000L;

    {
        setGateway("devnet");
    }

    public void setGateway(String gateway) {
        switch (gateway.toLowerCase(Locale.ROOT).strip()) {
        case "devnet": 
            this.gateway = processUrl("devnet-gateway");
            break;
        case "testnet": 
            this.gateway = processUrl("testnet-gateway");
            break;
        case "mainnet": 
            this.gateway = processUrl("gateway");
            break;
        default: 
            throw new GatewayException();
        }
    }

    private String processUrl(String gatewayValue) {
        return String.format("https://%s.elrond.com", gatewayValue);
    }

    public ErdClientProperties() {
    }

    public String getGateway() {
        return this.gateway;
    }

    public long getReadTimeoutMillis() {
        return this.readTimeoutMillis;
    }

    public long getWriteTimeoutMillis() {
        return this.writeTimeoutMillis;
    }

    public void setReadTimeoutMillis(final long readTimeoutMillis) {
        this.readTimeoutMillis = readTimeoutMillis;
    }

    public void setWriteTimeoutMillis(final long writeTimeoutMillis) {
        this.writeTimeoutMillis = writeTimeoutMillis;
    }

    @Override
    public boolean equals(final Object o) {
        if (o == this) return true;
        if (!(o instanceof ErdClientProperties)) return false;
        final ErdClientProperties other = (ErdClientProperties) o;
        if (!other.canEqual((Object) this)) return false;
        if (this.getReadTimeoutMillis() != other.getReadTimeoutMillis()) return false;
        if (this.getWriteTimeoutMillis() != other.getWriteTimeoutMillis()) return false;
        final Object this$gateway = this.getGateway();
        final Object other$gateway = other.getGateway();
        if (this$gateway == null ? other$gateway != null : !this$gateway.equals(other$gateway)) return false;
        return true;
    }

    protected boolean canEqual(final Object other) {
        return other instanceof ErdClientProperties;
    }

    @Override
    public int hashCode() {
        final int PRIME = 59;
        int result = 1;
        final long $readTimeoutMillis = this.getReadTimeoutMillis();
        result = result * PRIME + (int) ($readTimeoutMillis >>> 32 ^ $readTimeoutMillis);
        final long $writeTimeoutMillis = this.getWriteTimeoutMillis();
        result = result * PRIME + (int) ($writeTimeoutMillis >>> 32 ^ $writeTimeoutMillis);
        final Object $gateway = this.getGateway();
        result = result * PRIME + ($gateway == null ? 43 : $gateway.hashCode());
        return result;
    }

    @Override
    public String toString() {
        return "ErdClientProperties(gateway=" + this.getGateway() + ", readTimeoutMillis=" + this.getReadTimeoutMillis() + ", writeTimeoutMillis=" + this.getWriteTimeoutMillis() + ")";
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy