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; package dev.tilera.cwg.api.options;
import dev.tilera.cwg.api.CwgGlobals;
public interface IGeneratorOptionProvider { public interface IGeneratorOptionProvider {
Integer getInt(String id); Integer getInt(String id);
@ -12,4 +14,8 @@ public interface IGeneratorOptionProvider {
<T> T getValue(String id, Class<T> type); <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); 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.Config;
import dev.tilera.cwg.api.CwgGlobals; import dev.tilera.cwg.api.CwgGlobals;
import dev.tilera.cwg.api.options.IGeneratorOptionProvider; import dev.tilera.cwg.api.options.IGeneratorOptionProvider;
import dev.tilera.cwg.api.options.IGeneratorOptionRegistry;
public class ConfigProvider implements IGeneratorOptionProvider { public class ConfigProvider implements IGeneratorOptionProvider {
@ -50,4 +51,9 @@ public class ConfigProvider implements IGeneratorOptionProvider {
return parent.getValue(id, type); 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 java.util.Map;
import dev.tilera.cwg.api.options.IGeneratorOptionProvider; import dev.tilera.cwg.api.options.IGeneratorOptionProvider;
import dev.tilera.cwg.api.options.IGeneratorOptionRegistry;
public class OptionProvider implements IGeneratorOptionProvider { public class OptionProvider implements IGeneratorOptionProvider {
@ -80,4 +81,9 @@ public class OptionProvider implements IGeneratorOptionProvider {
storage.put(id, value); storage.put(id, value);
} }
@Override
public IGeneratorOptionRegistry getRegistry() {
return registry.getRegistry();
}
} }