diff --git a/CONTRACTS.md b/CONTRACTS.md index b3da2335a..564967b33 100644 --- a/CONTRACTS.md +++ b/CONTRACTS.md @@ -23,7 +23,7 @@ types that carry them and lists what the Iris adapter still owes. | Work across chunks and mantle writes | `Stage.mantle`, `MantleStage`, `MantleStageContext`, `MantleGenerationContext`; chunk stages read the mantle only | | Annotated settings | `IrisFeature`, `@Feature` (id as JSON key), config annotations, `OptionsMetadata` | | Area a stage writes | `reach(blocks)`, `reach(PackReach)`, `writesMantle(...)` on stage definitions, `PackSettings`, host `StageReach`, `ResolvedStage.reachBlocks`, `PipelineReach` | -| Settings described for studio | `@Desc`, `@Required`, `@MinNumber`, `@MaxNumber`, `@Snippet`, `@Ref`/`Reference`, `FeatureRegistry.registerSettings`, host `LoadedPack.schema()` (`PackSchema`, `FeatureSchema`, `ObjectType`, `SchemaOption`, `ValueKind` with `HostKind`), `ModuleHost.describingHostTypesIn` | +| Settings described for studio | `@Desc`, `@Required`, `@MinNumber`, `@MaxNumber`, `@MinItems`, `@Snippet`, `@Ref`/`Reference`, `FeatureRegistry.registerSettings`, host `LoadedPack.schema()` (`PackSchema`, `FeatureSchema`, `ObjectType`, `SchemaOption`, `ValueKind` with `HostKind`), `ModuleHost.describingHostTypesIn` | | Geometry and mantle registration | `FeatureRegistry`, host `ModuleRegistry`, `FeatureCatalog` | | Block states and palettes | `BlockState`, `BlockRegistry`, `BlockPalette`, `BlockSpec` (`BlockRegistry.resolve(BlockSpec)`, `blockEntity`) | | Noise from pack-described styles | `NoiseStyle`, `StyledRange`, `PackResources.noise()`, `NoiseFactory`, `NoiseSampler` | diff --git a/DESIGN.md b/DESIGN.md index db7b4b422..1575c5b93 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -615,7 +615,7 @@ never equal a feature id. the load; only a built-in class and a pack class can collide that way. - A `SchemaOption` per field that `OptionsMetadata` selects, which means instance fields that are not transient, inherited ones included, in declaration order. Each has its name, `ValueKind`, - `@Desc`, `@Required`, `@MinNumber`/`@MaxNumber` and the default value. + `@Desc`, `@Required`, `@MinNumber`/`@MaxNumber`, `@MinItems` and the default value. ### Value kinds diff --git a/README.md b/README.md index a74ed6952..1397efc1b 100644 --- a/README.md +++ b/README.md @@ -381,8 +381,8 @@ public final class FloraSettings implements IrisFeature { } ``` -- `@Desc` on a class, field or enum constant is its description. `@Required`, `@MinNumber` and - `@MaxNumber` are checks for the host to render. +- `@Desc` on a class, field or enum constant is its description. `@Required`, `@MinNumber`, `@MaxNumber` and + `@MinItems` (the least length of a list, set or array) are checks for the host to render. - Every settings class, nested ones included, needs a no-argument constructor, which may be private. The host creates settings with it, and the field values of that instance are the defaults studio shows. @@ -610,7 +610,7 @@ no JSON. The host renders it and merges it with its own fields: settings `ObjectType`. - `types()`: every class reachable from module settings, once each, by name. An `ObjectType` has the class name, description, snippet name and options. A `SchemaOption` has name, `ValueKind`, - description, required, minimum, maximum and default value. + description, required, minimum, maximum, minimum item count and default value. - `ValueKind` is sealed: `BooleanKind`, `IntegerKind`, `DecimalKind`, `TextKind(format)`, `ReferenceKind(reference, format)`, `EnumKind(type, constants)`, `ListKind(element, unique)`, `MapKind(value)`, `ObjectKind(type)`, which names an entry of `types()`, `HostKind(type)`, @@ -669,7 +669,7 @@ Optional clock = pack.catalog().service(Clock.class); // a Pro - `Hunk` is a dense local volume; `ArrayHunk` is the bounds-checked reference. - The `mantle` package keeps namespaced typed layers, codecs, lifetimes and buffered edits. - `IrisFeature`, `@Feature`, the config annotations (`@Desc`, `@Required`, `@MinNumber`, - `@MaxNumber`, `@Snippet`, `@Ref`) and `OptionsMetadata` describe settings. + `@MaxNumber`, `@MinItems`, `@Snippet`, `@Ref`) and `OptionsMetadata` describe settings. Invocation views and random streams expire when the invocation ends. Stage bodies are shared by concurrent invocations and must not keep views, streams or mutable state; what a module keeps per world lives in the diff --git a/src/main/java/com/volmit/config/MinItems.java b/src/main/java/com/volmit/config/MinItems.java new file mode 100644 index 000000000..8ab3c09bd --- /dev/null +++ b/src/main/java/com/volmit/config/MinItems.java @@ -0,0 +1,12 @@ +package com.volmit.config; + +import java.lang.annotation.*; + +/** Inclusive lower bound on the length of a list, set or array option, such as a palette that needs a block. Studio + * shows it ({@code minItems}); like {@link MinNumber}, enforcement belongs to the configuration loader. + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +public @interface MinItems { + int value(); +} diff --git a/src/main/java/com/volmit/config/OptionsMetadata.java b/src/main/java/com/volmit/config/OptionsMetadata.java index 6b9dec202..7ead1b260 100644 --- a/src/main/java/com/volmit/config/OptionsMetadata.java +++ b/src/main/java/com/volmit/config/OptionsMetadata.java @@ -13,11 +13,11 @@ public record OptionsMetadata(String description, String snippet, List