mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 10:30:42 +00:00
tryGet -> getFromID
This commit is contained in:
@@ -46,7 +46,7 @@ public class GenericTemplateSupplierLoader<T> implements TypeLoader<T> {
|
||||
Map<String, Object> map = (Map<String, Object>) c;
|
||||
try {
|
||||
return loader
|
||||
.load(registry.tryGet(((String) map.get("type")))
|
||||
.load(registry.getFromID(((String) map.get("type")))
|
||||
.orElseThrow(() -> new LoadException("No such entry: " + map.get("type")))
|
||||
.get(), new MapConfiguration(map)).get();
|
||||
} catch(ConfigException e) {
|
||||
|
||||
@@ -97,8 +97,8 @@ public class CheckedRegistryImpl<T> implements CheckedRegistry<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<RegistryKey, T> get(String id) {
|
||||
return registry.get(id);
|
||||
public Map<RegistryKey, T> getIDMatches(String id) {
|
||||
return registry.getIDMatches(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -84,8 +84,8 @@ public class LockedRegistryImpl<T> implements Registry<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<RegistryKey, T> get(String id) {
|
||||
return registry.get(id);
|
||||
public Map<RegistryKey, T> getIDMatches(String id) {
|
||||
return registry.getIDMatches(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -32,7 +32,6 @@ import java.lang.reflect.AnnotatedType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
@@ -67,9 +66,9 @@ public class OpenRegistryImpl<T> implements OpenRegistry<T> {
|
||||
|
||||
@Override
|
||||
public T load(@NotNull AnnotatedType type, @NotNull Object o, @NotNull ConfigLoader configLoader) throws LoadException {
|
||||
return tryGet((String) o).orElseThrow(() -> new LoadException("No such " + type.getType().getTypeName() + " matching \"" + o +
|
||||
"\" was found in this registry. Registry contains items: " +
|
||||
getItemsFormatted()));
|
||||
return getFromID((String) o).orElseThrow(() -> new LoadException("No such " + type.getType().getTypeName() + " matching \"" + o +
|
||||
"\" was found in this registry. Registry contains items: " +
|
||||
getItemsFormatted()));
|
||||
}
|
||||
|
||||
private String getItemsFormatted() {
|
||||
@@ -145,7 +144,7 @@ public class OpenRegistryImpl<T> implements OpenRegistry<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<RegistryKey, T> get(String id) {
|
||||
public Map<RegistryKey, T> getIDMatches(String id) {
|
||||
return objectIDs
|
||||
.get(id)
|
||||
.stream()
|
||||
|
||||
@@ -37,7 +37,7 @@ public class RegistryTest {
|
||||
|
||||
test.register("test", "bazinga");
|
||||
|
||||
assertEquals(test.get("test").orElseThrow(), "bazinga");
|
||||
assertEquals(test.getIDMatches("test").orElseThrow(), "bazinga");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -60,7 +60,7 @@ public class RegistryTest {
|
||||
|
||||
test.register("test", "bazinga");
|
||||
|
||||
assertEquals(test.get("test").orElseThrow(), "bazinga");
|
||||
assertEquals(test.getIDMatches("test").orElseThrow(), "bazinga");
|
||||
|
||||
try {
|
||||
test.register("test", "bazinga2");
|
||||
|
||||
Reference in New Issue
Block a user