|
| 1 | +package io.goodforgod.api.etherscan.model; |
| 2 | + |
| 3 | +import java.math.BigInteger; |
| 4 | +import java.util.Objects; |
| 5 | + |
| 6 | +/** |
| 7 | + * Please Add Description Here. |
| 8 | + * |
| 9 | + * @author Anton Kurako (GoodforGod) |
| 10 | + * @since 14.05.2023 |
| 11 | + */ |
| 12 | +public class EthSupply { |
| 13 | + |
| 14 | + private String EthSupply; |
| 15 | + private String Eth2Staking; |
| 16 | + private String BurntFees; |
| 17 | + private String WithdrawnTotal; |
| 18 | + |
| 19 | + public Wei getEthSupply() { |
| 20 | + return Wei.ofWei(new BigInteger(EthSupply)); |
| 21 | + } |
| 22 | + |
| 23 | + public Wei getEth2Staking() { |
| 24 | + return Wei.ofWei(new BigInteger(Eth2Staking)); |
| 25 | + } |
| 26 | + |
| 27 | + public Wei getBurntFees() { |
| 28 | + return Wei.ofWei(new BigInteger(BurntFees)); |
| 29 | + } |
| 30 | + |
| 31 | + public Wei getTotal() { |
| 32 | + final BigInteger total = getEthSupply().asWei() |
| 33 | + .add(getEth2Staking().asWei()) |
| 34 | + .min(getBurntFees().asWei()); |
| 35 | + return Wei.ofWei(total); |
| 36 | + } |
| 37 | + |
| 38 | + public Wei getWithdrawnTotal() { |
| 39 | + return Wei.ofWei(new BigInteger(WithdrawnTotal)); |
| 40 | + } |
| 41 | + |
| 42 | + @Override |
| 43 | + public boolean equals(Object o) { |
| 44 | + if (this == o) |
| 45 | + return true; |
| 46 | + if (!(o instanceof EthSupply)) |
| 47 | + return false; |
| 48 | + EthSupply ethSupply = (EthSupply) o; |
| 49 | + return Objects.equals(EthSupply, ethSupply.EthSupply) && Objects.equals(Eth2Staking, ethSupply.Eth2Staking) |
| 50 | + && Objects.equals(BurntFees, ethSupply.BurntFees) && Objects.equals(WithdrawnTotal, ethSupply.WithdrawnTotal); |
| 51 | + } |
| 52 | + |
| 53 | + @Override |
| 54 | + public int hashCode() { |
| 55 | + return Objects.hash(EthSupply, Eth2Staking, BurntFees, WithdrawnTotal); |
| 56 | + } |
| 57 | + |
| 58 | + @Override |
| 59 | + public String toString() { |
| 60 | + return "EthSupply{" + |
| 61 | + "EthSupply='" + EthSupply + '\'' + |
| 62 | + ", Eth2Staking='" + Eth2Staking + '\'' + |
| 63 | + ", BurntFees='" + BurntFees + '\'' + |
| 64 | + ", WithdrawnTotal='" + WithdrawnTotal + '\'' + |
| 65 | + '}'; |
| 66 | + } |
| 67 | + |
| 68 | + public static EthSupplyBuilder builder() { |
| 69 | + return new EthSupplyBuilder(); |
| 70 | + } |
| 71 | + |
| 72 | + public static final class EthSupplyBuilder { |
| 73 | + |
| 74 | + private Wei ethSupply; |
| 75 | + private Wei eth2Staking; |
| 76 | + private Wei burntFees; |
| 77 | + private Wei withdrawnTotal; |
| 78 | + |
| 79 | + private EthSupplyBuilder() {} |
| 80 | + |
| 81 | + public EthSupplyBuilder withEthSupply(Wei ethSupply) { |
| 82 | + this.ethSupply = ethSupply; |
| 83 | + return this; |
| 84 | + } |
| 85 | + |
| 86 | + public EthSupplyBuilder withEth2Staking(Wei eth2Staking) { |
| 87 | + this.eth2Staking = eth2Staking; |
| 88 | + return this; |
| 89 | + } |
| 90 | + |
| 91 | + public EthSupplyBuilder withBurntFees(Wei burntFees) { |
| 92 | + this.burntFees = burntFees; |
| 93 | + return this; |
| 94 | + } |
| 95 | + |
| 96 | + public EthSupplyBuilder withWithdrawnTotal(Wei withdrawnTotal) { |
| 97 | + this.withdrawnTotal = withdrawnTotal; |
| 98 | + return this; |
| 99 | + } |
| 100 | + |
| 101 | + public EthSupply build() { |
| 102 | + EthSupply ethSupply = new EthSupply(); |
| 103 | + ethSupply.BurntFees = this.burntFees.toString(); |
| 104 | + ethSupply.Eth2Staking = this.eth2Staking.toString(); |
| 105 | + ethSupply.EthSupply = this.ethSupply.toString(); |
| 106 | + ethSupply.WithdrawnTotal = this.withdrawnTotal.toString(); |
| 107 | + return ethSupply; |
| 108 | + } |
| 109 | + } |
| 110 | +} |
0 commit comments