registerSettings takes one settings type

The varargs over a generic Class made every caller compile with an
unchecked generic array warning. One type per call matches
registerResourceKind and registerValidator.
This commit is contained in:
piexel committed 2026-11-06 06:30:47 +01:00
1 parent 84bd65fdc4
commit 32a07bd005
4 files changed
+10 -24

No files matched your search

+1 -1
View File
@@ -651,7 +651,7 @@ public final class FloraSettings implements IrisFeature {
use them. Both are deprecated for removal: transitional, until the cut-over.
- Settings named in `when(...)` and object generator settings are described automatically. Settings
that no stage names, such as ones read only through `FeatureSettings.at(...)`, are registered with
`setup.registry().registerSettings(WindSettings.class, GustSettings.class)` in `setup`. Their feature id follows the module
`setup.registry().registerSettings(WindSettings.class)` in `setup`, one call per type. Their feature id follows the module
id like any other, and once registered, other modules may name them in `when(...)`.
A load error names the field, the settings and the module:
@@ -23,14 +23,14 @@ public interface FeatureRegistry {
*/
<T> void registerMantle(MantleKey<T> key, MantleLifetime lifetime, MantleCodec<T> codec);
/** Catalogs settings types that no stage names in {@code when(...)}, such as ones read only
* through {@link com.volmit.config.FeatureSettings#at}, so the host decodes them and studio
* describes them: {@code registerSettings(WindSettings.class, GustSettings.class)}. Settings that a
* stage names are catalogued without this; registering them as well changes nothing. Each type's
* feature id must be this module's id or start with it and {@code /}. Once registered, other
* modules may name the types in {@code when(...)} (see {@link StageGraph}).
/** Catalogs a settings type that no stage names in {@code when(...)}, such as one read only
* through {@link com.volmit.config.FeatureSettings#at}, so the host decodes it and studio
* describes it: {@code registerSettings(WindSettings.class)}. Settings that a stage names are
* catalogued without this; registering them as well changes nothing. The type's feature id must
* be this module's id or start with it and {@code /}. Once registered, other modules may name
* the type in {@code when(...)} (see {@link StageGraph}).
*/
void registerSettings(Class<? extends IrisFeature>... settingsTypes);
void registerSettings(Class<? extends IrisFeature> settingsType);
/** Declares a kind of pack resource this module reads: the JSON files under the kind's folder, served through
* {@link com.volmit.resource.PackResources} by the kind's type and described for studio from its class like
@@ -94,14 +94,9 @@ public final class ModuleRegistry implements FeatureRegistry, ToolingRegistry {
}
@Override
public void registerSettings(Class<? extends IrisFeature>... settingsTypes) {
public void registerSettings(Class<? extends IrisFeature> settingsType) {
checkOpen();
for (var settingsType : settingsTypes) {
registerOneSettings(settingsType);
}
}
private void registerOneSettings(Class<? extends IrisFeature> settingsType) {
Objects.requireNonNull(settingsType, "settingsType");
var descriptor = FeatureDescriptor.of(settingsType);
requireOwnedId("Settings " + settingsType.getName() + " with feature id", descriptor.id());
catalogSettings(descriptor, registering);
@@ -352,15 +352,6 @@ class ModuleRegistryTest {
assertTrue(registry.registeredByOwner(One.class));
}
@Test
void oneCallRegistersSeveralSettingsTypes() {
var registry = new ModuleRegistry();
registerAs(registry, "test:core", settings -> settings.registerSettings(One.class, Two.class));
assertEquals(List.of("test:core/one", "test:core/two"),
registry.freeze().settings().stream().map(value -> value.id().toString()).sorted().toList());
}
@Test
void explicitSettingsFollowTheRegisteringModulesIdAndStillCollide() {
var registry = new ModuleRegistry();