下面列出了怎么用com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatTypes的API类实例代码及写法,或者点击链接到github查看源代码。
private static void checkTestServerSchemaMap(Map<String, JsonSchema> schemaMap) {
JsonSchema descSchema = schemaMap.get("Description");
JsonSchema specSchema = schemaMap.get("Specification");
assertNotNull(descSchema);
assertNotNull(schemaMap.get("ID"));
assertNotNull(schemaMap.get("Name"));
assertNotNull(specSchema);
JsonFormatTypes descType = descSchema.getType();
assertNotNull(descType);
assertEquals(JsonFormatTypes.STRING, descType);
assertEquals(false, descSchema.getRequired());
JsonFormatTypes specType = specSchema.getType();
assertNotNull(specType);
assertEquals(JsonFormatTypes.OBJECT, specType);
assertEquals(false, specSchema.getRequired());
assertThat(specSchema).isInstanceOf(ObjectSchema.class);
ObjectSchema specObjSchema = specSchema.asObjectSchema();
assertEquals(4, specObjSchema.getProperties().size());
}
public HttpRequestWrapperProcessorTest() {
final ObjectSchema parameters = new ObjectSchema();
parameters.putProperty("param1", JsonSchema.minimalForFormat(JsonFormatTypes.STRING));
parameters.putProperty("param2", JsonSchema.minimalForFormat(JsonFormatTypes.STRING));
schema.putProperty("parameters", parameters);
final ObjectSchema body = new ObjectSchema();
body.putProperty("body1", JsonSchema.minimalForFormat(JsonFormatTypes.STRING));
body.putProperty("body2", JsonSchema.minimalForFormat(JsonFormatTypes.STRING));
schema.putProperty("body", body);
}
@Override // since 2.9
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint)
throws JsonMappingException
{
// 31-Mar-2017, tatu: Use same type as `ByteArraySerializer`: not optimal but has to do
JsonArrayFormatVisitor v2 = visitor.expectArrayFormat(typeHint);
if (v2 != null) {
v2.itemsFormat(JsonFormatTypes.INTEGER);
}
}
@Override
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint)
throws JsonMappingException
{
// 14-Mar-2016, tatu: while logically (and within JVM) binary, gets encoded as Base64 String,
// let's try to indicate it is array of Bytes... difficult, thanks to JSON Schema's
// lackluster listing of types
//
// TODO: for 2.8, make work either as String/base64, or array of numbers,
// with a qualifier that can be used to determine it's byte[]
JsonArrayFormatVisitor v2 = visitor.expectArrayFormat(typeHint);
if (v2 != null) {
v2.itemsFormat(JsonFormatTypes.INTEGER);
}
}
@Override
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint)
throws JsonMappingException
{
if (visitor != null) {
JsonArrayFormatVisitor v2 = visitor.expectArrayFormat(typeHint);
if (v2 != null) {
v2.itemsFormat(JsonFormatTypes.INTEGER);
}
}
}
@Override
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint)
throws JsonMappingException
{
if (visitor != null) {
JsonArrayFormatVisitor v2 = visitor.expectArrayFormat(typeHint);
if (v2 != null) {
v2.itemsFormat(JsonFormatTypes.INTEGER);
}
}
}
@Override
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint)
throws JsonMappingException
{
if (visitor != null) {
JsonArrayFormatVisitor v2 = visitor.expectArrayFormat(typeHint);
if (v2 != null) {
v2.itemsFormat(JsonFormatTypes.INTEGER);
}
}
}
@Override
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint)
throws JsonMappingException
{
if (visitor != null) {
JsonArrayFormatVisitor v2 = visitor.expectArrayFormat(typeHint);
if (v2 != null) {
v2.itemsFormat(JsonFormatTypes.INTEGER);
}
}
}
@Override
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint)
throws JsonMappingException
{
if (visitor != null) {
JsonArrayFormatVisitor v2 = visitor.expectArrayFormat(typeHint);
if (v2 != null) {
v2.itemsFormat(JsonFormatTypes.NUMBER);
}
}
}
@Override
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint)
throws JsonMappingException
{
if (visitor != null) {
JsonArrayFormatVisitor v2 = visitor.expectArrayFormat(typeHint);
if (v2 != null) {
v2.itemsFormat(JsonFormatTypes.NUMBER);
}
}
}
@Override
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint)
throws JsonMappingException
{
if (visitor != null) {
JsonArrayFormatVisitor v2 = visitor.expectArrayFormat(typeHint);
if (v2 != null) {
v2.itemsFormat(JsonFormatTypes.BOOLEAN);
}
}
}
@Override
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint)
throws JsonMappingException
{
if (visitor != null) {
JsonArrayFormatVisitor v2 = visitor.expectArrayFormat(typeHint);
if (v2 != null) {
v2.itemsFormat(JsonFormatTypes.STRING);
}
}
}
@Override
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint)
throws JsonMappingException
{
visitArrayFormat(visitor, typeHint, JsonFormatTypes.BOOLEAN);
}
@Override
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint)
throws JsonMappingException
{
visitArrayFormat(visitor, typeHint, JsonFormatTypes.INTEGER);
}
@Override
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint)
throws JsonMappingException
{
visitArrayFormat(visitor, typeHint, JsonFormatTypes.STRING);
}
@Override
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException
{
visitArrayFormat(visitor, typeHint, JsonFormatTypes.INTEGER);
}
@Override
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint)
throws JsonMappingException
{
visitArrayFormat(visitor, typeHint, JsonFormatTypes.NUMBER);
}
@Override
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException
{
visitArrayFormat(visitor, typeHint, JsonFormatTypes.NUMBER);
}
@Override
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint)
throws JsonMappingException
{
visitArrayFormat(visitor, typeHint, JsonFormatTypes.NUMBER);
}
@Override
protected void acceptContentVisitor(JsonArrayFormatVisitor visitor) throws JsonMappingException {
visitor.itemsFormat(JsonFormatTypes.STRING);
}
@Override
protected void acceptContentVisitor(JsonArrayFormatVisitor visitor) throws JsonMappingException
{
visitor.itemsFormat(JsonFormatTypes.STRING);
}
@Override
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException
{
visitArrayFormat(visitor, typeHint, JsonFormatTypes.STRING);
}