Skip to content
This repository was archived by the owner on Mar 15, 2021. It is now read-only.

Commit dad3c4f

Browse files
committed
Add ObjectHashable interface
In order to implement collection types, we need to be able to assign a type to all the primitives we support.
1 parent 9abcfd4 commit dad3c4f

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎src/main/java/ObjectHashable.java‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import java.security.NoSuchAlgorithmException;
2+
3+
public interface ObjectHashable {
4+
default String hexDigest() throws NoSuchAlgorithmException {
5+
StringBuilder sb = new StringBuilder();
6+
for (byte b : getBytes()) {
7+
sb.append(String.format("%02x", b));
8+
}
9+
return sb.toString();
10+
}
11+
12+
byte[] getBytes() throws NoSuchAlgorithmException;
13+
}

0 commit comments

Comments
 (0)