make registry return optional for get operations

This commit is contained in:
dfsek
2021-12-01 17:48:41 -07:00
parent 4cc07a7b02
commit a69be58b58
17 changed files with 73 additions and 86 deletions

View File

@@ -15,6 +15,7 @@ import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.Optional;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
@@ -28,9 +29,8 @@ public interface Registry<T> extends TypeLoader<T> {
*
* @return Value matching the identifier, {@code null} if no value is present.
*/
@NotNull
@Contract(pure = true)
T get(@NotNull String identifier) throws NoSuchEntryException;
Optional<T> get(@NotNull String identifier);
/**
* Check if the registry contains a value.

View File

@@ -5,7 +5,4 @@ public class NoSuchEntryException extends RuntimeException {
super(message);
}
public NoSuchEntryException(String message, Throwable cause) {
super(message, cause);
}
}