mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-04 00:45:57 +00:00
implement single-parameter Keyed registration methods
This commit is contained in:
parent
3792a1ab05
commit
1c93c2bbb4
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.api.registry;
|
package com.dfsek.terra.api.registry;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.registry.key.Keyed;
|
||||||
import com.dfsek.terra.api.registry.key.RegistryKey;
|
import com.dfsek.terra.api.registry.key.RegistryKey;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -24,4 +25,9 @@ public interface CheckedRegistry<T> extends Registry<T> {
|
|||||||
* @throws DuplicateEntryException If an entry with the same identifier is already present.
|
* @throws DuplicateEntryException If an entry with the same identifier is already present.
|
||||||
*/
|
*/
|
||||||
void register(@NotNull RegistryKey identifier, @NotNull T value) throws DuplicateEntryException;
|
void register(@NotNull RegistryKey identifier, @NotNull T value) throws DuplicateEntryException;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
default void register(@NotNull Keyed<? extends T> value) throws DuplicateEntryException {
|
||||||
|
register(value.getRegistryKey(), (T) value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.api.registry;
|
package com.dfsek.terra.api.registry;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.registry.key.Keyed;
|
||||||
import com.dfsek.terra.api.registry.key.RegistryKey;
|
import com.dfsek.terra.api.registry.key.RegistryKey;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -23,6 +24,11 @@ public interface OpenRegistry<T> extends Registry<T> {
|
|||||||
*/
|
*/
|
||||||
boolean register(@NotNull RegistryKey identifier, @NotNull T value);
|
boolean register(@NotNull RegistryKey identifier, @NotNull T value);
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
default boolean register(@NotNull Keyed<? extends T> value) {
|
||||||
|
return register(value.getRegistryKey(), (T) value);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a value to this registry, checking whether it is present first.
|
* Add a value to this registry, checking whether it is present first.
|
||||||
*
|
*
|
||||||
@ -33,6 +39,11 @@ public interface OpenRegistry<T> extends Registry<T> {
|
|||||||
*/
|
*/
|
||||||
void registerChecked(@NotNull RegistryKey identifier, @NotNull T value) throws DuplicateEntryException;
|
void registerChecked(@NotNull RegistryKey identifier, @NotNull T value) throws DuplicateEntryException;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
default void registerChecked(@NotNull Keyed<? extends T> value) {
|
||||||
|
registerChecked(value.getRegistryKey(), (T) value);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears all entries from the registry.
|
* Clears all entries from the registry.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user