forked from ipfs-shipyard/java-ipfs-http-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeyInfo.java
More file actions
44 lines (33 loc) · 1.06 KB
/
KeyInfo.java
File metadata and controls
44 lines (33 loc) · 1.06 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
package io.ipfs.api;
import io.ipfs.cid.*;
import io.ipfs.multihash.*;
import java.util.*;
public class KeyInfo {
public final String name;
public final Multihash id;
public KeyInfo(String name, Multihash id) {
this.name = name;
this.id = id;
}
public String toString() {
return name + ": " + id;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
KeyInfo keyInfo = (KeyInfo) o;
if (name != null ? !name.equals(keyInfo.name) : keyInfo.name != null) return false;
return id != null ? id.equals(keyInfo.id) : keyInfo.id == null;
}
@Override
public int hashCode() {
int result = name != null ? name.hashCode() : 0;
result = 31 * result + (id != null ? id.hashCode() : 0);
return result;
}
public static KeyInfo fromJson(Object json) {
Map<String, String> m = (Map) json;
return new KeyInfo(m.get("Name"), Cid.decode(m.get("Id")));
}
}