Builder class / API

To support the programmatic creation of JSON schemata by developers, the JsonSchemaBuilder class provides suitable methods.

For example:

BJsonSchema schema =
        new JsonSchemaBuilder()
          .withUpdateStrategy(BJsonSchemaUpdateStrategy.onDemandOnly)
          .withQuery("Bacnet Query", "station:|slot:/Drivers/BacnetNetwork|bql:select
           out.value AS 'v', status from control:ControlPoint")
          .withRootObject()
          .withFixedNumericProperty("Version", BDouble.make(1.23))
          .withFixedObject("Config")
          .stepDown()
            .withBoundProperty("BacnetAddress", BOrd.make(String.format
             ("station:|slot:/Drivers/BacnetNetwork/%s/address", deviceName)))
            .withBoundObject("DeviceSettings", BOrd.make(String.format
             ("station:|slot:/Drivers/BacnetNetwork/%s/config/deviceObject", deviceName)))
          .stepUp()
          .withBoundQueryResult("Data", "Bacnet Query", BObjectsArray.TYPE.getTypeSpec())
      .build()

The above schema would result in this output:

{
      "Version":1.23,
      "Config":{
        "BacnetAddress":"192.168.1.24",
        "DeviceSettings":{
          "pollFrequency":"Normal",
          "status":"{ok}",
          "faultCause":"",
          "objectId":"device:100171",
          …….
    }
    },
    "Data":[
       {
         "v":0.45,
         "status":"{down,stale}"
       },
       ……*
       ]
    }
 
NOTE: This example has been trimmed for demonstration purposes.