Exemplo n.º 1
0
  private int getParamIndexByName(Method method, String paramName) {
    Parameter[] params = method.getParameters();
    for (int i = 0; i < params.length; i++) {
      if (paramName.equals(params[i].getName())) return i;
    }

    return -1;
  }
Exemplo n.º 2
0
  /** Object[] invocation.getArguments() */
  public Object[] createArgs(
      MethodInvocation invocation, Method method, Object returnValue, Throwable throwingValue) {
    Parameter[] params = method.getParameters();
    Object[] result = new Object[params.length];
    for (int i = 0; i < params.length; i++) {
      Parameter param = params[i];

      if (onlyOneByType(params, param)) {
        result[i] = getArgByType_OnlyOne(invocation, param.getTypeName());
      }
    }

    int paramIndex = this.getReturningParamIndex(method);
    if (paramIndex >= 0) result[paramIndex] = returnValue;

    paramIndex = this.getAfterThrowingParamIndex(method);
    if (paramIndex >= 0) result[paramIndex] = throwingValue;

    return result;
  }