Package jline.solvers

Class ConfigValidator

java.lang.Object
jline.solvers.ConfigValidator

public final class ConfigValidator extends Object
Validates and sets options.config keys against the cross-codebase schema (doc/line-config.schema.json, generated into ConfigSchema).

The contract is the same in MATLAB, the JAR, Python and C++. For a key name:

  1. not a schema name or alias: LINE:input:ConfigUnknown, with a did-you-mean;
  2. Java placement config: set the typed SolverOptions.Config field of that name, or the additional-parameter map entry when no such field exists; config:a+b: set the Config fields a, b from a {a, b} pair;
  3. Java placement option:[Class.]field: set that public field of the options object, which must be an instance of Class, else LINE:input:ConfigMisplaced naming the solver;
  4. empty Java placement: accepted (and ignored) only when the value is null or the schema default, else LINE:unsupported:ConfigKey naming the codebases that implement it.

A placement may list several comma-separated spellings; the first that applies wins. The public Config field names that no schema key spells (e.g. rate_traj_tgrid, carried by rate_traj) are accepted as Java spellings and set directly.

Typed fields are set reflectively, converting from String, Number, Boolean, arrays, Lists and Matrix, so every typed Config field can be set from a ("config.x", value) pair.

  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    apply(SolverOptions options, String name, Object value)
    Validates config key name and sets it to value on options, creating options.config when absent.
    The schema key spelled name (canonical or alias).
    static String
    The closest accepted spelling of name: a case-insensitive match, else the nearest one within Levenshtein distance 2; null when none is that close.
    static void
    Checks the values already held by options.config, so that a field written directly (options.config.nonmkv = "foo") is refused exactly as the ("config.nonmkv", "foo") setter refuses it.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • apply

      public static void apply(SolverOptions options, String name, Object value)
      Validates config key name and sets it to value on options, creating options.config when absent.
      Throws:
      LineException - input (ConfigUnknown, ConfigMisplaced, ConfigInvalid) or unsupported (ConfigKey)
    • validate

      public static void validate(SolverOptions options)
      Checks the values already held by options.config, so that a field written directly (options.config.nonmkv = "foo") is refused exactly as the ("config.nonmkv", "foo") setter refuses it. MATLAB validates a whole options struct on solver construction (lineConfigValidate); this is that check for the typed Java fields. Every schema key the JAR places in a typed String field that lists its admissible values is checked against the list.
      Parameters:
      options - the options a solver is about to adopt; null or a null config is accepted
      Throws:
      LineInputException - LINE:input:ConfigInvalid for a value outside the key's list
    • resolve

      public static ConfigSchema.Key resolve(String name)
      The schema key spelled name (canonical or alias).
      Throws:
      LineInputException - LINE:input:ConfigUnknown when no key has that spelling
    • suggest

      public static String suggest(String name)
      The closest accepted spelling of name: a case-insensitive match, else the nearest one within Levenshtein distance 2; null when none is that close.