commoble.databuddy.nbt

## Class NBTMapCodec<KEY,VALUE>

- java.lang.Object
- - commoble.databuddy.nbt.NBTMapCodec<KEY,VALUE>

    public class NBTMapCodec<KEY,VALUE>
    extends java.lang.Object

Helper class for writing a Map into a CompoundNBT

### Constructor Summary

Constructors
Constructor and Description
`NBTMapCodec(java.lang.String name, java.util.function.BiConsumer<net.minecraft.nbt.CompoundNBT,KEY> keyWriter, java.util.function.Function<net.minecraft.nbt.CompoundNBT,KEY> keyReader, java.util.function.BiConsumer<net.minecraft.nbt.CompoundNBT,VALUE> valueWriter, java.util.function.Function<net.minecraft.nbt.CompoundNBT,VALUE> valueReader)`

### Method Summary

All Methods Instance Methods Concrete Methods
`java.util.Map<KEY,VALUE>` `read(net.minecraft.nbt.CompoundNBT nbt)` Reconstructs and returns a Map<KEY,VALUE> from a CompoundNBT If the nbt used was given by this.write(map), the map returned will be a reconstruction of the original Map
`net.minecraft.nbt.CompoundNBT` `write(java.util.Map<KEY,VALUE> map, net.minecraft.nbt.CompoundNBT compound)` Given a map and a CompoundNBT, writes the map into the NBT The same compoundNBT can be given to this.read to retrieve that map

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### NBTMapCodec

    public NBTMapCodec(java.lang.String name,
                       java.util.function.BiConsumer<net.minecraft.nbt.CompoundNBT,KEY> keyWriter,
                       java.util.function.Function<net.minecraft.nbt.CompoundNBT,KEY> keyReader,
                       java.util.function.BiConsumer<net.minecraft.nbt.CompoundNBT,VALUE> valueWriter,
                       java.util.function.Function<net.minecraft.nbt.CompoundNBT,VALUE> valueReader)

Parameters:
  `name` - A unique identifier for the hashmap, allowing the map to be written into a CompoundNBT alongside other data
  `keyWriter` - A function that, given a compoundNBT and a Key, writes that Key into the NBT
  `keyReader` - A function that, given a compoundNBT, returns the Key written in that NBT
  `valueWriter` - A function that, given a compoundNBT and a Value, writes that Value into the NBT
  `valueReader` - A Function that ,given a compoundNBT, returns the Value written in that NBT

### Method Detail

#### read

    public java.util.Map<KEY,VALUE> read(net.minecraft.nbt.CompoundNBT nbt)

Reconstructs and returns a Map<KEY,VALUE> from a CompoundNBT If the nbt used was given by this.write(map), the map returned will be a reconstruction of the original Map

Parameters:
  `nbt` - The CompoundNBT to read and construct the Map from
Returns:
  A Map that the data contained in the CompoundNBT represents

#### write

    public net.minecraft.nbt.CompoundNBT write(java.util.Map<KEY,VALUE> map,
                                               net.minecraft.nbt.CompoundNBT compound)

Given a map and a CompoundNBT, writes the map into the NBT The same compoundNBT can be given to this.read to retrieve that map

Parameters:
  `map` - A Map<KEY,VALUE>
  `compound` - A CompoundNBT to write the map into
Returns:
  a CompoundNBT that, when used as the argument to this.read(nbt), will cause that function to reconstruct and return a copy of the original map