Matthias Andreas Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame^] | 1 | package eu.mulk.jgvariant.ostree; |
| 2 | |
| 3 | import eu.mulk.jgvariant.core.Decoder; |
| 4 | |
| 5 | /** |
| 6 | * A wrapper for {@link ByteString} that refers to a content-addressed object in an OSTree |
| 7 | * repository. |
| 8 | */ |
| 9 | public record Checksum(ByteString bytes) { |
| 10 | |
| 11 | private static final Decoder<Checksum> DECODER = ByteString.decoder().map(Checksum::new); |
| 12 | |
| 13 | public static Decoder<Checksum> decoder() { |
| 14 | return DECODER; |
| 15 | } |
| 16 | |
| 17 | public String hex() { |
| 18 | return bytes.hex(); |
| 19 | } |
| 20 | |
| 21 | public static Checksum ofHex(String hex) { |
| 22 | return new Checksum(ByteString.ofHex(hex)); |
| 23 | } |
| 24 | } |