commoble.exmachina.util

## Class NBTListCodec<ENTRY,RAW>

- java.lang.Object
- - commoble.exmachina.util.NBTListCodec<ENTRY,RAW>

    public class NBTListCodec<ENTRY,RAW>
    extends java.lang.Object

Helper class for converting lists or list-like collections of arbitrary data to NBT and back.

### Nested Class Summary

Nested Classes
`static class` `NBTListCodec.ListNBTType<RAW>`

### Constructor Summary

Constructors
Constructor and Description
`NBTListCodec(java.lang.String name, NBTListCodec.ListNBTType<RAW> type, java.util.function.Function<ENTRY,RAW> elementWriter, java.util.function.Function<RAW,ENTRY> elementReader)`

### Method Summary

All Methods Instance Methods Concrete Methods
`java.util.List<ENTRY>` `read(net.minecraft.nbt.CompoundNBT compound)` Reconstructs and returns a List from a CompoundNBT If the nbt used was given by this.write(list), the list returned will be a reconstruction of the original List
`net.minecraft.nbt.CompoundNBT` `write(java.util.List<ENTRY> list, net.minecraft.nbt.CompoundNBT compound)` Given a list and a CompoundNBT,writes the contents of that list 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

#### NBTListCodec

    public NBTListCodec(java.lang.String name,
                        NBTListCodec.ListNBTType<RAW> type,
                        java.util.function.Function<ENTRY,RAW> elementWriter,
                        java.util.function.Function<RAW,ENTRY> elementReader)

Parameters:
  `name` - A string to use as the field name when we write the list into existing nbt
  `type` - A ListNBTType that describes how to get data out of the list and convert primitives to NBT
  `elementWriter` - A function that converts an entry instance to the intermediate raw type
  `elementReader` - A function that converts the raw instance back into an entry instance

### Method Detail

#### read

    public java.util.List<ENTRY> read(net.minecraft.nbt.CompoundNBT compound)

Reconstructs and returns a List from a CompoundNBT If the nbt used was given by this.write(list), the list returned will be a reconstruction of the original List

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

#### write

    public net.minecraft.nbt.CompoundNBT write(java.util.List<ENTRY> list,
                                               net.minecraft.nbt.CompoundNBT compound)

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

Parameters:
  `list` - A List to write into the nbt
  `compound` - A CompoundNBT to write the list 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 list