Package jsonvalues.spec
Class SpecToGen
java.lang.Object
jsonvalues.spec.SpecToGen
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 Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionConverts a JsObjSpec to a JSON object generator.Converts a JsObjSpec to a JSON object generator with the specified overrides.fun.gen.Gen
<? extends JsValue> Converts a spec to a JSON object generator.fun.gen.Gen
<? extends JsValue> Converts a JsSpec to a JSON generator.static SpecToGen
of
(SpecGenConfBuilder confBuilder) Creates a new instance of theSpecToGen
class with the specified configuration.
-
Field Details
-
DEFAULT
The default instance of theSpecToGen
class. To customize how data is generated, use theof(SpecGenConfBuilder)
method to create a new instance with the desired configuration.
-
-
Method Details
-
of
Creates a new instance of theSpecToGen
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
Converts a JsObjSpec to a JSON object generator. It throws aRuntimeException
if the generator cannot be created. In this case, use the alternative methodconvert(JsObjSpec, Map)
that accepts an override parameter to provide a custom generator- Parameters:
objSpec
- The JsObjSpec to be converted.- Returns:
- The resulting JsObjGen
-
convert
Converts a JsObjSpec to a JSON object generator with the specified overrides. It throws aRuntimeException
if the generator cannot be created. In this case, override the generator for the path using theoverrides
parameter.- Parameters:
objSpec
- The JsObjSpec to be converted.overrides
- The overrides to apply to the generator.- Returns:
- The resulting JsObjGen
-
convert
Converts a spec to a JSON object generator. It throws aRuntimeException
if the generator cannot be created. In this case, override the generator for the path using the methodconvert(JsSpec, Map)
.- Parameters:
spec
- The spec to be converted.- Returns:
- The resulting JSON value generator
-
convert
public fun.gen.Gen<? extends JsValue> convert(JsSpec spec, Map<JsPath, fun.gen.Gen<? extends JsValue>> overrides) Converts a JsSpec to a JSON generator. It throws aRuntimeException
if the generator cannot be created. In this case, use the alternative methodconvert(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
-