Package org.jtester.bytecode.reflector

Examples of org.jtester.bytecode.reflector.MethodAccessor


   */
  private Object instancePara(Parse cells) throws Exception {
    if (this.parsePropertyMethodName != null) {
      String text = cells.text();
      try {
        MethodAccessor methodAccessor = new MethodAccessor<Object>(this, parsePropertyMethodName, String.class);
        return methodAccessor.invoke(this, new Object[] { text });
      } catch (NoSuchMethodRuntimeException e) {
        TypeAdapter typeAdapter = TypeAdapter.on(this, dtoClazz);
        return typeAdapter.parse(text);
      }
    }
View Full Code Here


      this.typeAdapter = TypeAdapter.on(DtoPropertyFixture.this, fieldAccessor.getFieldType());
    }

    public void setValue(Object obj, String value) throws Exception {
      try {
        MethodAccessor methodAccessor = new MethodAccessor<Object>(obj, parseMethodName, String.class);
        methodAccessor.invoke(obj, new Object[] { value });
      } catch (NoSuchMethodRuntimeException e) {
        Object _value = typeAdapter.parse(value);
        fieldAccessor.set(obj, _value);
      }
    }
View Full Code Here

    if (target == null) {
      throw new RuntimeException("the target object can't be null!");
    }
    Object _target = ClazzHelper.getProxiedObject(target);
    Class[] paraClazes = MethodHelper.getParameterClazz(paras);
    MethodAccessor methodAccessor = new MethodAccessor(clazz, method, paraClazes);
    Object result = methodAccessor.invokeUnThrow(_target, paras);
    return (T) result;
  }
View Full Code Here

   * @return
   * @throws Exception
   */
  public static <T> T invoke(Object target, String method, Object... paras) throws Exception {
    Class[] paraClazes = getParameterClazz(paras);
    MethodAccessor accessor = new MethodAccessor(target, method, paraClazes);
    Object result = accessor.invoke(target, paras);
    return (T) result;
  }
View Full Code Here

    return (T) result;
  }

  public static <T> T invokeUnThrow(Object target, String method, Object... paras) {
    Class[] paraClazes = getParameterClazz(paras);
    MethodAccessor accessor = new MethodAccessor(target, method, paraClazes);
    Object result = accessor.invokeUnThrow(target, paras);
    return (T) result;
  }
View Full Code Here

    if (paras != null) {
      for (Object para : paras) {
        paraClazz.add(para == null ? null : para.getClass());
      }
    }
    MethodAccessor accessor = new MethodAccessor(targetClass, method, paraClazz.toArray(new Class[0]));
    return (T) accessor.invokeStaticUnThrow(paras);
  }
View Full Code Here

TOP

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

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.