Package org.jtester.bytecode.reflector

Examples of org.jtester.bytecode.reflector.FieldAccessor


    T pojo = ClazzHelper.newInstance(clazz);
    for (int index = 1; index <= count; index++) {
      String key = getCamelFieldName(rsmd, index, true);

      try {
        FieldAccessor accessor = new FieldAccessor(clazz, key);
        Object o = rs.getObject(index);
        Object value = DbParameterAccessor.normaliseValue(o);
        accessor.set(pojo, value);
      } catch (NoSuchFieldRuntimeException e) {
        JTesterLogger.warn("set pojo property errro: " + e.getMessage());
      }
    }
    return pojo;
View Full Code Here


    private FieldAccessor fieldAccessor;
    private String parseMethodName;
    private TypeAdapter typeAdapter;

    public PropertyBinding(String property) throws Exception {
      this.fieldAccessor = new FieldAccessor(dtoClazz, camel(property));
      this.parseMethodName = camel("parse " + property);
      this.typeAdapter = TypeAdapter.on(DtoPropertyFixture.this, fieldAccessor.getFieldType());
    }
View Full Code Here

    }
    Object value = null;
    if (expected instanceof Map) {
      value = ((Map) expected).get(field);
    } else {
      FieldAccessor accessor = new FieldAccessor(expected, field);
      value = accessor.get(expected);
    }
    if (value == null) {
      return "<null>";
    } else {
      return value.toString();
View Full Code Here

  public void setField(Class clazz, Object target, String field, Object value) {
    if (target == null) {
      throw new RuntimeException("the target object can't be null!");
    }
    Object _target = ClazzHelper.getProxiedObject(target);
    FieldAccessor accessor = new FieldAccessor(clazz, field);
    accessor.set(_target, value);
  }
View Full Code Here

  public <T> T getField(Class clazz, Object target, String field) {
    if (target == null) {
      throw new RuntimeException("the target object can't be null!");
    }
    Object _target = ClazzHelper.getProxiedObject(target);
    FieldAccessor accessor = new FieldAccessor(clazz, field);
    return (T) accessor.get(_target);
  }
View Full Code Here

   * @param clazz
   * @param field
   * @return
   */
  public <T> T getStaticField(Class clazz, String field) {
    FieldAccessor accessor = new FieldAccessor(clazz, field);
    Object o = accessor.getStatic();
    return (T) o;
  }
View Full Code Here

   * @param clazz
   * @param field
   * @param value
   */
  public void setStaticField(Class clazz, String field, Object value) {
    FieldAccessor accessor = new FieldAccessor(clazz, field);
    accessor.setStatic(value);
  }
View Full Code Here

  private final Class testClazz;

  public FieldProxy(final Class testClazz, final String fieldName) {
    this.fieldName = fieldName;
    this.accessor = new FieldAccessor(testClazz, fieldName);
    this.testClazz = testClazz;
  }
View Full Code Here

   */
  public static void setFieldValue(Object target, String fieldName, Object fieldValue) {
    if (target == null) {
      throw new RuntimeException("the target object can't be null.");
    }
    FieldAccessor accessor = new FieldAccessor(target.getClass(), fieldName);
    accessor.set(target, fieldValue);
  }
View Full Code Here

   */
  public static Object getFieldValue(Object target, String fieldName) {
    if (target == null) {
      throw new RuntimeException("the target object can't be null.");
    }
    FieldAccessor accessor = new FieldAccessor(target.getClass(), fieldName);
    Object o = accessor.get(target);
    return o;
  }
View Full Code Here

TOP

Related Classes of org.jtester.bytecode.reflector.FieldAccessor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.