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

        return new RuntimeMapField<T, Enum<?>, Enum<?>>(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<?>, Enum<?>>) accessor.get(message), schema));
            }

            @Override
            @SuppressWarnings("unchecked")
            protected void writeTo(Output output, T message) throws IOException
            {
                final Map<Enum<?>, Enum<?>> 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<?>, Enum<?>> 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<?>, Enum<?>> wrapper, Enum<?> key)
                    throws IOException
            {
                wrapper.put(key, eioV.readFrom(input));
            }

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

            @Override
            protected void vTransfer(Pipe pipe, Input input, Output output,
                    int number, boolean repeated) throws IOException
            {
                EnumIO.transfer(pipe, input, output, number, repeated, 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