throws JsonMappingException
{
if (visitor == null) {
return;
}
JsonObjectFormatVisitor objectVisitor = visitor.expectObjectFormat(typeHint);
if (objectVisitor == null) {
return;
}
JavaType valueType = typeHint.containedType(1);
JsonSerializer<Object> ser = _valueSerializer;
if (ser == null && valueType != null) {
ser = visitor.getProvider().findValueSerializer(valueType, _property);
}
if (valueType == null) {
valueType = visitor.getProvider().constructType(Object.class);
}
EnumValues keyEnums = _keyEnums;
if (keyEnums == null) {
JavaType enumType = typeHint.containedType(0);
if (enumType == null) {
throw new IllegalStateException("Can not resolve Enum type of EnumMap: "+typeHint);
}
JsonSerializer<?> enumSer = (enumType == null) ? null :
visitor.getProvider().findValueSerializer(enumType, _property);
if (!(enumSer instanceof EnumSerializer)) {
throw new IllegalStateException("Can not resolve Enum type of EnumMap: "+typeHint);
}
keyEnums = ((EnumSerializer) enumSer).getEnumValues();
}
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);
}
}