Package wtf.choco.veinminer.pattern
Class PatternRegistry
java.lang.Object
wtf.choco.veinminer.pattern.PatternRegistry
A registry to which
VeinMiningPatterns
may be registered.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription@Nullable VeinMiningPattern
Get the pattern with the given String-representation of aNamespacedKey
.@Nullable VeinMiningPattern
get
(@NotNull NamespacedKey key) Get the pattern with the givenNamespacedKey
.@NotNull VeinMiningPattern
getOrDefault
(@NotNull String key, @NotNull VeinMiningPattern defaultPattern) Get the pattern with the given String-representation of aNamespacedKey
, or return a default pattern if a pattern with the given key does not exist.@NotNull VeinMiningPattern
getOrDefault
(@NotNull NamespacedKey key, @NotNull VeinMiningPattern defaultPattern) Get the pattern with the givenNamespacedKey
, or return a default pattern if a pattern with the given key does not exist.@NotNull Collection<VeinMiningPattern>
Get an unmodifiableCollection
of allVeinMiningPatterns
in this registry.void
register
(@NotNull VeinMiningPattern pattern) Register a newVeinMiningPattern
.boolean
unregister
(@NotNull VeinMiningPattern pattern) Unregister the givenVeinMiningPattern
.@Nullable VeinMiningPattern
unregister
(@NotNull NamespacedKey key) Unregister the pattern with the givenNamespacedKey
.void
Unregister all patterns in this registry.
-
Constructor Details
-
PatternRegistry
public PatternRegistry()
-
-
Method Details
-
register
Register a newVeinMiningPattern
.- Parameters:
pattern
- the pattern to register
-
get
Get the pattern with the givenNamespacedKey
.- Parameters:
key
- the pattern key- Returns:
- the pattern
-
getOrDefault
@NotNull public @NotNull VeinMiningPattern getOrDefault(@NotNull @NotNull NamespacedKey key, @NotNull @NotNull VeinMiningPattern defaultPattern) Get the pattern with the givenNamespacedKey
, or return a default pattern if a pattern with the given key does not exist.- Parameters:
key
- the pattern keydefaultPattern
- the default pattern to return if unavailable- Returns:
- the pattern, or the default pattern if unavailable
-
get
Get the pattern with the given String-representation of aNamespacedKey
.- Parameters:
key
- the pattern key- Returns:
- the pattern
-
getOrDefault
@NotNull public @NotNull VeinMiningPattern getOrDefault(@NotNull @NotNull String key, @NotNull @NotNull VeinMiningPattern defaultPattern) Get the pattern with the given String-representation of aNamespacedKey
, or return a default pattern if a pattern with the given key does not exist.- Parameters:
key
- the pattern keydefaultPattern
- the default pattern to return if unavailable- Returns:
- the pattern, or the default pattern if unavailable
-
unregister
Unregister the givenVeinMiningPattern
.- Parameters:
pattern
- the pattern to unregister- Returns:
- true if unregistered, false if the pattern was not previously registered
-
unregister
Unregister the pattern with the givenNamespacedKey
.- Parameters:
key
- the key of the pattern to unregister- Returns:
- the unregistered
VeinMiningPattern
, or null if none unregistered
-
getPatterns
Get an unmodifiableCollection
of allVeinMiningPatterns
in this registry.- Returns:
- all registered patterns
-
unregisterAll
public void unregisterAll()Unregister all patterns in this registry.
-