-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathGroupMetadata.java
More file actions
63 lines (54 loc) · 2.26 KB
/
GroupMetadata.java
File metadata and controls
63 lines (54 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package dev.zarr.zarrjava.v3;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import dev.zarr.zarrjava.ZarrException;
import dev.zarr.zarrjava.core.Attributes;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public final class GroupMetadata extends dev.zarr.zarrjava.core.GroupMetadata {
static final String NODE_TYPE = "group";
static final int ZARR_FORMAT = 3;
@JsonProperty("zarr_format")
public final int zarrFormat = ZARR_FORMAT;
@JsonProperty("node_type")
public final String nodeType = "group";
@JsonProperty("consolidated_metadata")
public final Object consolidatedMetadata = null;
@Nullable
public final Attributes attributes;
public GroupMetadata(@Nullable Attributes attributes) throws ZarrException {
this(ZARR_FORMAT, NODE_TYPE, attributes);
}
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
public GroupMetadata(
@JsonProperty(value = "zarr_format", required = true) int zarrFormat,
@JsonProperty(value = "node_type", required = true) String nodeType,
@Nullable @JsonProperty(value = "attributes") Attributes attributes
) throws ZarrException {
if (zarrFormat != this.zarrFormat) {
throw new ZarrException(
"Expected zarr format '" + this.zarrFormat + "', got '" + zarrFormat + "'.");
}
if (!nodeType.equals(this.nodeType)) {
throw new ZarrException(
"Expected node type '" + this.nodeType + "', got '" + nodeType + "'.");
}
this.attributes = attributes;
}
public static GroupMetadata defaultValue() {
try {
return new GroupMetadata(ZARR_FORMAT, NODE_TYPE, new Attributes());
} catch (ZarrException e) {
// This should never happen with default values
throw new IllegalStateException(
"Failed to create default GroupMetadata - this indicates a programming error", e);
}
}
@Override
public @Nonnull Attributes attributes() throws ZarrException {
if (attributes == null) {
throw new ZarrException("Group attributes have not been set.");
}
return attributes;
}
}