@Override
 public void serialize(Map<?, ?> value, JsonGenerator gen, SerializerProvider provider)
     throws IOException {
   gen.writeStartObject(value);
   if (!value.isEmpty()) {
     if (_sortKeys || provider.isEnabled(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS)) {
       value = _orderEntries(value, gen, provider);
     }
     PropertyFilter pf;
     if ((_filterId != null) && (pf = findPropertyFilter(provider, _filterId, value)) != null) {
       serializeFilteredFields(value, gen, provider, pf, _suppressableValue);
     } else if ((_suppressableValue != null) || _suppressNulls) {
       serializeOptionalFields(value, gen, provider, _suppressableValue);
     } else if (_valueSerializer != null) {
       serializeFieldsUsing(value, gen, provider, _valueSerializer);
     } else {
       serializeFields(value, gen, provider);
     }
   }
   gen.writeEndObject();
 }
 @Override
 public void serializeWithType(
     Map<?, ?> value, JsonGenerator gen, SerializerProvider provider, TypeSerializer typeSer)
     throws IOException {
   typeSer.writeTypePrefixForObject(value, gen);
   // [databind#631]: Assign current value, to be accessible by custom serializers
   gen.setCurrentValue(value);
   if (!value.isEmpty()) {
     if (_sortKeys || provider.isEnabled(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS)) {
       value = _orderEntries(value, gen, provider);
     }
     PropertyFilter pf;
     if ((_filterId != null) && (pf = findPropertyFilter(provider, _filterId, value)) != null) {
       serializeFilteredFields(value, gen, provider, pf, _suppressableValue);
     } else if ((_suppressableValue != null) || _suppressNulls) {
       serializeOptionalFields(value, gen, provider, _suppressableValue);
     } else if (_valueSerializer != null) {
       serializeFieldsUsing(value, gen, provider, _valueSerializer);
     } else {
       serializeFields(value, gen, provider);
     }
   }
   typeSer.writeTypeSuffixForObject(value, gen);
 }