public class SchemaBuilderImpl extends Object implements SchemaBuilder
SchemaBuilder
implementation
Listing outstanding items here instead of in the API
TODO add mark/unmark or current support to navigate previous builders
TODO support customer ObjectMapper
TODO support "additionalItems" for array type
TODO support nested array definition for array type
TODO support "definitions"
TODO support "patternProperties"
TODO support "dependencies"
TODO support "allOf"
TODO support "anyOf"
TODO support "oneOf"
TODO support "not"
TODO support "default"Modifier and Type | Field and Description |
---|---|
protected com.boomi.util.json.schema.impl.BoomiAnnotations |
_annotations |
protected ObjectNode |
_root |
protected static String |
SCHEMA_DESCRIPTION |
protected static String |
SCHEMA_EXCLUSIVE_MAXIMUM |
protected static String |
SCHEMA_EXCLUSIVE_MINIMUM |
protected static String |
SCHEMA_FORMAT |
protected static String |
SCHEMA_MAX_ITEMS |
protected static String |
SCHEMA_MAX_LENGTH |
protected static String |
SCHEMA_MAX_PROPERTIES |
protected static String |
SCHEMA_MAXIMUM |
protected static String |
SCHEMA_MIN_ITEMS |
protected static String |
SCHEMA_MIN_LENGTH |
protected static String |
SCHEMA_MIN_PROPERTIES |
protected static String |
SCHEMA_MINIMUM |
protected static String |
SCHEMA_MULTIPLE_OF |
protected static String |
SCHEMA_PATTERN |
protected static String |
SCHEMA_REQUIRED |
protected static String |
SCHEMA_UNIQUE_ITEMS |
Constructor and Description |
---|
SchemaBuilderImpl()
Creates a new instance using
JSONUtil.getDefaultObjectMapper() . |
Modifier and Type | Method and Description |
---|---|
protected void |
addAttribute(String name,
boolean value) |
protected void |
addAttribute(String name,
int value) |
protected void |
addAttribute(String name,
String value) |
FieldSpecBuilder<T> |
buildFieldSpec(String name)
Builder method to add a new "boomi_fieldSpec" annotation to the current
object.
|
ElementTypeBuilder<T> |
buildProperty(String name)
Builder method to add a new property to the document.
|
P |
finish()
This method finalizes the current builder and the returns its parent
builder (i.e, the builder that was used to create the current builder).
|
ObjectNode |
getObjectRoot()
This method returns the root
JsonNode of the current builder. |
ObjectNode |
getProperties()
This method returns the "properties" node of the object definition which
is where any nestesd definitions should be defined.
|
JsonNode |
getSchema()
This method returns the schema document as a
JsonNode . |
protected T |
getThis()
Returns the current builder instance.
|
void |
reset()
This method removes any attributes that have been added and returns the
schema document to its original state.
|
T |
withDescription(String value)
This method includes the "description" attribute in the current type
definition.
|
T |
withId(String value)
This method includes the "id" attribute in the current type definition.
|
T |
withIgnoreForFilters(boolean value)
This method includes the "ignoreForFilters" boomi field spec annotation
in the current type definition.
|
T |
withIgnoreForSelection(boolean value)
This method includes the "ignoreForSelection" boomi field spec annotation
in the current type definition.
|
T |
withIgnoreForSort(boolean value)
This method includes the "ignoreForSort" boomi field spec annotation in
the current type definition.
|
T |
withMaxProperties(int value)
This method includes the "maxProperties" attribute in the object type
definition
|
T |
withMinProperties(int value)
This method includes the "minProperties" attribute in the object type
definition
|
T |
withRequired(String... values)
This method includes the "required" attribute in the object type
definition
|
T |
withTitle(String value)
This method includes the "title" attribute in the current type
definition.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
buildFieldSpec, buildProperty, withMaxProperties, withMinProperties, withRequired
getObjectRoot
withDescription, withId, withIgnoreForFilters, withIgnoreForSelection, withIgnoreForSort, withTitle
protected static final String SCHEMA_MIN_PROPERTIES
protected static final String SCHEMA_MAX_PROPERTIES
protected static final String SCHEMA_UNIQUE_ITEMS
protected static final String SCHEMA_MULTIPLE_OF
protected static final String SCHEMA_PATTERN
protected static final String SCHEMA_MIN_ITEMS
protected static final String SCHEMA_MAX_ITEMS
protected static final String SCHEMA_MIN_LENGTH
protected static final String SCHEMA_MAX_LENGTH
protected static final String SCHEMA_EXCLUSIVE_MAXIMUM
protected static final String SCHEMA_EXCLUSIVE_MINIMUM
protected static final String SCHEMA_MINIMUM
protected static final String SCHEMA_MAXIMUM
protected static final String SCHEMA_FORMAT
protected static final String SCHEMA_REQUIRED
protected static final String SCHEMA_DESCRIPTION
protected final ObjectNode _root
protected final com.boomi.util.json.schema.impl.BoomiAnnotations _annotations
public SchemaBuilderImpl()
JSONUtil.getDefaultObjectMapper()
.
Sets the schema type to object and the $schema to
JSONUtil.SchemaVersion#DRAFT_04
.public JsonNode getSchema()
SchemaBuilder
JsonNode
. The method
can be called multiple times and will return the current state of the
schema.getSchema
in interface SchemaBuilder
public void reset()
SchemaBuilder
reset
in interface SchemaBuilder
public FieldSpecBuilder<T> buildFieldSpec(String name)
ComplexTypeBuilder
buildFieldSpec
in interface ComplexTypeBuilder<T extends ComplexTypeBuilder<T>>
name
- the name of the field specFieldSpecBuilder
instance that can be used to continue
building on the field specpublic ObjectNode getProperties()
public ElementTypeBuilder<T> buildProperty(String name)
ComplexTypeBuilder
ComplexTypeBuilder
instance. The method will return an
ElementTypeBuilder
instance that can be used to obtain a builder
for desired property type. A call to NestedBuilder.finish()
on
the type specific builder will return the original builder instance. The
property will be replaced if this method is called multiple times with
the same name.buildProperty
in interface ComplexTypeBuilder<T extends ComplexTypeBuilder<T>>
name
- the name of the propertyArrayTypeBuilder
instance that can be used to continue
building on the array propertypublic T withRequired(String... values)
ComplexTypeBuilder
withRequired
in interface ComplexTypeBuilder<T extends ComplexTypeBuilder<T>>
values
- the value array of the attributeObjectTypeBuilder
instancepublic T withMaxProperties(int value)
ComplexTypeBuilder
withMaxProperties
in interface ComplexTypeBuilder<T extends ComplexTypeBuilder<T>>
ObjectTypeBuilder
instancepublic T withMinProperties(int value)
ComplexTypeBuilder
withMinProperties
in interface ComplexTypeBuilder<T extends ComplexTypeBuilder<T>>
ObjectTypeBuilder
instancepublic P finish()
NestedBuilder
finish
in interface NestedBuilder<P extends NestingBuilder>
public T withId(String value)
CommonBuilder
withId
in interface CommonBuilder<T extends CommonBuilder<T>>
value
- the value of the attributepublic T withDescription(String value)
CommonBuilder
withDescription
in interface CommonBuilder<T extends CommonBuilder<T>>
value
- the value of the attributepublic T withIgnoreForFilters(boolean value)
CommonBuilder
withIgnoreForFilters
in interface CommonBuilder<T extends CommonBuilder<T>>
value
- the value of the attributepublic T withIgnoreForSelection(boolean value)
CommonBuilder
withIgnoreForSelection
in interface CommonBuilder<T extends CommonBuilder<T>>
value
- the value of the attributepublic T withIgnoreForSort(boolean value)
CommonBuilder
withIgnoreForSort
in interface CommonBuilder<T extends CommonBuilder<T>>
value
- the value of the attributepublic ObjectNode getObjectRoot()
NestingBuilder
JsonNode
of the current builder.getObjectRoot
in interface NestingBuilder
public T withTitle(String value)
CommonBuilder
withTitle
in interface CommonBuilder<T extends CommonBuilder<T>>
value
- the value of the attributeprotected void addAttribute(String name, int value)
protected void addAttribute(String name, boolean value)
protected final T getThis()
return this;
has some
weirdness because of the generic typing