@Override
        public <T> Field<T> create(int number, java.lang.String name,
                final java.lang.reflect.Field f, 
                final IdStrategy strategy)
        {
            final EnumIO<? extends Enum<?>> eio = strategy.getEnumIO(f
                    .getType());
            return new Field<T>(FieldType.ENUM, number, name,
                    f.getAnnotation(Tag.class))
            {
                {
                    f.setAccessible(true);
                }

                public void mergeFrom(Input input, T message)
                        throws IOException
                {
                    try
                    {
                        f.set(message, eio.readFrom(input));
                    }
                    catch (IllegalAccessException e)
                    {
                        throw new RuntimeException(e);
                    }
                    catch (IllegalArgumentException e)
                    {
                        throw new RuntimeException(e);
                    }
                }

                public void writeTo(Output output, T message)
                        throws IOException
                {
                    final Enum<?> existing;
                    try
                    {
                        existing = (Enum<?>) f.get(message);
                    }
                    catch (IllegalAccessException e)
                    {
                        throw new RuntimeException(e);
                    }
                    catch (IllegalArgumentException e)
                    {
                        throw new RuntimeException(e);
                    }

                    if (existing != null)
                        eio.writeTo(output, number, repeated, existing);
                }

                public void transfer(Pipe pipe, Input input, Output output,
                        boolean repeated) throws IOException
                {
                    EnumIO.transfer(pipe, input, output, number, repeated, strategy);
                }
            };
        }
Field factory via plain old reflection api.

@author David Yu
@created Jul 7, 2011
protostuff-runtime/src/main/java/io/protostuff/runtime/RuntimeReflectionFieldFactory.java