Package jline.solvers
Class ConfigValidator
java.lang.Object
jline.solvers.ConfigValidator
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:
- not a schema name or alias:
LINE:input:ConfigUnknown, with a did-you-mean; - Java placement
config: set the typedSolverOptions.Configfield 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; - Java placement
option:[Class.]field: set that public field of the options object, which must be an instance of Class, elseLINE:input:ConfigMisplacednaming the solver; - empty Java placement: accepted (and ignored) only when the value is null or the schema default,
else
LINE:unsupported:ConfigKeynaming 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 TypeMethodDescriptionstatic voidapply(SolverOptions options, String name, Object value) Validates config keynameand sets it tovalueonoptions, creatingoptions.configwhen absent.static ConfigSchema.KeyThe schema key spelledname(canonical or alias).static StringThe closest accepted spelling ofname: a case-insensitive match, else the nearest one within Levenshtein distance 2; null when none is that close.static voidvalidate(SolverOptions options) Checks the values already held byoptions.config, so that a field written directly (options.config.nonmkv = "foo") is refused exactly as the("config.nonmkv", "foo")setter refuses it.
-
Method Details
-
apply
Validates config keynameand sets it tovalueonoptions, creatingoptions.configwhen absent.- Throws:
LineException- input (ConfigUnknown, ConfigMisplaced, ConfigInvalid) or unsupported (ConfigKey)
-
validate
Checks the values already held byoptions.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:ConfigInvalidfor a value outside the key's list
-
resolve
The schema key spelledname(canonical or alias).- Throws:
LineInputException-LINE:input:ConfigUnknownwhen no key has that spelling
-
suggest
The closest accepted spelling ofname: a case-insensitive match, else the nearest one within Levenshtein distance 2; null when none is that close.
-