feat: added getRegistry method to provider
All checks were successful
ci/woodpecker/push/central-override Pipeline was successful

This commit is contained in:
Timo Ley 2024-11-09 20:58:01 +01:00
parent d1442fe35a
commit 9029822118
4 changed files with 23 additions and 0 deletions

View file

@ -1,5 +1,7 @@
package dev.tilera.cwg.api.options;
import dev.tilera.cwg.api.CwgGlobals;
public interface IGeneratorOptionProvider {
Integer getInt(String id);
@ -12,4 +14,8 @@ public interface IGeneratorOptionProvider {
<T> T getValue(String id, Class<T> type);
default IGeneratorOptionRegistry getRegistry() {
return CwgGlobals.getOptionRegistry();
}
}

View file

@ -18,4 +18,9 @@ public interface IGeneratorOptionRegistry extends IGeneratorOptionProvider {
Class<?> getOptionType(String id);
@Override
default IGeneratorOptionRegistry getRegistry() {
return this;
}
}

View file

@ -3,6 +3,7 @@ package dev.tilera.cwg.options;
import dev.tilera.cwg.Config;
import dev.tilera.cwg.api.CwgGlobals;
import dev.tilera.cwg.api.options.IGeneratorOptionProvider;
import dev.tilera.cwg.api.options.IGeneratorOptionRegistry;
public class ConfigProvider implements IGeneratorOptionProvider {
@ -49,5 +50,10 @@ public class ConfigProvider implements IGeneratorOptionProvider {
}
return parent.getValue(id, type);
}
@Override
public IGeneratorOptionRegistry getRegistry() {
return parent.getRegistry();
}
}

View file

@ -4,6 +4,7 @@ import java.util.HashMap;
import java.util.Map;
import dev.tilera.cwg.api.options.IGeneratorOptionProvider;
import dev.tilera.cwg.api.options.IGeneratorOptionRegistry;
public class OptionProvider implements IGeneratorOptionProvider {
@ -79,5 +80,10 @@ public class OptionProvider implements IGeneratorOptionProvider {
public void putValue(String id, Object value) {
storage.put(id, value);
}
@Override
public IGeneratorOptionRegistry getRegistry() {
return registry.getRegistry();
}
}