1313 * See the License for the specific language governing permissions and
1414 * limitations under the License.
1515 */
16- package org .glavo .nbt . tag ;
16+ package org .glavo .nbt ;
1717
18- import org .glavo .nbt .MinecraftEdition ;
19- import org .glavo .nbt .internal . input . TagLoaderImpl ;
18+ import org .glavo .nbt .internal . NBTCodecImpl ;
19+ import org .glavo .nbt .tag . Tag ;
2020import org .jetbrains .annotations .ApiStatus ;
2121import org .jetbrains .annotations .Contract ;
2222import org .jetbrains .annotations .Nullable ;
2828import java .nio .file .Path ;
2929
3030/// The loader for reading NBT tags.
31- public sealed interface TagLoader permits TagLoaderImpl {
31+ public sealed interface NBTCodec permits NBTCodecImpl {
3232
33- /// Returns the default [TagLoader ].
33+ /// Returns the default [NBTCodec ].
3434 @ Contract (pure = true )
35- static TagLoader getDefault () {
36- return TagLoaderImpl .DEFAULT ;
35+ static NBTCodec getDefault () {
36+ return NBTCodecImpl .DEFAULT ;
3737 }
3838
39- /// Returns a new [TagLoader .Builder].
39+ /// Returns a new [NBTCodec .Builder].
4040 @ Contract ("-> new" )
41- static TagLoader .Builder newBuilder () {
42- return new TagLoaderImpl .BuilderImpl ();
41+ static NBTCodec .Builder newBuilder () {
42+ return new NBTCodecImpl .BuilderImpl ();
4343 }
4444
4545 /// Returns whether the loader automatically decompresses the NBT data.
@@ -60,74 +60,74 @@ static TagLoader.Builder newBuilder() {
6060
6161 /// Loads a NBT tag from a byte array.
6262 @ Contract (pure = true )
63- Tag load (byte [] array ) throws IOException ;
63+ Tag readTag (byte [] array ) throws IOException ;
6464
6565 /// Loads the specified NBT tag from a byte array.
6666 @ Contract (pure = true )
67- default <T extends Tag > T load (byte [] array , Class <T > tagClass ) throws IOException {
68- return check (load (array ), tagClass );
67+ default <T extends Tag > T readTag (byte [] array , Class <T > tagClass ) throws IOException {
68+ return check (readTag (array ), tagClass );
6969 }
7070
7171 /// Loads a NBT tag from a byte array with the specified offset and length.
7272 @ Contract (pure = true )
73- default Tag load (byte [] array , int offset , int length ) throws IOException {
74- return load (ByteBuffer .wrap (array , offset , length ));
73+ default Tag readTag (byte [] array , int offset , int length ) throws IOException {
74+ return readTag (ByteBuffer .wrap (array , offset , length ));
7575 }
7676
7777 /// Loads the specified NBT tag from a byte array with the specified offset and length.
7878 @ Contract (pure = true )
79- default <T extends Tag > T load (byte [] array , int offset , int length , Class <T > tagClass ) throws IOException {
80- return check (load (array , offset , length ), tagClass );
79+ default <T extends Tag > T readTag (byte [] array , int offset , int length , Class <T > tagClass ) throws IOException {
80+ return check (readTag (array , offset , length ), tagClass );
8181 }
8282
8383 /// Loads a NBT tag from a byte buffer.
8484 ///
8585 /// This method does not change the position and the limit of the buffer.
8686 @ Contract (pure = true )
87- Tag load (ByteBuffer buffer ) throws IOException ;
87+ Tag readTag (ByteBuffer buffer ) throws IOException ;
8888
8989 /// Loads the specified NBT tag from a byte buffer.
9090 ///
9191 /// This method does not change the position and the limit of the buffer.
9292 @ Contract (pure = true )
93- default <T extends Tag > T load (ByteBuffer buffer , Class <T > tagClass ) throws IOException {
94- return check (load (buffer ), tagClass );
93+ default <T extends Tag > T readTag (ByteBuffer buffer , Class <T > tagClass ) throws IOException {
94+ return check (readTag (buffer ), tagClass );
9595 }
9696
9797 /// Loads a NBT tag from an input stream.
9898 ///
9999 /// After this method is called, the state of the `inputStream` is undefined.
100100 @ Contract (mutates = "param1" )
101- Tag load (InputStream inputStream ) throws IOException ;
101+ Tag readTag (InputStream inputStream ) throws IOException ;
102102
103103 /// Loads the specified NBT tag from an input stream.
104104 ///
105105 /// After this method is called, the state of the `inputStream` is undefined.
106106 @ Contract (mutates = "param1" )
107- default <T extends Tag > T load (InputStream inputStream , Class <T > tagClass ) throws IOException {
108- return check (load (inputStream ), tagClass );
107+ default <T extends Tag > T readTag (InputStream inputStream , Class <T > tagClass ) throws IOException {
108+ return check (readTag (inputStream ), tagClass );
109109 }
110110
111111 /// Loads a NBT tag from a readable byte channel.
112112 ///
113113 /// After this method is called, the state of the `channel` is undefined.
114114 @ Contract (mutates = "param1" )
115- Tag load (ReadableByteChannel channel ) throws IOException ;
115+ Tag readTag (ReadableByteChannel channel ) throws IOException ;
116116
117117 /// Loads the specified NBT tag from a readable byte channel.
118118 ///
119119 /// After this method is called, the state of the `channel` is undefined.
120120 @ Contract (mutates = "param1" )
121- default <T extends Tag > T load (ReadableByteChannel channel , Class <T > tagClass ) throws IOException {
122- return check (load (channel ), tagClass );
121+ default <T extends Tag > T readTag (ReadableByteChannel channel , Class <T > tagClass ) throws IOException {
122+ return check (readTag (channel ), tagClass );
123123 }
124124
125125 /// Loads a NBT tag from a file.
126- Tag load (Path path ) throws IOException ;
126+ Tag readTag (Path path ) throws IOException ;
127127
128128 /// Loads the specified NBT tag from a file.
129- default <T extends Tag > T load (Path path , Class <T > tagClass ) throws IOException {
130- return check (load (path ), tagClass );
129+ default <T extends Tag > T readTag (Path path , Class <T > tagClass ) throws IOException {
130+ return check (readTag (path ), tagClass );
131131 }
132132
133133 private static <T extends Tag > T check (@ Nullable Tag tag , Class <T > tagClass ) throws IOException {
@@ -141,8 +141,8 @@ private static <T extends Tag> T check(@Nullable Tag tag, Class<T> tagClass) thr
141141 }
142142 }
143143
144- /// The builder for creating a [TagLoader ].
145- sealed interface Builder permits TagLoaderImpl .BuilderImpl {
144+ /// The builder for creating a [NBTCodec ].
145+ sealed interface Builder permits NBTCodecImpl .BuilderImpl {
146146
147147 /// Sets the Minecraft edition of the NBT data.
148148 ///
@@ -160,7 +160,7 @@ sealed interface Builder permits TagLoaderImpl.BuilderImpl {
160160 @ Contract (value = "_ -> this" , mutates = "this" )
161161 Builder setAutoDecompress (boolean autoDecompress );
162162
163- /// Builds a new [TagLoader ] with the specified configuration.
164- TagLoader build ();
163+ /// Builds a new [NBTCodec ] with the specified configuration.
164+ NBTCodec build ();
165165 }
166166}
0 commit comments