11package io .api .etherscan .model ;
22
3+ import io .api .etherscan .util .BasicUtils ;
4+
5+ import java .math .BigInteger ;
36import java .time .LocalDateTime ;
7+ import java .time .ZoneOffset ;
48import java .util .List ;
59
610/**
1216public class Log {
1317
1418 private String blockNumber ;
19+ private long _blockNumber ;
1520 private String address ;
1621 private String transactionHash ;
1722 private String transactionIndex ;
23+ private long _transactionIndex ;
1824 private String timeStamp ;
1925 private LocalDateTime _timeStamp ;
2026 private String data ;
2127 private String gasPrice ;
28+ private BigInteger _gasPrice ;
2229 private String gasUsed ;
30+ private BigInteger _gasUsed ;
2331 private List <String > topics ;
2432 private String logIndex ;
25-
26- public Log () { }
27-
28- public Log (String blockNumber , String address , String transactionHash , String transactionIndex ,
29- LocalDateTime _timeStamp , String data , String gasPrice , String gasUsed ,
30- List <String > topics , String logIndex ) {
31- this .blockNumber = blockNumber ;
32- this .address = address ;
33- this .transactionHash = transactionHash ;
34- this .transactionIndex = transactionIndex ;
35- this ._timeStamp = _timeStamp ;
36- this .data = data ;
37- this .gasPrice = gasPrice ;
38- this .gasUsed = gasUsed ;
39- this .topics = topics ;
40- this .logIndex = logIndex ;
41- }
33+ private long _logIndex ;
4234
4335 //<editor-fold desc="Getters">
44- public String getBlockNumber () {
45- return blockNumber ;
36+ public long getBlockNumber () {
37+ if (!BasicUtils .isEmpty (blockNumber )){
38+ _blockNumber = BasicUtils .parseHex (blockNumber ).longValue ();
39+ }
40+ return _blockNumber ;
4641 }
4742
4843 public String getAddress () {
@@ -53,36 +48,53 @@ public String getTransactionHash() {
5348 return transactionHash ;
5449 }
5550
56- public String getTransactionIndex () {
57- return transactionIndex ;
58- }
51+ public long getTransactionIndex () {
52+ if (!BasicUtils .isEmpty (transactionIndex )){
53+ _transactionIndex = BasicUtils .parseHex (transactionIndex ).longValue ();
54+ }
5955
60- public String getTimeStamp () {
61- return timeStamp ;
56+ return _transactionIndex ;
6257 }
6358
64- public LocalDateTime get_timeStamp () {
59+ public LocalDateTime getTimeStamp () {
60+ if (_timeStamp == null && !BasicUtils .isEmpty (timeStamp )) {
61+ long formatted = (timeStamp .charAt (0 ) == '0' && timeStamp .charAt (1 ) == 'x' )
62+ ? BasicUtils .parseHex (timeStamp ).longValue ()
63+ : Long .valueOf (timeStamp );
64+ _timeStamp = LocalDateTime .ofEpochSecond (formatted , 0 , ZoneOffset .UTC );
65+ }
6566 return _timeStamp ;
6667 }
6768
6869 public String getData () {
6970 return data ;
7071 }
7172
72- public String getGasPrice () {
73- return gasPrice ;
73+ public BigInteger getGasPrice () {
74+ if (!BasicUtils .isEmpty (gasPrice )){
75+ _gasPrice = BasicUtils .parseHex (gasPrice );
76+ }
77+
78+ return _gasPrice ;
7479 }
7580
76- public String getGasUsed () {
77- return gasUsed ;
81+ public BigInteger getGasUsed () {
82+ if (!BasicUtils .isEmpty (gasUsed )){
83+ _gasUsed = BasicUtils .parseHex (gasUsed );
84+ }
85+
86+ return _gasUsed ;
7887 }
7988
8089 public List <String > getTopics () {
8190 return topics ;
8291 }
8392
84- public String getLogIndex () {
85- return logIndex ;
93+ public long getLogIndex () {
94+ if (!BasicUtils .isEmpty (logIndex )){
95+ _logIndex = BasicUtils .parseHex (logIndex ).longValue ();
96+ }
97+ return _logIndex ;
8698 }
8799 //</editor-fold>
88100}
0 commit comments