public static BeanValueAccessor createAccessor(Object bean, final String propertyName) {
    Field[] fields = bean.getClass().getFields();
    for (final Field field : fields) {
      if (field.getName().equals(propertyName)) {
        return new BeanValueAccessor(bean, propertyName) {
          @Override
          protected Object doGetValue() throws IllegalAccessException {
            return field.get(myBean);
          }

          @Override
          protected void doSetValue(Object value) throws IllegalAccessException {
            field.set(myBean, value);
          }

          @Override
          public Class getType() {
            return field.getType();
          }
        };
      }
    }
    try {
      BeanInfo beanInfo = Introspector.getBeanInfo(bean.getClass());
      for (final PropertyDescriptor descriptor : beanInfo.getPropertyDescriptors()) {
        if (descriptor.getName().equals(propertyName)) {
          return new BeanValueAccessor(bean, propertyName) {
            @Override
            protected Object doGetValue() throws Exception {
              return descriptor.getReadMethod().invoke(myBean);
            }

            @Override
            protected void doSetValue(Object value) throws Exception {
              descriptor.getWriteMethod().invoke(myBean, value);
            }

            @Override
            public Class getType() {
              return descriptor.getPropertyType();
            }
          };
        }
      }
      throw new IllegalArgumentException("Property " + propertyName + " not found in " + bean.getClass());
    }
    catch (IntrospectionException e) {
      throw new RuntimeException(e);
    }
  }
public static BeanValueAccessor createAccessor(Object bean, final String propertyName)