@Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { JsonObjectFormatVisitor objectVisitor = visitor.expectObjectFormat(typeHint); /* JavaType enumType = typeHint.containedType(0); if (enumType == null) { enumType = visitor.getProvider().constructType(Object.class); } */ JavaType valueType = typeHint.containedType(1); if (valueType == null) { valueType = visitor.getProvider().constructType(Object.class); } JsonSerializer<Object> ser = _valueSerializer; // Class<Enum<?>> enumClass = (Class<Enum<?>>) enumType.getRawClass(); for (Map.Entry<?,SerializedString> entry : _keyEnums.internalMap().entrySet()) { String name = entry.getValue().getValue(); // should all have the same type, so: if (ser == null) { ser = visitor.getProvider().findValueSerializer(entry.getKey().getClass(), _property); } objectVisitor.property(name, (JsonFormatVisitable) ser, valueType); } }
@Override public void itemsFormat(JsonFormatVisitable handler, JavaType elementType) throws JsonMappingException { String elementPath = path + "[]"; JsonFormatVisitorWrapper visitor = new FieldDocumentationVisitorWrapper(getProvider(), context, elementPath, null, typeRegistry, typeFactory); handler.acceptJsonFormatVisitor(visitor, elementType); }
/** Visit recursively the type, or return a cached response */ public static AbstractType getTSTypeForHandler(ABaseTSJsonFormatVisitor<?> baseVisitor, JsonFormatVisitable handler, JavaType typeHint, Configuration conf) throws JsonMappingException { AbstractType computedType = baseVisitor.getComputedTypes().get(typeHint); if (computedType != null) { return computedType; } TSJsonFormatVisitorWrapper visitor = new TSJsonFormatVisitorWrapper(baseVisitor, conf); handler.acceptJsonFormatVisitor(visitor, typeHint); baseVisitor.getComputedTypes().put(typeHint, visitor.getType()); return visitor.getType(); }
@Override public void itemsFormat(JsonFormatVisitable handler, JavaType elementType) throws JsonMappingException { TSJsonFormatVisitorWrapper visitorWrapper = new TSJsonFormatVisitorWrapper(this, conf); handler.acceptJsonFormatVisitor(visitorWrapper, elementType); type.setItemType(visitorWrapper.getType()); }
@Override public void property(String name, JsonFormatVisitable handler, JavaType propertyTypeHint) throws JsonMappingException { addField(name, getTSTypeForHandler(this, handler, propertyTypeHint, conf)); }
@Override public void optionalProperty(String name, JsonFormatVisitable handler, JavaType propertyTypeHint) throws JsonMappingException { addField(name, getTSTypeForHandler(this, handler, propertyTypeHint, conf)); }
@Override public void keyFormat(JsonFormatVisitable handler, JavaType keyType) throws JsonMappingException { type.setKeyType(getTSTypeForHandler(this, handler, keyType, conf)); }
@Override public void valueFormat(JsonFormatVisitable handler, JavaType valueType) throws JsonMappingException { type.setValueType(getTSTypeForHandler(this, handler, valueType, conf)); }