@SuppressWarnings("unchecked")
    static void writeObjectTo(Output output, Object value,
            Schema<?> currentSchema, IdStrategy strategy) throws IOException
    {
        if (Collections.class == value.getClass().getDeclaringClass())
        {
            writeNonPublicMapTo(output, value, currentSchema, strategy);
            return;
        }

        Class<Object> clazz = (Class<Object>) value.getClass();
        if (EnumMap.class.isAssignableFrom(clazz))
        {
            strategy.writeEnumIdTo(output, ID_ENUM_MAP,
                    EnumIO.getKeyTypeFromEnumMap(value));

            // TODO use enum schema
        }
        else
        {
            strategy.writeMapIdTo(output, ID_MAP, clazz);
        }

        if (output instanceof StatefulOutput)
        {
            // update using the derived schema.
            ((StatefulOutput) output).updateLast(strategy.MAP_SCHEMA,
                    currentSchema);
        }

        strategy.MAP_SCHEMA.writeTo(output, (Map<Object, Object>) value);
    }
Used when the type is an interface (Map/SortedMap).

@author David Yu
@created Apr 24, 2012
protostuff-runtime/src/main/java/io/protostuff/runtime/PolymorphicMapSchema.java