
software.crldev.elrondspringbootstarterreactive.domain.transaction.GasPrice Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of elrond-spring-boot-starter-reactive Show documentation
Show all versions of elrond-spring-boot-starter-reactive Show documentation
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.transaction;
import software.crldev.elrondspringbootstarterreactive.error.exception.NegativeGasException;
import software.crldev.elrondspringbootstarterreactive.config.constants.CurrencyConstants;
import java.math.BigInteger;
/**
* Value object for GasPrice
*
* @author carlo_stanciu
*/
public final class GasPrice {
private final BigInteger value;
private GasPrice(BigInteger value) {
if (value.signum() == -1) throw new NegativeGasException(value);
this.value = value;
}
/**
* Creates an GasPrice object from
* a number value
*
* @param value - value in BigInteger format
* @return an instance of GasPrice
*/
public static GasPrice fromNumber(BigInteger value) {
return new GasPrice(value);
}
/**
* Creates an GasPrice object from
* a String value
*
* @param value - value in String format
* @return an instance of GasPrice
*/
public static GasPrice fromString(String value) {
return fromNumber(new BigInteger(value));
}
@Override
public String toString() {
return value.toString(CurrencyConstants.BASE10);
}
public BigInteger getValue() {
return this.value;
}
@Override
public boolean equals(final Object o) {
if (o == this) return true;
if (!(o instanceof GasPrice)) return false;
final GasPrice other = (GasPrice) 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