Class SpecToGen

java.lang.Object
jsonvalues.spec.SpecToGen

public final class SpecToGen extends Object
Class responsible for converting JSON specs to JSON generators. When a generator cannot be created for a given spec, a RuntimeException is thrown. In this case, the user can provide a custom generator for the path using the override parameter.
  • Field Details

    • DEFAULT

      public static final SpecToGen DEFAULT
      The default instance of the SpecToGen class. To customize how data is generated, use the of(SpecGenConfBuilder) method to create a new instance with the desired configuration.
  • Method Details

    • of

      public static SpecToGen of(SpecGenConfBuilder confBuilder)
      Creates a new instance of the SpecToGen class with the specified configuration.
      Parameters:
      confBuilder - The configuration to customize how data is generated.
      Returns:
      A new instance of the SpecToGen class with the specified configuration.
    • convert

      public JsObjGen convert(JsObjSpec objSpec)
      Converts a JsObjSpec to a JSON object generator. It throws a RuntimeException if the generator cannot be created. In this case, use the alternative method convert(JsObjSpec, Map) that accepts an override parameter to provide a custom generator
      Parameters:
      objSpec - The JsObjSpec to be converted.
      Returns:
      The resulting JsObjGen
    • convert

      public JsObjGen convert(JsObjSpec objSpec, Map<JsPath,fun.gen.Gen<? extends JsValue>> overrides)
      Converts a JsObjSpec to a JSON object generator with the specified overrides. It throws a RuntimeException if the generator cannot be created. In this case, override the generator for the path using the overrides parameter.
      Parameters:
      objSpec - The JsObjSpec to be converted.
      overrides - The overrides to apply to the generator.
      Returns:
      The resulting JsObjGen
    • convert

      public fun.gen.Gen<JsValue> convert(JsSpec spec)
      Converts a spec to a JSON object generator. It throws a RuntimeException if the generator cannot be created. In this case, override the generator for the path using the method convert(JsSpec, Map).
      Parameters:
      spec - The spec to be converted.
      Returns:
      The resulting JSON value generator
    • convert

      public fun.gen.Gen<JsValue> convert(JsSpec spec, Map<JsPath,fun.gen.Gen<? extends JsValue>> overrides)
      Converts a JsSpec to a JSON generator. It throws a RuntimeException if the generator cannot be created. In this case, use the alternative method convert(JsSpec, Map) that accepts an override parameter to provide a custom generator.
      Parameters:
      spec - The JsSpec to be converted.
      overrides - The overrides to apply to the generator.
      Returns:
      The resulting JSON value generator