Class ScenarioEntrySchema

java.lang.Object
dev.itsharshxd.zentrix.api.scenario.ScenarioEntrySchema

public final class ScenarioEntrySchema extends Object
The shape of every entry in a ScenarioSettingType.STRUCTURED_LIST setting.

A schema is an ordered list of ScenarioEntryFields. That keeps the setting type domain-independent: one field describes a plain list of values, two describe a list of pairs, and more describe whatever the scenario needs. Zentrix never interprets a field's meaning; it only validates it, renders it, stores it, and hands it back.

Field order is the order an administrator sees in the entry editor, so declare the field that identifies an entry first: the GUI uses primary() as the headline of every entry it lists.

Since:
1.6.0
  • Method Details

    • of

      @NotNull public static @NotNull ScenarioEntrySchema of(@NotNull @NotNull ScenarioEntryField... fields)
      A schema made of the given fields, in the order they are listed.
    • of

      @NotNull public static @NotNull ScenarioEntrySchema of(@NotNull @NotNull List<ScenarioEntryField> fields)
      A schema made of the given fields, in the order they are listed.
    • fields

      @NotNull public @NotNull List<ScenarioEntryField> fields()
      Every field, in declaration order.
    • byKey

      @NotNull public @NotNull Map<String,ScenarioEntryField> byKey()
      Every field keyed by its own key, in declaration order.
    • field

      @NotNull public @NotNull Optional<ScenarioEntryField> field(@NotNull @NotNull String key)
    • has

      public boolean has(@NotNull @NotNull String key)
    • primary

      @NotNull public @NotNull ScenarioEntryField primary()
      The first declared field, which the GUIs use as the headline of an entry.
    • size

      public int size()
    • requiredKeys

      @NotNull public @NotNull List<String> requiredKeys()
      The keys of the fields an entry cannot leave out.
    • emptyEntry

      @NotNull public @NotNull ScenarioEntry emptyEntry()
      An entry holding only the defaults of the optional fields, as a starting point for an editor.
    • isComplete

      public boolean isComplete(@NotNull @NotNull ScenarioEntry entry)
      Whether every required field of an entry carries a value.
    • toString

      public String toString()
      Overrides:
      toString in class Object