Java Code Examples for java.lang.reflect.Method.getParameterAnnotations()

The following are Jave code examples for showing how to use getParameterAnnotations() of the java.lang.reflect.Method class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: vertx-zero   File: Depot.java   View Source Code Vote up 6 votes
private void initAnnotationsWithName(final Method method) {
    final Annotation[][] annotations = method.getParameterAnnotations();
    Fn.itArray(annotations, (annotationArr, index) -> {
        // Find annotation class
        final Annotation annotation = findAnnotation(annotationArr);
        final Class<? extends Annotation> annoCls = (null == annotation)
                ? null : annotation.annotationType();
        this.paramAnnos.add(annoCls);
        // Check names
        if (null != annoCls) {
            if (Filler.NO_VALUE.contains(annoCls)) {
                this.paramNames.add(ID.DIRECT);
            } else {
                final String name = Instance.invoke(annotation, "value");
                this.paramNames.add(name);
            }
        } else {
            this.paramNames.add(ID.IGNORE);
        }
        // Besure the params are length match others.
        this.paramValues.add(null);
    });
}
 
Example 2
Project: Equella   File: XFireCompatabilityConfiguration.java   View Source Code Vote up 6 votes
@Override
public QName getInParameterName(OperationInfo op, Method method, int paramNumber)
{
	Annotation[][] annos = method.getParameterAnnotations();
	if( annos.length > paramNumber )
	{
		Annotation[] paramAnnos = annos[paramNumber];
		for( Annotation anno : paramAnnos )
		{
			if( anno instanceof WebParam )
			{
				WebParam webParam = (WebParam) anno;
				String targetNs = webParam.targetNamespace();
				if( Check.isEmpty(targetNs) )
				{
					targetNs = op.getName().getNamespaceURI();
				}
				return new QName(targetNs, webParam.name());
			}
		}
	}

	return new QName(op.getName().getNamespaceURI(), "in" + paramNumber);
}
 
Example 3
Project: promagent   File: Delegator.java   View Source Code Vote up 6 votes
private static List<Class<?>> stripReturnedAndThrown(Method hookMethod) {
    Class<?>[] allTypes = hookMethod.getParameterTypes();
    Annotation[][] annotations = hookMethod.getParameterAnnotations();
    if (allTypes.length != annotations.length) {
        throw new HookException("Method.getParameterAnnotations() returned an unexpected value. This is a bug in promagent.");
    }
    List<Class<?>> result = new ArrayList<>();
    for (int i=0; i<allTypes.length; i++) {
        if (Arrays.stream(annotations[i])
                .map(Annotation::annotationType)
                .noneMatch(a -> Returned.class.equals(a) || Thrown.class.equals(a))) {
            result.add(allTypes[i]);
        }
    }
    return result;
}
 
Example 4
Project: crnk-framework   File: JacksonResourceFieldInformationProvider.java   View Source Code Vote up 6 votes
protected Optional<String> getName(Method method) {
	ObjectMapper objectMapper = context.getObjectMapper();
	SerializationConfig serializationConfig = objectMapper.getSerializationConfig();
	if (serializationConfig != null && serializationConfig.getPropertyNamingStrategy() != null) {
		String name = ClassUtils.getGetterFieldName(method);
		Annotation[] declaredAnnotations = method.getDeclaredAnnotations();
		AnnotationMap annotationMap = buildAnnotationMap(declaredAnnotations);

		int paramsLength = method.getParameterAnnotations().length;
		AnnotationMap[] paramAnnotations = new AnnotationMap[paramsLength];
		for (int i = 0; i < paramsLength; i++) {
			AnnotationMap parameterAnnotationMap = buildAnnotationMap(method.getParameterAnnotations()[i]);
			paramAnnotations[i] = parameterAnnotationMap;
		}

		AnnotatedClass annotatedClass = AnnotatedClassBuilder.build(method.getDeclaringClass(), serializationConfig);
		AnnotatedMethod annotatedField = AnnotatedMethodBuilder.build(annotatedClass, method, annotationMap, paramAnnotations);
		return Optional.of(serializationConfig.getPropertyNamingStrategy().nameForGetterMethod(serializationConfig, annotatedField, name));
	}
	return Optional.empty();
}
 
Example 5
Project: dooo   File: SpringContainer.java   View Source Code Vote up 5 votes
private void parse(Action action) {
    Class clazz = action.getClass();
    FastClass fastClass = FastClass.create(clazz);
    for (Method method : clazz.getDeclaredMethods()) {
        InterfaceTarget interfaceTarget = method.getAnnotation(InterfaceTarget.class);
        if (interfaceTarget == null) {
            continue;
        }
        String interfaceKey = interfaceTarget.path() + "_" + interfaceTarget.version();
        InterfaceHandler interfaceHandler = new InterfaceHandler(interfaceKey, action, method, fastClass.getMethod(method));

        // 返回表示按照声明顺序对此 Method对象所表示方法的形参进行注释的那个数组的数组。
        String[] parameterNames = parameterNameDiscoverer.getParameterNames(method);
        Class<?>[] parameterTypes = method.getParameterTypes();
        Annotation[][] parameterAnnotations = method.getParameterAnnotations();
        Preconditions.checkArgument(parameterNames.length == parameterTypes.length);
        Preconditions.checkArgument(parameterNames.length == parameterAnnotations.length);
        int parameterCount = parameterTypes.length;
        for (int i = 0; i < parameterCount; i++) {
            Annotation[] annotations = parameterAnnotations[i];
            Class<?> parameterClazz = parameterTypes[i];
            String parameterName = parameterNames[i];
            resolveParameter(parameterName, parameterClazz, annotations, interfaceHandler);
        }

        LOGGER.info("path {} ,handle {}", interfaceKey, interfaceHandler);
        interfaceHandlerHashMap.put(interfaceKey, interfaceHandler);
    }
}
 
Example 6
Project: crnk-framework   File: JaxrsModule.java   View Source Code Vote up 5 votes
private boolean hasJaxRsMethodParameters(Method method) {
	Annotation[][] parameterAnnotationsArray = method.getParameterAnnotations();
	for (int paramIndex = 0; paramIndex < parameterAnnotationsArray.length; paramIndex++) {
		Annotation[] parameterAnnotations = parameterAnnotationsArray[paramIndex];
		for (Annotation parameterAnnotation : parameterAnnotations) {
			if (parameterAnnotation instanceof PathParam || parameterAnnotation instanceof QueryParam) {
				return true;
			}
		}
	}
	return false;
}
 
Example 7
Project: jdk8u-jdk   File: RedefineMethodWithAnnotationsApp.java   View Source Code Vote up 5 votes
private static void verifyMethodParameterAnnotationsValue(
        String expectedValue) throws Exception {
    Class<RedefineMethodWithAnnotationsTarget> c =
            RedefineMethodWithAnnotationsTarget.class;
    Method method = c.getMethod("annotatedMethod", String.class);

    Annotation [][] parametersAnnotations =
            method.getParameterAnnotations();
    if (parametersAnnotations.length != 1) {
        throw new Exception("Incorrect number of parameters to method: " +
                method.getName() + "." +
                " Expected: 1," +
                " got: " + parametersAnnotations.length);
    }

    Annotation[] parameterAnnotations = parametersAnnotations[0];
    if (parameterAnnotations.length != 1) {
        throw new Exception("Incorrect number of annotations." +
                " Expected: 1" +
                ", got " + parameterAnnotations.length);
    }

    Annotation parameterAnnotation = parameterAnnotations[0];
    if (!(parameterAnnotation instanceof ParameterAnnotation)) {
        throw new Exception("Incorrect Annotation class." +
                " Expected: " + ParameterAnnotation.class.getName() +
                ", got: " + parameterAnnotation.getClass().getName());
    }

    ParameterAnnotation pa = (ParameterAnnotation)parameterAnnotation;
    String annotationValue = pa.value();
    if (!expectedValue.equals(annotationValue)) {
        throw new Exception("Incorrect parameter annotation value." +
                " Expected: " + expectedValue +
                ", got: " + annotationValue);
    }
}
 
Example 8
Project: Meepo   File: DefaultParser.java   View Source Code Vote up 5 votes
@NonNull
@Override
public CallMethod parseMethod(@NonNull Config config, @NonNull Method method) {
    final Annotation[] methodAnnotations = method.getAnnotations();
    final Annotation[][] parameterAnnotationsArray = method.getParameterAnnotations();

    final CallMethod callMethod = new CallMethod();
    parseMethodAnnotations(callMethod, methodAnnotations, parameterAnnotationsArray);
    parseParameterAnnotation(callMethod, parameterAnnotationsArray);

    return callMethod;
}
 
Example 9
Project: jdk8u-jdk   File: ParameterAnnotations.java   View Source Code Vote up 5 votes
void test1() throws Throwable {
    for (Method m : thisClass.getMethods()) {
        if (m.getName().equals("nop")) {
            Annotation[][] ann = m.getParameterAnnotations();
            equal(ann.length, 2);
            Annotation foo = ann[0][0];
            Annotation bar = ann[1][0];
            equal(foo.toString(), "@Named(value=foo)");
            equal(bar.toString(), "@Named(value=bar)");
            check(foo.equals(foo));
            check(! foo.equals(bar));
        }
    }
}
 
Example 10
Project: openjdk-jdk10   File: ParameterAnnotations.java   View Source Code Vote up 5 votes
void test1() throws Throwable {
    for (Method m : thisClass.getMethods()) {
        if (m.getName().equals("nop")) {
            Annotation[][] ann = m.getParameterAnnotations();
            equal(ann.length, 2);
            Annotation foo = ann[0][0];
            Annotation bar = ann[1][0];
            equal(foo.toString(), "@Named(value=\"foo\")");
            equal(bar.toString(), "@Named(value=\"bar\")");
            check(foo.equals(foo));
            check(! foo.equals(bar));
        }
    }
}
 
Example 11
Project: Elasticsearch   File: FactoryProvider2.java   View Source Code Vote up 5 votes
/**
 * @param factoryType  a Java interface that defines one or more create methods.
 * @param producedType a concrete type that is assignable to the return types of all factory
 *                     methods.
 */
FactoryProvider2(TypeLiteral<F> factoryType, Key<?> producedType) {
    this.producedType = producedType;

    Errors errors = new Errors();

    @SuppressWarnings("unchecked") // we imprecisely treat the class literal of T as a Class<T>
            Class<F> factoryRawType = (Class) factoryType.getRawType();

    try {
        ImmutableMap.Builder<Method, Key<?>> returnTypesBuilder = ImmutableMap.builder();
        ImmutableMap.Builder<Method, List<Key<?>>> paramTypesBuilder
                = ImmutableMap.builder();
        // TODO: also grab methods from superinterfaces
        for (Method method : factoryRawType.getMethods()) {
            Key<?> returnType = getKey(
                    factoryType.getReturnType(method), method, method.getAnnotations(), errors);
            returnTypesBuilder.put(method, returnType);
            List<TypeLiteral<?>> params = factoryType.getParameterTypes(method);
            Annotation[][] paramAnnotations = method.getParameterAnnotations();
            int p = 0;
            List<Key<?>> keys = new ArrayList<>();
            for (TypeLiteral<?> param : params) {
                Key<?> paramKey = getKey(param, method, paramAnnotations[p++], errors);
                keys.add(assistKey(method, paramKey, errors));
            }
            paramTypesBuilder.put(method, Collections.unmodifiableList(keys));
        }
        returnTypesByMethod = returnTypesBuilder.build();
        paramTypes = paramTypesBuilder.build();
    } catch (ErrorsException e) {
        throw new ConfigurationException(e.getErrors().getMessages());
    }

    factory = factoryRawType.cast(Proxy.newProxyInstance(factoryRawType.getClassLoader(),
            new Class[]{factoryRawType}, this));
}
 
Example 12
Project: AlphaLibary   File: AnnotatedCommand.java   View Source Code Vote up 5 votes
<A extends Annotation> A getMethodParameterAnnotation(Method method, Class<A> clazz) {
    Annotation[][] annotations = method.getParameterAnnotations();
    for (Annotation[] annotationA : annotations) {
        for (Annotation annotation : annotationA) {
            if (clazz.isAssignableFrom(annotation.getClass())) {
                return (A) annotation;
            }
        }
    }
    return null;
}
 
Example 13
Project: drift   File: AbstractThriftMetadataBuilder.java   View Source Code Vote up 5 votes
protected final boolean hasThriftFieldAnnotation(Method method)
{
    for (Annotation[] parameterAnnotations : method.getParameterAnnotations()) {
        for (Annotation parameterAnnotation : parameterAnnotations) {
            if (parameterAnnotation instanceof ThriftField) {
                return true;
            }
        }
    }
    return false;
}
 
Example 14
Project: AlphaLibary   File: AnnotatedCommand.java   View Source Code Vote up 5 votes
<A extends Annotation> A getMethodParameterAnnotation(Method method, int index, Class<A> clazz) {
    Annotation[] annotations = method.getParameterAnnotations()[index];
    if (annotations != null) {
        for (Annotation annotation : annotations) {
            if (clazz.isAssignableFrom(annotation.getClass())) {
                return (A) annotation;
            }
        }
    }
    return null;
}
 
Example 15
Project: X4J   File: AnnotationParanamer.java   View Source Code Vote up 4 votes
public String[] lookupParameterNames(AccessibleObject methodOrCtor, boolean throwExceptionIfMissing) {
	// Oh for some commonality between Constructor and Method !!
	Class<?>[] types = null;
	Class<?> declaringClass = null;
	String name = null;
	Annotation[][] anns = null;
	if (methodOrCtor instanceof Method) {
		Method method = (Method) methodOrCtor;
		types = method.getParameterTypes();
		name = method.getName();
		declaringClass = method.getDeclaringClass();
		anns = method.getParameterAnnotations();
	} else {
		Constructor<?> constructor = (Constructor<?>) methodOrCtor;
		types = constructor.getParameterTypes();
		declaringClass = constructor.getDeclaringClass();
		name = "<init>";
		anns = constructor.getParameterAnnotations();
	}

	if (types.length == 0) {
		return EMPTY_NAMES;
	}

	final String[] names = new String[types.length];
	boolean allDone = true;
	for (int i = 0; i < names.length; i++) {
		for (int j = 0; j < anns[i].length; j++) {
			Annotation ann = anns[i][j];
			if (isNamed(ann)) {
				names[i] = getNamedValue(ann);
				break;
			}
		}
		if (names[i] == null) {
			allDone = false;
		}

	}

	// fill in blanks from fallback if possible.
	if (!allDone) {
		allDone = true;
		String[] altNames = fallback.lookupParameterNames(methodOrCtor, false);
		if (altNames.length > 0) {
			for (int i = 0; i < names.length; i++) {
				if (names[i] == null) {
					if (altNames[i] != null) {
						names[i] = altNames[i];
					} else {
						allDone = false;
					}
				}
			}
		} else {
			allDone = false;
		}
	}

	// error if applicable
	if (!allDone) {
		if (throwExceptionIfMissing) {
			throw new ParameterNamesNotFoundException("One or more @Named annotations missing for class '"
					+ declaringClass.getName() + "', methodOrCtor " + name + " and parameter types "
					+ DefaultParanamer.getParameterTypeNamesCSV(types));
		} else {
			return Paranamer.EMPTY_NAMES;
		}
	}
	return names;
}
 
Example 16
Project: dremio-oss   File: Doc.java   View Source Code Vote up 4 votes
public Resource(String parentPath, Method method) {
  this.pathPrefix = notNull(parentPath, "parentPath");
  this.httpMethod = notNull(getHttpMethod(method), "httpMethod");
  this.methodPath = method.getAnnotation(Path.class);
  this.returnType = getDataType(method.getGenericReturnType());
  Annotation[][] parameterAnnotations = method.getParameterAnnotations();
  Type[] paramTypes = method.getGenericParameterTypes();
  DataType bodyType = null;
  for (int i = 0; i < paramTypes.length; i++) {
    DataType type = getParamDataType(paramTypes[i]);
    Annotation[] paramAnnotations = parameterAnnotations[i];
    Param p = null;
    String defaultValue = null;
    for (Annotation paramAnnotation : paramAnnotations) {
      if (paramAnnotation instanceof QueryParam) {
        p = new Param(((QueryParam)paramAnnotation).value(), type);
        params.add(p);
      } else if (paramAnnotation instanceof PathParam) {
        p = new Param(((PathParam)paramAnnotation).value(), type);
        pathParams.add(p);
      } else if (paramAnnotation instanceof FormParam) {
        p = new Param(((FormParam)paramAnnotation).value(), type);
        formParams.add(p);
      } else if (paramAnnotation instanceof FormDataParam) {
        // TODO
        p = new Param(((FormDataParam)paramAnnotation).value(), type);
        formParams.add(p);
      } else if (paramAnnotation instanceof HeaderParam) {
        p = new Param(((HeaderParam)paramAnnotation).value(), type);
        headerParams.add(p);
      } else if (paramAnnotation instanceof DefaultValue) {
        defaultValue = ((DefaultValue)paramAnnotation).value();
      } else if (paramAnnotation instanceof Context) {
        // just an injected value. Not part of the api
        p = new Param(null, null);
      } else {
        System.err.println("[WARNING] Unknown param ann: " + paramAnnotation + " on " + i + "th param of " + method);
      }
    }
    if (p == null) {
      if (bodyType != null) {
        System.err.println("[WARNING] More than one body param on " + i + "th param of " + method);
      }
      if (defaultValue != null) {
        System.err.println("[WARNING] default value " + defaultValue + " for body on " + i + "th param of " + method);
      }
      bodyType = getDataType(paramTypes[i]);
    } else {
      p.setDefaultValue(defaultValue);
    }
  }
  this.body = bodyType;
}
 
Example 17
Project: openjdk-jdk10   File: MBeanOperationInfo.java   View Source Code Vote up 4 votes
private static MBeanParameterInfo[] methodSignature(Method method) {
    final Class<?>[] classes = method.getParameterTypes();
    final Annotation[][] annots = method.getParameterAnnotations();
    return parameters(classes, annots);
}
 
Example 18
Project: bubichain-sdk-java   File: HttpServiceAgent.java   View Source Code Vote up 4 votes
private ServiceActionContext resolveAction(ServiceEndpoint serviceEndpoint, Method mth, String servicePath){
    // 生成路径模板;
    HttpAction actionAnno = mth.getAnnotation(HttpAction.class);
    String actionPath = StringUtils.cleanPath(actionAnno.path());
    if (StringUtils.isEmpty(actionPath)) {
        actionPath = mth.getName();
    }
    RequestPathTemplate pathTemplate = new RequestPathTemplate(serviceEndpoint, servicePath, actionPath);

    // 校验请求你方法;
    if (actionAnno.method() == null) {
        throw new IllegalHttpServiceDefinitionException("The http method of action was not specified!");
    }

    RequestParamFilter reqParamFilter = createRequestParamFilter(actionAnno);
    ResponseConverter responseConverter = createResponseConverter(actionAnno, mth);

    // 获取参数定义;
    // 参数列表中, RequestBody 最多只能定义一个;
    RequestBodyResolver bodyResolver = null;
    Class<?>[] paramTypes = mth.getParameterTypes();
    Annotation[][] paramAnnos = mth.getParameterAnnotations();

    List<ArgDefEntry<RequestParam>> reqParamAnnos = new LinkedList<>();
    List<ArgDefEntry<RequestParamMap>> reqParamMapAnnos = new LinkedList<>();
    List<ArgDefEntry<PathParam>> pathParamAnnos = new LinkedList<>();
    for (int i = 0; i < paramTypes.length; i++) {
        RequestBody reqBodyAnno = findAnnotation(RequestBody.class, paramAnnos[i]);
        RequestParam reqParamAnno = findAnnotation(RequestParam.class, paramAnnos[i]);
        RequestParamMap reqParamsAnno = findAnnotation(RequestParamMap.class, paramAnnos[i]);
        PathParam pathParamAnno = findAnnotation(PathParam.class, paramAnnos[i]);
        if (hasConflictiveAnnotation(reqBodyAnno, reqParamAnno, reqParamsAnno, pathParamAnno)) {
            // 存在冲突的定义;
            throw new IllegalHttpServiceDefinitionException(
                    "The argument[" + i + "] of action has conflictive definition!");
        }
        if (bodyResolver != null && reqBodyAnno != null) {
            throw new IllegalHttpServiceDefinitionException("Define more than one request body for the action!");
        }
        if (reqBodyAnno != null) {
            bodyResolver = createBodyResolver(new ArgDefEntry<>(i, paramTypes[i], reqBodyAnno));
        }
        if (reqParamAnno != null) {
            reqParamAnnos.add(new ArgDefEntry<>(i, paramTypes[i], reqParamAnno));
        }
        if (reqParamsAnno != null) {
            reqParamMapAnnos.add(new ArgDefEntry<>(i, paramTypes[i], reqParamsAnno));
        }
        if (pathParamAnno != null) {
            pathParamAnnos.add(new ArgDefEntry<>(i, paramTypes[i], pathParamAnno));
        }
    }
    RequestParamResolver reqParamResolver = createRequestParamResolver(reqParamAnnos, reqParamMapAnnos);
    PathParamResolver pathParamResolver = createPathParamResolver(pathParamAnnos);
    if (bodyResolver == null) {
        bodyResolver = RequestBodyResolvers.NULL_BODY_RESOLVER;
    }

    // 获取声明的异常列表;
    Class<?>[] thrownExceptionTypes = mth.getExceptionTypes();

    ServiceActionContext actionContext = new ServiceActionContext(mth, actionAnno.method(), pathTemplate,
            pathParamResolver, reqParamFilter, reqParamResolver, bodyResolver, responseConverter,
            thrownExceptionTypes, actionAnno.resolveContentOnHttpError());
    return actionContext;
}
 
Example 19
Project: apache-tomcat-7.0.73-with-comment   File: PojoMethodMapping.java   View Source Code Vote up 4 votes
private static PojoPathParam[] getPathParams(Method m,
        MethodType methodType) throws DeploymentException {
    if (m == null) {
        return new PojoPathParam[0];
    }
    boolean foundThrowable = false;
    Class<?>[] types = m.getParameterTypes();
    Annotation[][] paramsAnnotations = m.getParameterAnnotations();
    PojoPathParam[] result = new PojoPathParam[types.length];
    for (int i = 0; i < types.length; i++) {
        Class<?> type = types[i];
        if (type.equals(Session.class)) {
            result[i] = new PojoPathParam(type, null);
        } else if (methodType == MethodType.ON_OPEN &&
                type.equals(EndpointConfig.class)) {
            result[i] = new PojoPathParam(type, null);
        } else if (methodType == MethodType.ON_ERROR
                && type.equals(Throwable.class)) {
            foundThrowable = true;
            result[i] = new PojoPathParam(type, null);
        } else if (methodType == MethodType.ON_CLOSE &&
                type.equals(CloseReason.class)) {
            result[i] = new PojoPathParam(type, null);
        } else {
            Annotation[] paramAnnotations = paramsAnnotations[i];
            for (Annotation paramAnnotation : paramAnnotations) {
                if (paramAnnotation.annotationType().equals(
                        PathParam.class)) {
                    // Check that the type is valid. "0" coerces to every
                    // valid type
                    try {
                        Util.coerceToType(type, "0");
                    } catch (IllegalArgumentException iae) {
                        throw new DeploymentException(sm.getString(
                                "pojoMethodMapping.invalidPathParamType"),
                                iae);
                    }
                    result[i] = new PojoPathParam(type,
                            ((PathParam) paramAnnotation).value());
                    break;
                }
            }
            // Parameters without annotations are not permitted
            if (result[i] == null) {
                throw new DeploymentException(sm.getString(
                        "pojoMethodMapping.paramWithoutAnnotation",
                        type, m.getName(), m.getClass().getName()));
            }
        }
    }
    if (methodType == MethodType.ON_ERROR && !foundThrowable) {
        throw new DeploymentException(sm.getString(
                "pojoMethodMapping.onErrorNoThrowable",
                m.getName(), m.getDeclaringClass().getName()));
    }
    return result;
}
 
Example 20
Project: Android-Code-Demos   File: RouterBus.java   View Source Code Vote up 4 votes
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    //获取方法上的注解
    RouterUri routerUri = method.getAnnotation(RouterUri.class);
    if (routerUri == null || TextUtils.isEmpty(routerUri.value())) {
        throw new IllegalArgumentException("没有注解的方法");
    }
    //获取注解value值
    String path = routerUri.value();
    Uri.Builder uriBuilder = Uri.parse(path).buildUpon();
    //获取参数注解值
    Annotation[][] annotationsParam = method.getParameterAnnotations();
    if (annotationsParam == null || annotationsParam.length == 0) {
        throw new IllegalArgumentException("参数上没有注解");
    }
    for (int i = 0; i < annotationsParam.length; i++) {
        Annotation[] annotations = annotationsParam[i];
        if (annotations == null || annotations.length == 0) {
            throw new IllegalArgumentException("method" + method.getName() + ", args at" + i + "lack of annotation");
        }

        boolean findAnnotation = false;
        for (Annotation a : annotations) {
            if (a != null && (a.annotationType()) == RouterParam.class) {
                String keyParam = ((RouterParam) a).value();
                uriBuilder.appendQueryParameter(keyParam, new Gson().toJson(args[i]));
                findAnnotation = true;

            }
        }
        if (!findAnnotation) {
            throw new IllegalArgumentException("method " + method.getName() + " args at " + i + ", lack of annotion");
        }

    }

    Uri uri = uriBuilder.build();
    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    //判断这个intent是不是有效的intent
    boolean isValid = checkIntent(intent);
    if (isValid) {
        return intent;
    } else {
        if (BuildConfig.DEBUG) {
            Toast.makeText(App.getContext(), "子模块作为独立程序启动时,跳不到其他模块哟", Toast.LENGTH_SHORT).show();
        } else {
            throw new IllegalStateException("can't resolve uri with" + uri.toString());
        }
    }
    return null;
}