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

software.crldev.elrondspringbootstarterreactive.domain.esdt.common.TokenRoyalties 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.domain.esdt.common;

import software.crldev.elrondspringbootstarterreactive.error.ErrorMessage;
import software.crldev.elrondspringbootstarterreactive.util.HexValidator;
import static java.util.Objects.nonNull;

/**
 * Value object for ESDT NFT royalties
 *
 * @author carlo_stanciu
 */
public final class TokenRoyalties {
    private final Integer value;

    private TokenRoyalties(Integer number) {
        this.value = number;
    }

    /**
     * Creates an TokenRoyalties object from number input
     *
     * @return - an instance of TokenRoyalties
     */
    public static TokenRoyalties fromNumber(Integer value) {
        if (!(nonNull(value) && value >= 0 && value <= 10000)) throw new IllegalArgumentException(ErrorMessage.TOKEN_ROYALTIES.getValue());
        return new TokenRoyalties(value);
    }

    /**
     * Getter
     *
     * @return - hex value of the Token Royalties
     */
    public String getHex() {
        return HexValidator.processNumberHexArgument(Integer.toString(value, 16));
    }

    /**
     * Returns the value
     *
     * @return - value in String format
     */
    @Override
    public String toString() {
        return value.toString();
    }

    public Integer getValue() {
        return this.value;
    }

    @Override
    public boolean equals(final Object o) {
        if (o == this) return true;
        if (!(o instanceof TokenRoyalties)) return false;
        final TokenRoyalties other = (TokenRoyalties) o;
        final Object this$value = this.getValue();
        final Object other$value = other.getValue();
        if (this$value == null ? other$value != null : !this$value.equals(other$value)) return false;
        return true;
    }

    @Override
    public int hashCode() {
        final int PRIME = 59;
        int result = 1;
        final Object $value = this.getValue();
        result = result * PRIME + ($value == null ? 43 : $value.hashCode());
        return result;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy