44import dev .zarr .zarrjava .ZarrException ;
55import dev .zarr .zarrjava .core .Attributes ;
66import dev .zarr .zarrjava .store .FilesystemStore ;
7+ import dev .zarr .zarrjava .store .MemoryStore ;
78import dev .zarr .zarrjava .store .StoreHandle ;
89import dev .zarr .zarrjava .utils .Utils ;
910import java .io .IOException ;
@@ -30,48 +31,122 @@ protected Group(@Nonnull StoreHandle storeHandle, @Nonnull GroupMetadata groupMe
3031 public static Group open (@ Nonnull StoreHandle storeHandle ) throws IOException {
3132 StoreHandle metadataHandle = storeHandle .resolve (ZARR_JSON );
3233 ByteBuffer metadataBytes = metadataHandle .readNonNull ();
33- return new Group (storeHandle , makeObjectMapper ()
34- .readValue (Utils .toArray (metadataBytes ), GroupMetadata .class ));
34+ return new Group (storeHandle , makeObjectMapper ().readValue (Utils .toArray (metadataBytes ), GroupMetadata .class ));
3535 }
3636
37-
38- public static Group open (Path path ) throws IOException {
39- return open (new StoreHandle (new FilesystemStore (path )));
40- }
4137
42- public static Group open (String path ) throws IOException {
43- return open (Paths .get (path ));
44- }
45-
46- public static Group create (
47- @ Nonnull StoreHandle storeHandle , @ Nonnull GroupMetadata groupMetadata
48- ) throws IOException {
38+ public static Group open (Path path ) throws IOException {
39+ return open (new StoreHandle (new FilesystemStore (path )));
40+ }
41+
42+ public static Group open (String path ) throws IOException {
43+ return open (Paths .get (path ));
44+ }
45+
46+ /**
47+ * Creates a new Zarr group with default metadata in an in-memory store.
48+ *
49+ * @throws IOException if the metadata cannot be serialized
50+ */
51+ public static Group create () throws IOException {
52+ return new Group (new MemoryStore ().resolve (), GroupMetadata .defaultValue ()).writeMetadata ();
53+ }
54+
55+ /**
56+ * Creates a new Zarr group with the provided metadata in an in-memory store.
57+ *
58+ * @param attributes the attributes of the Zarr group
59+ * @throws IOException if the metadata cannot be serialized
60+ * @throws ZarrException if the attributes are invalid
61+ */
62+ public static Group create (@ Nonnull Attributes attributes ) throws IOException , ZarrException {
63+ return new Group (new MemoryStore ().resolve (), new GroupMetadata (attributes )).writeMetadata ();
64+ }
65+
66+ /**
67+ * Creates a new Zarr group with the provided metadata in an in-memory store.
68+ *
69+ * @param groupMetadata the metadata of the Zarr group
70+ * @throws IOException if the metadata cannot be serialized
71+ */
72+ public static Group create (@ Nonnull GroupMetadata groupMetadata ) throws IOException {
73+ return new Group (new MemoryStore ().resolve (), groupMetadata ).writeMetadata ();
74+ }
75+
76+ /**
77+ * Creates a new Zarr group with the provided metadata at a specified storage location.
78+ *
79+ * @param storeHandle the storage location of the Zarr group
80+ * @param groupMetadata the metadata of the Zarr group
81+ * @throws IOException if the metadata cannot be serialized
82+ */
83+ public static Group create (@ Nonnull StoreHandle storeHandle , @ Nonnull GroupMetadata groupMetadata ) throws IOException {
4984 return new Group (storeHandle , groupMetadata ).writeMetadata ();
5085 }
5186
87+ /**
88+ * Creates a new Zarr group with the provided metadata at a specified storage location.
89+ *
90+ * @param storeHandle the storage location of the Zarr group
91+ * @param attributes attributes of the Zarr group
92+ * @throws IOException if the metadata cannot be serialized
93+ * @throws ZarrException if the attributes are invalid
94+ */
5295 public static Group create (
5396 @ Nonnull StoreHandle storeHandle ,
5497 @ Nonnull Attributes attributes
5598 ) throws IOException , ZarrException {
5699 return create (storeHandle , new GroupMetadata (attributes ));
57100 }
58101
59- public static Group create (@ Nonnull StoreHandle storeHandle ) throws IOException , ZarrException {
102+ /**
103+ * Creates a new Zarr group with the provided metadata at a specified storage location.
104+ *
105+ * @param storeHandle the storage location of the Zarr group
106+ * @throws IOException if the metadata cannot be serialized
107+ */
108+ public static Group create (@ Nonnull StoreHandle storeHandle ) throws IOException {
60109 return create (storeHandle , GroupMetadata .defaultValue ());
61110 }
62111
112+ /**
113+ * Creates a new Zarr group with the provided metadata at a specified storage location.
114+ *
115+ * @param path the storage location of the Zarr group
116+ * @param groupMetadata the metadata of the Zarr group
117+ * @throws IOException if the metadata cannot be serialized
118+ */
63119 public static Group create (Path path , GroupMetadata groupMetadata ) throws IOException , ZarrException {
64120 return create (new FilesystemStore (path ).resolve (), groupMetadata );
65121 }
66122
123+ /**
124+ * Creates a new Zarr group with the provided metadata at a specified storage location.
125+ *
126+ * @param path the storage location of the Zarr group
127+ * @param groupMetadata the metadata of the Zarr group
128+ * @throws IOException if the metadata cannot be serialized
129+ */
67130 public static Group create (String path , GroupMetadata groupMetadata ) throws IOException , ZarrException {
68131 return create (Paths .get (path ), groupMetadata );
69132 }
70133
134+ /**
135+ * Creates a new Zarr group with the provided metadata at a specified storage location.
136+ *
137+ * @param path the storage location of the Zarr group
138+ * @throws IOException if the metadata cannot be serialized
139+ */
71140 public static Group create (Path path ) throws IOException , ZarrException {
72141 return create (new FilesystemStore (path ).resolve ());
73142 }
74143
144+ /**
145+ * Creates a new Zarr group with the provided metadata at a specified storage location.
146+ *
147+ * @param path the storage location of the Zarr group
148+ * @throws IOException if the metadata cannot be serialized
149+ */
75150 public static Group create (String path ) throws IOException , ZarrException {
76151 return create (Paths .get (path ));
77152 }
@@ -86,25 +161,59 @@ public Node get(String key) throws ZarrException, IOException{
86161 }
87162 }
88163
164+ /**
165+ * Creates a new subgroup with the provided metadata at the specified key.
166+ *
167+ * @param key the key of the new Zarr group within the current group
168+ * @param groupMetadata the metadata of the Zarr group
169+ * @throws IOException if the metadata cannot be serialized
170+ */
89171 public Group createGroup (String key , GroupMetadata groupMetadata )
90- throws IOException , ZarrException {
172+ throws IOException , ZarrException {
91173 return Group .create (storeHandle .resolve (key ), groupMetadata );
92174 }
93175
176+ /**
177+ * Creates a new subgroup with the provided attributes at the specified key.
178+ *
179+ * @param key the key of the new Zarr group within the current group
180+ * @param attributes attributes of the Zarr group
181+ * @throws IOException if the metadata cannot be serialized
182+ */
94183 public Group createGroup (String key , Attributes attributes )
95- throws IOException , ZarrException {
184+ throws IOException , ZarrException {
96185 return Group .create (storeHandle .resolve (key ), new GroupMetadata (attributes ));
97186 }
98187
99- public Group createGroup (String key ) throws IOException , ZarrException {
188+ /**
189+ * Creates a new subgroup with default metadata at the specified key.
190+ *
191+ * @param key the key of the new Zarr group within the current group
192+ * @throws IOException if the metadata cannot be serialized
193+ */
194+ public Group createGroup (String key ) throws IOException {
100195 return Group .create (storeHandle .resolve (key ), GroupMetadata .defaultValue ());
101196 }
102197
198+ /**
199+ * Creates a new array with the provided metadata at the specified key.
200+ *
201+ * @param key the key of the new Zarr array within the current group
202+ * @param arrayMetadata the metadata of the Zarr array
203+ * @throws IOException if the metadata cannot be serialized
204+ */
103205 public Array createArray (String key , ArrayMetadata arrayMetadata )
104- throws IOException , ZarrException {
206+ throws IOException , ZarrException {
105207 return Array .create (storeHandle .resolve (key ), arrayMetadata );
106208 }
107209
210+ /**
211+ * Creates a new array with the provided metadata builder mapper at the specified key.
212+ *
213+ * @param key the key of the new Zarr array within the current group
214+ * @param arrayMetadataBuilderMapper a function building the metadata of the Zarr array
215+ * @throws IOException if the metadata cannot be serialized
216+ */
108217 public Array createArray (String key ,
109218 Function <ArrayMetadataBuilder , ArrayMetadataBuilder > arrayMetadataBuilderMapper )
110219 throws IOException , ZarrException {
0 commit comments