package com.voxelwind.nbt.util;

import com.voxelwind.nbt.tags.*;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

import java.util.HashMap;
import java.util.Map;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class CompoundTagBuilder {
    private final Map<String, Tag<?>> tagMap = new HashMap<>();

    public static CompoundTagBuilder builder() {
        return new CompoundTagBuilder();
    }

    public static CompoundTagBuilder from(CompoundTag tag) {
        CompoundTagBuilder builder = new CompoundTagBuilder();
        builder.tagMap.putAll(tag.getValue());
        return builder;
    }

    public CompoundTagBuilder tag(Tag<?> tag) {
        tagMap.put(tag.getName(), tag);
        return this;
    }

    public CompoundTagBuilder tag(String name, byte value) {
        return tag(new ByteTag(name, value));
    }

    public CompoundTagBuilder tag(String name, byte [] value) {
        return tag(new ByteArrayTag(name, value));
    }

    public CompoundTagBuilder tag(String name, double value) {
        return tag(new DoubleTag(name, value));
    }

    public CompoundTagBuilder tag(String name, float value) {
        return tag(new FloatTag(name, value));
    }

    public CompoundTagBuilder tag(String name, int[] value) {
        return tag(new IntArrayTag(name, value));
    }

    public CompoundTagBuilder tag(String name, int value) {
        return tag(new IntTag(name, value));
    }

    public CompoundTagBuilder tag(String name, long value) {
        return tag(new LongTag(name, value));
    }

    public CompoundTagBuilder tag(String name, short value) {
        return tag(new ShortTag(name, value));
    }

    public CompoundTagBuilder tag(String name, String value) {
        return tag(new StringTag(name, value));
    }

    public CompoundTagBuilder tag (String name, CompoundTag value) {
        tagMap.put(name, value);
        return this;
    }

    public CompoundTagBuilder tag(String name, ListTag value) {
        tagMap.put(name, value);
        return this;
    }

    public CompoundTag buildRootTag() {
        return new CompoundTag("", tagMap);
    }

    public CompoundTag build(String tagName) {
        return new CompoundTag(tagName, tagMap);
    }
}

@@ -757,32 +757,37 @@
 ndTagBuilder tag
+Byte 
 (String name, by
@@ -876,32 +876,42 @@
 ndTagBuilder tag
+ByteArray 
 (String name, by
@@ -1008,32 +1008,39 @@
 ndTagBuilder tag
+Double 
 (String name, do
@@ -1133,32 +1133,38 @@
 ndTagBuilder tag
+Float 
 (String name, fl
@@ -1255,32 +1255,41 @@
 ndTagBuilder tag
+IntArray 
 (String name, in
@@ -1383,32 +1383,36 @@
 ndTagBuilder tag
+Int 
 (String name, in
@@ -1499,32 +1499,37 @@
 ndTagBuilder tag
+Long 
 (String name, lo
@@ -1618,32 +1618,38 @@
 ndTagBuilder tag
+Short 
 (String name, sh
@@ -1740,32 +1740,39 @@
 ndTagBuilder tag
+String 
 (String name, St
@@ -1873,16 +1873,27 @@
 lder tag
+CompoundTag
  (String
@@ -2014,16 +2014,23 @@
 lder tag
+ListTag
 (String 

Add type-related tag methods to nbt-builder