com.intellectualcrafters.jnbt

## Class ListTag

- java.lang.Object
- - com.intellectualcrafters.jnbt.Tag
  - - com.intellectualcrafters.jnbt.ListTag

-     public final class ListTag
      extends Tag

  The `TAG_List` tag.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ListTag(java.lang.Class<? extends Tag> type, java.util.List<? extends Tag> value)` Creates the tag with an empty name.
    `ListTag(java.lang.String name, java.lang.Class<? extends Tag> type, java.util.List<? extends Tag> value)` Creates the tag.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `double` | `asDouble(int index)` Get a double named with the given index, even if it's another type of number.
    `int` | `asInt(int index)` Get an int named with the given index, even if it's another type of number.
    `long` | `asLong(int index)` Get a long named with the given index, even if it's another type of number.
    `byte` | `getByte(int index)` Get a byte named with the given index.
    `byte[]` | `getByteArray(int index)` Get a byte array named with the given index.
    `double` | `getDouble(int index)` Get a double named with the given index.
    `float` | `getFloat(int index)` Get a float named with the given index.
    `Tag` | `getIfExists(int index)` Get the tag if it exists at the given index.
    `int` | `getInt(int index)` Get an int named with the given index.
    `int[]` | `getIntArray(int index)` Get a `int[]` named with the given index.
    `java.util.List<Tag>` | `getList(int index)` Get a list of tags named with the given index.
    `<T extends Tag> java.util.List<T>` | `getList(int index, java.lang.Class<T> listType)` Get a list of tags named with the given index.
    `ListTag` | `getListTag(int index)` Get a `TagList` named with the given index.
    `long` | `getLong(int index)` Get a long named with the given index.
    `short` | `getShort(int index)` Get a short named with the given index.
    `java.lang.String` | `getString(int index)` Get a string named with the given index.
    `java.lang.Class<? extends Tag>` | `getType()` Gets the type of item in this list.
    `java.util.List<Tag>` | `getValue()` Gets the value of this tag.
    `ListTag` | `setValue(java.util.List<Tag> list)` Create a new list tag with this tag's name and type.
    `java.lang.String` | `toString()`

    - ### Methods inherited from class com.intellectualcrafters.jnbt.Tag

      `getName`

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

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

- - ### Constructor Detail

    - #### ListTag

          public ListTag(java.lang.Class<? extends Tag> type,
                 java.util.List<? extends Tag> value)

      Creates the tag with an empty name.
      Parameters:
        `type` - the type of tag
        `value` - the value of the tag

    - #### ListTag

          public ListTag(java.lang.String name,
                 java.lang.Class<? extends Tag> type,
                 java.util.List<? extends Tag> value)

      Creates the tag.
      Parameters:
        `name` - the name of the tag
        `type` - the type of tag
        `value` - the value of the tag

  - ### Method Detail

    - #### getType

          public java.lang.Class<? extends Tag> getType()

      Gets the type of item in this list.
      Returns:
        The type of item in this list.

    - #### getValue

          public java.util.List<Tag> getValue()

      Description copied from class: `Tag`
      Gets the value of this tag.
      Specified by:
        `getValue` in class `Tag`
      Returns:
        the value

    - #### setValue

          public ListTag setValue(java.util.List<Tag> list)

      Create a new list tag with this tag's name and type.
      Parameters:
        `list` - the new list
      Returns:
        a new list tag

    - #### getIfExists

          @Nullable
          public Tag getIfExists(int index)

      Get the tag if it exists at the given index.
      Parameters:
        `index` - the index
      Returns:
        the tag or null

    - #### getByteArray

          public byte[] getByteArray(int index)

      Get a byte array named with the given index.

      If the index does not exist or its value is not a byte array tag, then an empty byte array will be returned.

      Parameters:
        `index` - the index
      Returns:
        a byte array

    - #### getByte

          public byte getByte(int index)

      Get a byte named with the given index.

      If the index does not exist or its value is not a byte tag, then `0` will be returned.

      Parameters:
        `index` - the index
      Returns:
        a byte

    - #### getDouble

          public double getDouble(int index)

      Get a double named with the given index.

      If the index does not exist or its value is not a double tag, then `0` will be returned.

      Parameters:
        `index` - the index
      Returns:
        a double

    - #### asDouble

          public double asDouble(int index)

      Get a double named with the given index, even if it's another type of number.

      If the index does not exist or its value is not a number, then `0` will be returned.

      Parameters:
        `index` - the index
      Returns:
        a double

    - #### getFloat

          public float getFloat(int index)

      Get a float named with the given index.

      If the index does not exist or its value is not a float tag, then `0` will be returned.

      Parameters:
        `index` - the index
      Returns:
        a float

    - #### getIntArray

          public int[] getIntArray(int index)

      Get a `int[]` named with the given index.

      If the index does not exist or its value is not an int array tag, then an empty array will be returned.

      Parameters:
        `index` - the index
      Returns:
        an int array

    - #### getInt

          public int getInt(int index)

      Get an int named with the given index.

      If the index does not exist or its value is not an int tag, then `0` will be returned.

      Parameters:
        `index` - the index
      Returns:
        an int

    - #### asInt

          public int asInt(int index)

      Get an int named with the given index, even if it's another type of number.

      If the index does not exist or its value is not a number, then `0` will be returned.

      Parameters:
        `index` - the index
      Returns:
        an int

    - #### getList

          public java.util.List<Tag> getList(int index)

      Get a list of tags named with the given index.

      If the index does not exist or its value is not a list tag, then an empty list will be returned.

      Parameters:
        `index` - the index
      Returns:
        a list of tags

    - #### getListTag

          public ListTag getListTag(int index)

      Get a `TagList` named with the given index.

      If the index does not exist or its value is not a list tag, then an empty tag list will be returned.

      Parameters:
        `index` - the index
      Returns:
        a tag list instance

    - #### getList

          public <T extends Tag> java.util.List<T> getList(int index,
                                                  java.lang.Class<T> listType)

      Get a list of tags named with the given index.

      If the index does not exist or its value is not a list tag, then an empty list will be returned. If the given index references a list but the list of of a different type, then an empty list will also be returned.

      Type Parameters:
        `T` - the NBT type
      Parameters:
        `index` - the index
        `listType` - the class of the contained type
      Returns:
        a list of tags

    - #### getLong

          public long getLong(int index)

      Get a long named with the given index.

      If the index does not exist or its value is not a long tag, then `0` will be returned.

      Parameters:
        `index` - the index
      Returns:
        a long

    - #### asLong

          public long asLong(int index)

      Get a long named with the given index, even if it's another type of number.

      If the index does not exist or its value is not a number, then `0` will be returned.

      Parameters:
        `index` - the index
      Returns:
        a long

    - #### getShort

          public short getShort(int index)

      Get a short named with the given index.

      If the index does not exist or its value is not a short tag, then `0` will be returned.

      Parameters:
        `index` - the index
      Returns:
        a short

    - #### getString

          public java.lang.String getString(int index)

      Get a string named with the given index.

      If the index does not exist or its value is not a string tag, then `""` will be returned.

      Parameters:
        `index` - the index
      Returns:
        a string

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`