Class BlockList

java.lang.Object
wtf.choco.veinminer.block.BlockList
All Implemented Interfaces:
Cloneable, Iterable<VeinMinerBlock>

public class BlockList extends Object implements Iterable<VeinMinerBlock>, Cloneable
A list of VeinMinerBlocks.
  • Constructor Details

    • BlockList

      public BlockList(@NotNull @NotNull BlockList... lists)
      Construct a new BlockList containing the values of the given lists. Duplicate entries will be ignored.
      Parameters:
      lists - the block lists
    • BlockList

      public BlockList(@NotNull @NotNull BlockList list)
      Construct a new BlockList containing the values of the given list.
      Parameters:
      list - the list
    • BlockList

      public BlockList(int initialSize)
      Construct a new BlockList with the given initial size.
      Parameters:
      initialSize - the initial size. Must be positive and non-zero
    • BlockList

      public BlockList()
      Construct a new empty BlockList.
  • Method Details

    • add

      public boolean add(@NotNull @NotNull VeinMinerBlock block)
      Add a VeinMinerBlock to this list.
      Parameters:
      block - the block to add
      Returns:
      true if this list was changed as a result of this operation, false if remained unchanged
    • addAll

      public boolean addAll(@NotNull @NotNull Iterable<? extends VeinMinerBlock> blocks)
      Add a collection of VeinMinerBlocks to this list.
      Parameters:
      blocks - the blocks to add
      Returns:
      true if this list was changed as a result of this operation, false if remained unchanged
    • remove

      public boolean remove(@NotNull @NotNull VeinMinerBlock block)
      Remove a VeinMinerBlock from this list.
      Parameters:
      block - the block to remove
      Returns:
      true if this list contained the given block
    • remove

      public boolean remove(@NotNull @NotNull BlockState state)
      Remove from this list the block that matches the given state.
      Parameters:
      state - the state to remove
      Returns:
      true if this list contained a block with the given state
    • removeAll

      public boolean removeAll(@NotNull @NotNull BlockType type)
      Remove from this list all blocks that match the given type regardless of their states.
      Parameters:
      type - the type of block to remove
      Returns:
      true if this list contained at least one block with the given type
    • contains

      public boolean contains(@NotNull @NotNull VeinMinerBlock block)
      Check whether or not this list contains the given block.
      Parameters:
      block - the block to check
      Returns:
      true if this list contains the value, false otherwise
    • containsState

      public boolean containsState(@NotNull @NotNull BlockState state, boolean exact)
      Check whether or not this list contains a block that matches the given state.
      Parameters:
      state - the state to check
      exact - whether or not to match against all states
      Returns:
      true if this list contains the state, false otherwise
    • containsState

      public boolean containsState(@NotNull @NotNull BlockState state)
      Check whether or not this list contains a block that matches the given state.
      Parameters:
      state - the state to check
      Returns:
      true if this list contains the state, false otherwise
    • containsType

      public boolean containsType(@NotNull @NotNull BlockType type)
      Check whether or not this list contains a block that matches the given type.
      Parameters:
      type - the type to check
      Returns:
      true if this list contains the type, false otherwise
    • containsWildcard

      public boolean containsWildcard()
      Check whether or not this list contains the wildcard.
      Returns:
      true if contains wildcard, false otherwise
    • getVeinMinerBlock

      @Nullable public @Nullable VeinMinerBlock getVeinMinerBlock(@NotNull @NotNull BlockState state)
      Get the VeinMinerBlock from this BlockList that matches the given BlockState. If no VeinMinerBlock in this list matches the BlockState (i.e. VeinMinerBlock.matchesState(BlockState) is false), null is returned.
      Parameters:
      state - the state for which to get a VeinMinerBlock
      Returns:
      the matching VeinBlock for this list, or null if none
    • size

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

      public boolean isEmpty()
      Check whether or not this BlockList is empty.
      Returns:
      true if empty (size is 0), false if it contains at least one entry
    • clear

      public void clear()
      Clear this block list.
    • asSet

      @NotNull public @NotNull Set<VeinMinerBlock> asSet()
      Get this BlockList as a Set.
      Returns:
      a new set matching the elements of this list
    • asList

      @NotNull public @NotNull List<VeinMinerBlock> asList(@Nullable @Nullable Comparator<VeinMinerBlock> comparator)
      Get this BlockList as a sorted List.
      Parameters:
      comparator - the comparator by which to sort the elements, or null to use VeinMinerBlock's natural sorting order
      Returns:
      a new list matching the elements of this list
    • asList

      @NotNull public @NotNull List<VeinMinerBlock> asList()
      Get this BlockList as a List.
      Returns:
      a new list matching the elements of this list
    • parseBlockList

      @NotNull public static @NotNull BlockList parseBlockList(@NotNull @NotNull List<String> blockStateStrings, @Nullable @Nullable Logger logger)
      Create a BlockList from a list of input strings.
      Parameters:
      blockStateStrings - the list of strings from which to create a BlockList
      logger - an optional logger instance to which warnings should be logged
      Returns:
      the block list
    • iterator

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

      @NotNull public @NotNull BlockList clone()
      Overrides:
      clone in class Object
    • hashCode

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

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object