20
20
21
21
package land .oras ;
22
22
23
+ import java .util .Map ;
23
24
import land .oras .utils .JsonUtils ;
24
25
import org .jspecify .annotations .NullMarked ;
25
26
import org .jspecify .annotations .Nullable ;
@@ -35,18 +36,32 @@ public final class ManifestDescriptor {
35
36
private final String digest ;
36
37
private final long size ;
37
38
39
+ @ Nullable
40
+ private final Map <String , String > platform ;
41
+
42
+ @ Nullable
43
+ private final Map <String , String > annotations ;
44
+
38
45
/**
39
46
* Constructor
40
47
* @param artifactType The optional artifact type
41
48
* @param mediaType The media type
42
49
* @param digest The digest
43
50
* @param size The size
44
51
*/
45
- private ManifestDescriptor (@ Nullable String artifactType , String mediaType , String digest , long size ) {
52
+ private ManifestDescriptor (
53
+ @ Nullable String artifactType ,
54
+ String mediaType ,
55
+ String digest ,
56
+ long size ,
57
+ @ Nullable Map <String , String > platform ,
58
+ @ Nullable Map <String , String > annotations ) {
46
59
this .artifactType = artifactType ;
47
60
this .mediaType = mediaType ;
48
61
this .digest = digest ;
49
62
this .size = size ;
63
+ this .platform = platform ;
64
+ this .annotations = annotations ;
50
65
}
51
66
52
67
/**
@@ -81,6 +96,22 @@ public long getSize() {
81
96
return size ;
82
97
}
83
98
99
+ /**
100
+ * Get the platform
101
+ * @return The platform
102
+ */
103
+ public Map <String , String > getPlatform () {
104
+ return platform ;
105
+ }
106
+
107
+ /**
108
+ * Get the annotations
109
+ * @return The annotations
110
+ */
111
+ public Map <String , String > getAnnotations () {
112
+ return annotations ;
113
+ }
114
+
84
115
/**
85
116
* Return the JSON representation of the manifest
86
117
* @return The JSON string
@@ -89,6 +120,15 @@ public String toJson() {
89
120
return JsonUtils .toJson (this );
90
121
}
91
122
123
+ /**
124
+ * Create a manifest descriptor from a JSON string
125
+ * @param json The JSON string
126
+ * @return The manifest
127
+ */
128
+ public static ManifestDescriptor fromJson (String json ) {
129
+ return JsonUtils .fromJson (json , ManifestDescriptor .class );
130
+ }
131
+
92
132
/**
93
133
* Return this manifest descriptor as a subject
94
134
* @return The subject
@@ -105,6 +145,6 @@ public Subject toSubject() {
105
145
* @return The subject
106
146
*/
107
147
public static ManifestDescriptor of (String mediaType , String digest , long size ) {
108
- return new ManifestDescriptor (null , mediaType , digest , size );
148
+ return new ManifestDescriptor (null , mediaType , digest , size , null , null );
109
149
}
110
150
}
0 commit comments