forked from GoodforGod/java-etherscan-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLog.java
More file actions
176 lines (153 loc) · 5.47 KB
/
Copy pathLog.java
File metadata and controls
176 lines (153 loc) · 5.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
package io.api.etherscan.model;
import com.google.gson.annotations.Expose;
import io.api.etherscan.util.BasicUtils;
import java.math.BigInteger;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.List;
import java.util.Objects;
/**
* ! NO DESCRIPTION !
*
* @author GoodforGod
* @since 31.10.2018
*/
public class Log {
private String blockNumber;
@Expose(serialize = false, deserialize = false)
private Long _blockNumber;
private String address;
private String transactionHash;
private String transactionIndex;
@Expose(serialize = false, deserialize = false)
private Long _transactionIndex;
private String timeStamp;
@Expose(serialize = false, deserialize = false)
private LocalDateTime _timeStamp;
private String data;
private String gasPrice;
@Expose(serialize = false, deserialize = false)
private BigInteger _gasPrice;
private String gasUsed;
@Expose(serialize = false, deserialize = false)
private BigInteger _gasUsed;
private List<String> topics;
private String logIndex;
@Expose(serialize = false, deserialize = false)
private Long _logIndex;
// <editor-fold desc="Getters">
public Long getBlockNumber() {
if (_blockNumber == null && !BasicUtils.isEmpty(blockNumber)) {
_blockNumber = BasicUtils.parseHex(blockNumber).longValue();
}
return _blockNumber;
}
public String getAddress() {
return address;
}
public String getTransactionHash() {
return transactionHash;
}
public Long getTransactionIndex() {
if (_transactionIndex == null && !BasicUtils.isEmpty(transactionIndex)) {
_transactionIndex = BasicUtils.parseHex(transactionIndex).longValue();
}
return _transactionIndex;
}
public LocalDateTime getTimeStamp() {
if (_timeStamp == null && !BasicUtils.isEmpty(timeStamp)) {
long formatted = (timeStamp.charAt(0) == '0' && timeStamp.charAt(1) == 'x')
? BasicUtils.parseHex(timeStamp).longValue()
: Long.parseLong(timeStamp);
_timeStamp = LocalDateTime.ofEpochSecond(formatted, 0, ZoneOffset.UTC);
}
return _timeStamp;
}
/**
* Return the "timeStamp" field of the event record as a long-int representing the milliseconds
* since the Unix epoch (1970-01-01 00:00:00).
*
* @return milliseconds between Unix epoch and `timeStamp`. If field is empty or null, returns null
*/
public Long getTimeStampAsMillis() {
if (BasicUtils.isEmpty(timeStamp)) {
return null;
}
long tsSecs = (timeStamp.charAt(0) == '0' && timeStamp.charAt(1) == 'x')
? BasicUtils.parseHex(timeStamp).longValue()
: Long.parseLong(timeStamp);
return tsSecs * 1000;
}
public String getData() {
return data;
}
public BigInteger getGasPrice() {
if (!BasicUtils.isEmpty(gasPrice)) {
_gasPrice = BasicUtils.parseHex(gasPrice);
}
return _gasPrice;
}
public BigInteger getGasUsed() {
if (!BasicUtils.isEmpty(gasUsed)) {
_gasUsed = BasicUtils.parseHex(gasUsed);
}
return _gasUsed;
}
public List<String> getTopics() {
return topics;
}
public Long getLogIndex() {
if (_logIndex == null && !BasicUtils.isEmpty(logIndex)) {
_logIndex = BasicUtils.parseHex(logIndex).longValue();
}
return _logIndex;
}
// </editor-fold>
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
Log log = (Log) o;
if (!Objects.equals(blockNumber, log.blockNumber))
return false;
if (!Objects.equals(address, log.address))
return false;
if (!Objects.equals(transactionHash, log.transactionHash))
return false;
if (!Objects.equals(timeStamp, log.timeStamp))
return false;
return Objects.equals(logIndex, log.logIndex);
}
@Override
public int hashCode() {
int result = blockNumber != null ? blockNumber.hashCode() : 0;
result = 31 * result + (address != null ? address.hashCode() : 0);
result = 31 * result + (transactionHash != null ? transactionHash.hashCode() : 0);
result = 31 * result + (timeStamp != null ? timeStamp.hashCode() : 0);
result = 31 * result + (logIndex != null ? logIndex.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "Log{" +
"blockNumber='" + blockNumber + '\'' +
", _blockNumber=" + _blockNumber +
", address='" + address + '\'' +
", transactionHash='" + transactionHash + '\'' +
", transactionIndex='" + transactionIndex + '\'' +
", _transactionIndex=" + _transactionIndex +
", timeStamp='" + timeStamp + '\'' +
", _timeStamp=" + _timeStamp +
", data='" + data + '\'' +
", gasPrice='" + gasPrice + '\'' +
", _gasPrice=" + _gasPrice +
", gasUsed='" + gasUsed + '\'' +
", _gasUsed=" + _gasUsed +
", topics=" + topics +
", logIndex='" + logIndex + '\'' +
", _logIndex=" + _logIndex +
'}';
}
}