Properly document jgvariant-ostree.
Change-Id: I0aa3b1df512ef99d0e25d73efdd34a1b488e7d0d
diff --git a/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/DeltaMetaEntry.java b/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/DeltaMetaEntry.java
index 39ada86..0eaea73 100644
--- a/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/DeltaMetaEntry.java
+++ b/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/DeltaMetaEntry.java
@@ -1,22 +1,46 @@
package eu.mulk.jgvariant.ostree;
import eu.mulk.jgvariant.core.Decoder;
+import java.nio.ByteBuffer;
import java.nio.ByteOrder;
+import java.util.ArrayList;
import java.util.List;
/**
* An entry in a {@link DeltaSuperblock}.
*
* <p>Reference: {@code ostree-repo-static-delta-private.h#OSTREE_STATIC_DELTA_META_ENTRY_FORMAT}
+ *
+ * @param version the version corresponding to the version of {@link DeltaPartPayload}; always 0.
+ * @param checksum the checksum of the {@link DeltaPartPayload}.
+ * @param compressedSize the total compressed size of the delta.
+ * @param uncompressedSize the total uncompressed size of the files generated by the delta.
+ * @param objects a list of objects generated by the delta payload.
*/
public record DeltaMetaEntry(
- int version, Checksum checksum, long size, long usize, List<DeltaObject> objects) {
+ int version,
+ Checksum checksum,
+ long compressedSize,
+ long uncompressedSize,
+ List<DeltaObject> objects) {
- record DeltaObject(byte objectType, Checksum checksum) {
+ /**
+ * A reference to an object generated by a {@link DeltaPartPayload}.
+ *
+ * @param objectType the file type.
+ * @param checksum the checksum of the resulting file.
+ */
+ public record DeltaObject(ObjectType objectType, Checksum checksum) {
private static final Decoder<DeltaObject> DECODER =
- Decoder.ofStructure(DeltaObject.class, Decoder.ofByte(), Checksum.decoder());
+ Decoder.ofStructure(
+ DeltaObject.class, Decoder.ofByte().map(ObjectType::valueOf), Checksum.decoder());
+ /**
+ * Acquires a {@link Decoder} for the enclosing type.
+ *
+ * @return a possibly shared {@link Decoder}.
+ */
public static Decoder<DeltaObject> decoder() {
return DECODER;
}
@@ -29,9 +53,26 @@
Checksum.decoder(),
Decoder.ofLong().withByteOrder(ByteOrder.LITTLE_ENDIAN), // FIXME: non-canonical
Decoder.ofLong().withByteOrder(ByteOrder.LITTLE_ENDIAN), // FIXME: non-canonical
- Decoder.ofByteArray().map(x -> List.of()) // FIXME
- );
+ Decoder.ofByteArray().map(DeltaMetaEntry::parseObjectList));
+ private static List<DeltaObject> parseObjectList(byte[] bytes) {
+ var byteBuffer = ByteBuffer.wrap(bytes);
+ List<DeltaObject> objects = new ArrayList<>();
+
+ while (byteBuffer.hasRemaining()) {
+ var type = ObjectType.valueOf(byteBuffer.get());
+ var checksum = Checksum.readFrom(byteBuffer);
+ objects.add(new DeltaObject(type, checksum));
+ }
+
+ return objects;
+ }
+
+ /**
+ * Acquires a {@link Decoder} for the enclosing type.
+ *
+ * @return a possibly shared {@link Decoder}.
+ */
public static Decoder<DeltaMetaEntry> decoder() {
return DECODER;
}