private static <T> Field<T> createMapEnumKObjectV(int number, String name,
            final java.lang.reflect.Field f, final MessageFactory messageFactory,
            final Class<Object> clazzK, final Schema<Object> valueSchema,
            final Pipe.Schema<Object> valuePipeSchema, final IdStrategy strategy)
    {
        final EnumIO<?> eioK = strategy.getEnumIO(clazzK);

        return new RuntimeMapField<T, Enum<?>, Object>(FieldType.MESSAGE,
                number, name, f.getAnnotation(Tag.class), messageFactory)
        {

            final Accessor accessor = AF.create(f);

            @Override
            @SuppressWarnings("unchecked")
            protected void mergeFrom(Input input, T message) throws IOException
            {
                accessor.set(message, input.mergeObject(
                        (Map<Enum<?>, Object>) accessor.get(message), schema));
            }

            @Override
            @SuppressWarnings("unchecked")
            protected void writeTo(Output output, T message) throws IOException
            {
                final Map<Enum<?>, Object> existing = accessor.get(message);

                if (existing != null)
                    output.writeObject(number, existing, schema, false);
            }

            @Override
            protected void transfer(Pipe pipe, Input input, Output output,
                    boolean repeated) throws IOException
            {
                output.writeObject(number, pipe, schema.pipeSchema, repeated);
            }

            @Override
            protected Enum<?> kFrom(Input input,
                    MapWrapper<Enum<?>, Object> wrapper) throws IOException
            {
                return eioK.readFrom(input);
            }

            @Override
            protected void kTo(Output output, int fieldNumber, Enum<?> key,
                    boolean repeated) throws IOException
            {
                eioK.writeTo(output, fieldNumber, repeated, key);
            }

            @Override
            protected void kTransfer(Pipe pipe, Input input, Output output,
                    int number, boolean repeated) throws IOException
            {
                EnumIO.transfer(pipe, input, output, number, repeated, strategy);
            }

            @Override
            protected void vPutFrom(Input input,
                    MapWrapper<Enum<?>, Object> wrapper, Enum<?> key)
                    throws IOException
            {
                final Object value = input.mergeObject(wrapper, valueSchema);
                if (value != wrapper)
                {
                    // referenced.
                    // An entry would never have a cyclic reference.
                    ((GraphInput) input).updateLast(value, wrapper);

                    wrapper.put(key, value);
                    return;
                }

                if (key != null)
                {
                    // we can already add the entry.
                    wrapper.put(key, wrapper.setValue(null));
                }
            }

            @Override
            protected void vTo(Output output, int fieldNumber, Object val,
                    boolean repeated) throws IOException
            {
                output.writeObject(fieldNumber, val, valueSchema, repeated);
            }

            @Override
            protected void vTransfer(Pipe pipe, Input input, Output output,
                    int number, boolean repeated) throws IOException
            {
                output.writeObject(number, pipe, valuePipeSchema, repeated);
            }
            
            @Override
            protected Field<T> copy(IdStrategy strategy)
            {
                return createMapEnumKObjectV(number, name, f, messageFactory, clazzK, 
                        valueSchema, valuePipeSchema, strategy);
            }
        };
    }
Static utility for creating runtime {@link java.util.Map} fields.

@author David Yu
@created Jan 21, 2011
protostuff-runtime/src/main/java/io/protostuff/runtime/RuntimeMapFieldFactory.java