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 | import java.nio.ByteOrder; |
| 5 | |
| 6 | /** |
| 7 | * A fallback entry in a {@link DeltaSuperblock}. |
| 8 | * |
Matthias Andreas Benkard | 0511464 | 2021-12-29 21:51:29 +0100 | [diff] [blame] | 9 | * <p>References a file in the OSTree repository. |
| 10 | * |
Matthias Andreas Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame] | 11 | * <p>Reference: {@code ostree-repo-static-delta-private.h#OSTREE_STATIC_DELTA_FALLBACK_FORMAT} |
Matthias Andreas Benkard | 0511464 | 2021-12-29 21:51:29 +0100 | [diff] [blame] | 12 | * |
| 13 | * @param objectType the object type of the file represented by this fallback entry. |
| 14 | * @param checksum the checksum of the file represented by this fallback entry. |
| 15 | * @param compressedSize the compressed size of the file represented by this fallback entry. |
| 16 | * @param uncompressedSize the uncompressed size of the file represented by this fallback entry. |
Matthias Andreas Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame] | 17 | */ |
| 18 | public record DeltaFallback( |
Matthias Andreas Benkard | 0511464 | 2021-12-29 21:51:29 +0100 | [diff] [blame] | 19 | ObjectType objectType, Checksum checksum, long compressedSize, long uncompressedSize) { |
Matthias Andreas Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame] | 20 | |
| 21 | private static final Decoder<DeltaFallback> DECODER = |
| 22 | Decoder.ofStructure( |
| 23 | DeltaFallback.class, |
Matthias Andreas Benkard | 0511464 | 2021-12-29 21:51:29 +0100 | [diff] [blame] | 24 | Decoder.ofByte().map(ObjectType::valueOf), |
Matthias Andreas Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame] | 25 | Checksum.decoder(), |
Matthias Andreas Benkard | a8514a3 | 2021-12-30 21:01:48 +0100 | [diff] [blame^] | 26 | Decoder.ofLong(), |
| 27 | Decoder.ofLong()); |
Matthias Andreas Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame] | 28 | |
Matthias Andreas Benkard | 0511464 | 2021-12-29 21:51:29 +0100 | [diff] [blame] | 29 | /** |
| 30 | * Acquires a {@link Decoder} for the enclosing type. |
| 31 | * |
Matthias Andreas Benkard | a8514a3 | 2021-12-30 21:01:48 +0100 | [diff] [blame^] | 32 | * <p><strong>Note:</strong> This decoder has an unspecified {@link ByteOrder}. |
| 33 | * |
Matthias Andreas Benkard | 0511464 | 2021-12-29 21:51:29 +0100 | [diff] [blame] | 34 | * @return a possibly shared {@link Decoder}. |
| 35 | */ |
Matthias Andreas Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame] | 36 | public static Decoder<DeltaFallback> decoder() { |
| 37 | return DECODER; |
| 38 | } |
Matthias Andreas Benkard | a8514a3 | 2021-12-30 21:01:48 +0100 | [diff] [blame^] | 39 | |
| 40 | DeltaFallback byteSwapped() { |
| 41 | return new DeltaFallback(objectType, checksum, compressedSize, uncompressedSize); |
| 42 | } |
Matthias Andreas Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame] | 43 | } |