mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-12-02 19:22:08 +00:00
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:
1 parent
84bd65fdc4
commit
32a07bd005
4 files changed
+10
-24
No files matched your search
@@ -651,7 +651,7 @@ public final class FloraSettings implements IrisFeature {
|
|||||||
use them. Both are deprecated for removal: transitional, until the cut-over.
|
use them. Both are deprecated for removal: transitional, until the cut-over.
|
||||||
- Settings named in `when(...)` and object generator settings are described automatically. Settings
|
- 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
|
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(...)`.
|
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:
|
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);
|
<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
|
/** 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 them and studio
|
* through {@link com.volmit.config.FeatureSettings#at}, so the host decodes it and studio
|
||||||
* describes them: {@code registerSettings(WindSettings.class, GustSettings.class)}. Settings that a
|
* describes it: {@code registerSettings(WindSettings.class)}. Settings that a stage names are
|
||||||
* stage names are catalogued without this; registering them as well changes nothing. Each type's
|
* catalogued without this; registering them as well changes nothing. The type's feature id must
|
||||||
* feature id must be this module's id or start with it and {@code /}. Once registered, other
|
* be this module's id or start with it and {@code /}. Once registered, other modules may name
|
||||||
* modules may name the types in {@code when(...)} (see {@link StageGraph}).
|
* 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
|
/** 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
|
* {@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
|
@Override
|
||||||
public void registerSettings(Class<? extends IrisFeature>... settingsTypes) {
|
public void registerSettings(Class<? extends IrisFeature> settingsType) {
|
||||||
checkOpen();
|
checkOpen();
|
||||||
for (var settingsType : settingsTypes) {
|
Objects.requireNonNull(settingsType, "settingsType");
|
||||||
registerOneSettings(settingsType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerOneSettings(Class<? extends IrisFeature> settingsType) {
|
|
||||||
var descriptor = FeatureDescriptor.of(settingsType);
|
var descriptor = FeatureDescriptor.of(settingsType);
|
||||||
requireOwnedId("Settings " + settingsType.getName() + " with feature id", descriptor.id());
|
requireOwnedId("Settings " + settingsType.getName() + " with feature id", descriptor.id());
|
||||||
catalogSettings(descriptor, registering);
|
catalogSettings(descriptor, registering);
|
||||||
|
|||||||
@@ -352,15 +352,6 @@ class ModuleRegistryTest {
|
|||||||
assertTrue(registry.registeredByOwner(One.class));
|
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
|
@Test
|
||||||
void explicitSettingsFollowTheRegisteringModulesIdAndStillCollide() {
|
void explicitSettingsFollowTheRegisteringModulesIdAndStillCollide() {
|
||||||
var registry = new ModuleRegistry();
|
var registry = new ModuleRegistry();
|
||||||
|
|||||||
Reference in new issue
Block a user