Class BlockList

java.lang.Object
wtf.choco.veinminer.data.BlockList
All Implemented Interfaces:
Serializable, Cloneable, Iterable<VeinBlock>

public class BlockList
extends Object
implements Iterable<VeinBlock>, Serializable, Cloneable
Represents a list of blocks and states (see VeinBlock).
Author:
Parker Hawke - 2008Choco
See Also:
Serialized Form
  • Constructor Summary

    Constructors 
    Constructor Description
    BlockList()
    Create a new, empty Blocklist with its default initial capacity (16)
    BlockList​(int initialSize)
    Create a new BlockList with an initial size
    BlockList​(@NotNull BlockList list)
    Create a new BlockList with the values from an existing BlockList instance.
    BlockList​(@NotNull BlockList... lists)
    Create a new BlockList with the values from a set of existing BlockList instances.
  • Method Summary

    Modifier and Type Method Description
    @NotNull VeinBlock add​(@NotNull org.bukkit.block.data.BlockData data)
    Add a BlockData to this BlockList.
    @NotNull VeinBlock add​(@NotNull org.bukkit.Material material)
    Add a Material with no states to this BlockList.
    boolean add​(@NotNull VeinBlock block)
    Add a VeinBlock to this block list.
    boolean addAll​(@NotNull Iterable<? extends VeinBlock> values)
    Add a collection of VeinBlocks to this block list.
    void clear()
    Clear the contents of this list.
    @NotNull BlockList clone()  
    boolean contains​(@NotNull org.bukkit.block.data.BlockData data)
    Check whether or not this list encapsulates the specified BlockData.
    boolean contains​(@NotNull org.bukkit.Material material)
    Check whether or not this list encapsulates the specified Material.
    boolean contains​(@NotNull VeinBlock block)
    Check whether or not this list contains a specific VeinBlock instance.
    boolean containsExact​(@NotNull org.bukkit.block.data.BlockData data)
    Check whether or not this list contains exactly the specified BlockData.
    boolean equals​(Object obj)  
    @Nullable VeinBlock getVeinBlock​(@NotNull org.bukkit.block.data.BlockData data)
    Get the VeinBlock from this BlockList that encapsulates the given BlockData.
    int hashCode()  
    @NotNull Iterator<VeinBlock> iterator()  
    void remove​(@NotNull org.bukkit.block.data.BlockData data)
    Remove a specific BlockData from this block list.
    void remove​(@NotNull VeinBlock block)
    Remove a specific VeinBlock from this block list.
    void removeAll​(@NotNull org.bukkit.Material material)
    Remove all blocks and states from this list such that their type match the one specified.
    int size()
    Get the size of this list.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Constructor Details

    • BlockList

      public BlockList​(@NotNull @NotNull BlockList... lists)
      Create a new BlockList with the values from a set of existing BlockList instances. Duplicate instances of blocks and states will not be included.
      Parameters:
      lists - the block lists whose values should be included
    • BlockList

      public BlockList​(@NotNull @NotNull BlockList list)
      Create a new BlockList with the values from an existing BlockList instance.
      Parameters:
      list - the block list whose values should be included
    • BlockList

      public BlockList​(int initialSize)
      Create a new BlockList with an initial size
      Parameters:
      initialSize - the initial list size
    • BlockList

      public BlockList()
      Create a new, empty Blocklist with its default initial capacity (16)
  • Method Details

    • add

      @NotNull public @NotNull VeinBlock add​(@NotNull @NotNull org.bukkit.block.data.BlockData data)
      Add a BlockData to this BlockList.
      Parameters:
      data - the data to add
      Returns:
      the VeinBlock added to this list
    • add

      @NotNull public @NotNull VeinBlock add​(@NotNull @NotNull org.bukkit.Material material)
      Add a Material with no states to this BlockList.
      Parameters:
      material - the material to add
      Returns:
      the VeinBlock added to this list
    • add

      public boolean add​(@NotNull @NotNull VeinBlock block)
      Add a VeinBlock to this block list. If the block is already present in this list, this method will fail silently.
      Parameters:
      block - the block to add
      Returns:
      true if added, false if already present
    • addAll

      public boolean addAll​(@NotNull @NotNull Iterable<? extends VeinBlock> values)
      Add a collection of VeinBlocks to this block list. If a block is already present in this list, it will be ignored silently.
      Parameters:
      values - the values to add
      Returns:
      true if at least one block was added, false otherwise
    • remove

      public void remove​(@NotNull @NotNull VeinBlock block)
      Remove a specific VeinBlock from this block list.
      Parameters:
      block - the block to remove
    • remove

      public void remove​(@NotNull @NotNull org.bukkit.block.data.BlockData data)
      Remove a specific BlockData from this block list. The data must be equals(Object) to the one that should be removed.
      Parameters:
      data - the data to remove
    • removeAll

      public void removeAll​(@NotNull @NotNull org.bukkit.Material material)
      Remove all blocks and states from this list such that their type match the one specified.
      Parameters:
      material - the material to remove
    • contains

      public boolean contains​(@NotNull @NotNull VeinBlock block)
      Check whether or not this list contains a specific VeinBlock instance.
      Parameters:
      block - the block to check
      Returns:
      true if present, false otherwise
    • contains

      public boolean contains​(@NotNull @NotNull org.bukkit.block.data.BlockData data)
      Check whether or not this list encapsulates the specified BlockData. This method will return true if even a parent VeinBlock (i.e. one with just a similar material or more generic states) is present, therefore if an exact check is required, see containsExact(BlockData).
      Parameters:
      data - the data to check
      Returns:
      true if present, false otherwise
      See Also:
      containsExact(BlockData)
    • contains

      public boolean contains​(@NotNull @NotNull org.bukkit.Material material)
      Check whether or not this list encapsulates the specified Material.
      Parameters:
      material - the material to check
      Returns:
      true if present, false otherwise
    • containsExact

      public boolean containsExact​(@NotNull @NotNull org.bukkit.block.data.BlockData data)
      Check whether or not this list contains exactly the specified BlockData.
      Parameters:
      data - the data to check
      Returns:
      true if present, false otherwise
    • getVeinBlock

      @Nullable public @Nullable VeinBlock getVeinBlock​(@NotNull @NotNull org.bukkit.block.data.BlockData data)
      Get the VeinBlock from this BlockList that encapsulates the given BlockData. If no VeinBlock in this list encapsulates the BlockData, (i.e. contains(BlockData) is false) null is returned.
      Parameters:
      data - the data for which to get a VeinBlock
      Returns:
      the encapsulating VeinBlock for this list. null if none
    • size

      public int size()
      Get the size of this list.
      Returns:
      the list size
    • clear

      public void clear()
      Clear the contents of this list.
    • iterator

      @NotNull public @NotNull Iterator<VeinBlock> iterator()
      Specified by:
      iterator in interface Iterable<VeinBlock>
    • clone

      @NotNull public @NotNull BlockList clone()
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals​(Object obj)
      Overrides:
      equals in class Object