forked from DannaGuo/java-tron
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKey.java
More file actions
32 lines (25 loc) · 647 Bytes
/
Key.java
File metadata and controls
32 lines (25 loc) · 647 Bytes
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
package org.tron.core.db2.common;
import java.util.Arrays;
import lombok.EqualsAndHashCode;
import org.tron.core.db.common.WrappedByteArray;
@EqualsAndHashCode
public final class Key {
final private WrappedByteArray data;
private Key(WrappedByteArray data) {
this.data = data;
}
public static Key of(byte[] bytes) {
byte[] key = null;
if (bytes != null) {
key = Arrays.copyOf(bytes, bytes.length);
}
return new Key(WrappedByteArray.of(key));
}
public byte[] getBytes() {
byte[] key = data.getBytes();
if (key == null) {
return null;
}
return Arrays.copyOf(key, key.length);
}
}