Package jline.api.sn

Class SnContractValidate

java.lang.Object
jline.api.sn.SnContractValidate

public final class SnContractValidate extends Object
Checks a NetworkStruct against its contract, SnContract: the JAR twin of MATLAB's sn_validate.

Four kinds of violation are reported, one string each: a required field is missing, a field is not in the contract at all (a misspelled or undeclared field), a value has a type the contract does not admit, and a non-empty value has a shape none of the field's shapes admits. A null value is an empty one and is not checked further.

The check runs on a name-to-value snapshot of the struct (snapshot(jline.lang.NetworkStruct)), so a test can drop or inject a field exactly as the MATLAB test does with rmfield. Network.getStruct runs it once per rebuild at VerboseLevel.DEBUG or with LINE_VALIDATE_SN=1, and warns.

  • Method Details

    • requested

      public static boolean requested()
      True when the session asks getStruct to validate: debug verbosity or LINE_VALIDATE_SN=1.
    • snapshot

      public static Map<String,Object> snapshot(NetworkStruct sn)
      Every instance field of the struct, by its JAR name, in declaration order.
    • validate

      public static List<String> validate(NetworkStruct sn)
      The violations of a struct, empty when it conforms.
    • validate

      public static List<String> validate(NetworkStruct sn, boolean error)
      As validate(NetworkStruct); with error true, raises LINE:internal:Contract instead.
    • validate

      public static List<String> validate(Map<String,Object> fields, boolean error)
      The violations of a snapshot; with error true, raises LINE:internal:Contract on any.