Package wtf.choco.veinminer.block
Class BlockList
java.lang.Object
wtf.choco.veinminer.block.BlockList
- All Implemented Interfaces:
Cloneable
,Iterable<VeinMinerBlock>
A list of
VeinMinerBlocks
.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
add
(@NotNull VeinMinerBlock block) Add aVeinMinerBlock
to this list.boolean
addAll
(@NotNull Iterable<? extends VeinMinerBlock> blocks) Add a collection ofVeinMinerBlocks
to this list.@NotNull List<VeinMinerBlock>
asList()
@NotNull List<VeinMinerBlock>
asList
(@Nullable Comparator<VeinMinerBlock> comparator) @NotNull Set<VeinMinerBlock>
asSet()
void
clear()
Clear this block list.@NotNull BlockList
clone()
boolean
contains
(@NotNull VeinMinerBlock block) Check whether or not this list contains the given block.boolean
containsState
(@NotNull BlockState state) Check whether or not this list contains a block that matches the given state.boolean
containsState
(@NotNull BlockState state, boolean exact) Check whether or not this list contains a block that matches the given state.boolean
containsType
(@NotNull BlockType type) Check whether or not this list contains a block that matches the given type.boolean
Check whether or not this list contains thewildcard
.boolean
@Nullable VeinMinerBlock
getVeinMinerBlock
(@NotNull BlockState state) int
hashCode()
boolean
isEmpty()
Check whether or not thisBlockList
is empty.@NotNull Iterator<VeinMinerBlock>
iterator()
static @NotNull BlockList
parseBlockList
(@NotNull List<String> blockStateStrings, @Nullable Logger logger) Create aBlockList
from a list of input strings.boolean
remove
(@NotNull VeinMinerBlock block) Remove aVeinMinerBlock
from this list.boolean
remove
(@NotNull BlockState state) Remove from this list the block that matches the given state.boolean
Remove from this list all blocks that match the given type regardless of their states.int
size()
Get the size of this list.toString()
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
BlockList
Construct a newBlockList
containing the values of the given lists. Duplicate entries will be ignored.- Parameters:
lists
- the block lists
-
BlockList
Construct a newBlockList
containing the values of the given list.- Parameters:
list
- the list
-
BlockList
public BlockList(int initialSize) Construct a newBlockList
with the given initial size.- Parameters:
initialSize
- the initial size. Must be positive and non-zero
-
BlockList
public BlockList()Construct a new emptyBlockList
.
-
-
Method Details
-
add
Add aVeinMinerBlock
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
Add a collection ofVeinMinerBlocks
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
Remove aVeinMinerBlock
from this list.- Parameters:
block
- the block to remove- Returns:
- true if this list contained the given block
-
remove
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
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
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
Check whether or not this list contains a block that matches the given state.- Parameters:
state
- the state to checkexact
- whether or not to match against all states- Returns:
- true if this list contains the state, false otherwise
-
containsState
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
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 thewildcard
.- Returns:
- true if contains wildcard, false otherwise
-
getVeinMinerBlock
Get theVeinMinerBlock
from thisBlockList
that matches the givenBlockState
. If no VeinMinerBlock in this list matches the BlockState (i.e.VeinMinerBlock.matchesState(BlockState)
isfalse
), 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 thisBlockList
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
- Returns:
- a new set matching the elements of this list
-
asList
@NotNull public @NotNull List<VeinMinerBlock> asList(@Nullable @Nullable Comparator<VeinMinerBlock> comparator) - Parameters:
comparator
- the comparator by which to sort the elements, or null to useVeinMinerBlock
's natural sorting order- Returns:
- a new list matching the elements of this list
-
asList
- 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 aBlockList
from a list of input strings.- Parameters:
blockStateStrings
- the list of strings from which to create a BlockListlogger
- an optional logger instance to which warnings should be logged- Returns:
- the block list
-
iterator
- Specified by:
iterator
in interfaceIterable<VeinMinerBlock>
-
clone
-
hashCode
public int hashCode() -
equals
-
toString
-