當前位置: 首頁>>代碼示例>>Java>>正文


Java Method.getTypeParameters方法代碼示例

本文整理匯總了Java中java.lang.reflect.Method.getTypeParameters方法的典型用法代碼示例。如果您正苦於以下問題:Java Method.getTypeParameters方法的具體用法?Java Method.getTypeParameters怎麽用?Java Method.getTypeParameters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.lang.reflect.Method的用法示例。


在下文中一共展示了Method.getTypeParameters方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: visit

import java.lang.reflect.Method; //導入方法依賴的package包/類
private void visit(Class<?> type, Set<Class<?>> types) {
    if (type.isArray()) {
        visit(type.getComponentType(), types);
        return;
    }

    if (!type.isInterface() || !types.add(type) || stopAt.contains(type)) {
        return;
    }

    for (Type superType : type.getGenericInterfaces()) {
        visit(superType, types);
    }
    for (Method method : type.getDeclaredMethods()) {
        visit(method.getGenericReturnType(), types);
        for (TypeVariable<Method> typeVariable : method.getTypeParameters()) {
            visit(typeVariable, types);
        }
    }
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:21,代碼來源:TypeInspector.java

示例2: isValidMethod

import java.lang.reflect.Method; //導入方法依賴的package包/類
private static boolean isValidMethod(InjectableMethod injectableMethod,
    Errors errors) {
  boolean result = true;
  if (injectableMethod.jsr330) {
    Method method = injectableMethod.method;
    if (Modifier.isAbstract(method.getModifiers())) {
      errors.cannotInjectAbstractMethod(method);
      result = false;
    }
    if (method.getTypeParameters().length > 0) {
      errors.cannotInjectMethodWithTypeParameters(method);
      result = false;
    }
  }
  return result;
}
 
開發者ID:maetrive,項目名稱:businessworks,代碼行數:17,代碼來源:InjectionPoint.java

示例3: validateRuleMethod

import java.lang.reflect.Method; //導入方法依賴的package包/類
private void validateRuleMethod(MethodRuleDefinition<?, ?> ruleDefinition, Method ruleMethod, RuleSourceValidationProblemCollector problems) {
    if (Modifier.isPrivate(ruleMethod.getModifiers())) {
        problems.add(ruleMethod, "A rule method cannot be private");
    }
    if (Modifier.isAbstract(ruleMethod.getModifiers())) {
        problems.add(ruleMethod, "A rule method cannot be abstract");
    }

    if (ruleMethod.getTypeParameters().length > 0) {
        problems.add(ruleMethod, "Cannot have type variables (i.e. cannot be a generic method)");
    }

    // TODO validations on method: synthetic, bridge methods, varargs, abstract, native
    ModelType<?> returnType = ModelType.returnType(ruleMethod);
    if (returnType.isRawClassOfParameterizedType()) {
        problems.add(ruleMethod, "Raw type " + returnType + " used for return type (all type parameters must be specified of parameterized type)");
    }

    for (int i = 0; i < ruleDefinition.getReferences().size(); i++) {
        ModelReference<?> reference = ruleDefinition.getReferences().get(i);
        if (reference.getType().isRawClassOfParameterizedType()) {
            problems.add(ruleMethod, "Raw type " + reference.getType() + " used for parameter " + (i + 1) + " (all type parameters must be specified of parameterized type)");
        }
        if (reference.getPath() != null) {
            try {
                ModelPath.validatePath(reference.getPath().getPath());
            } catch (Exception e) {
                problems.add(ruleDefinition, "The declared model element path '" + reference.getPath().getPath() + "' used for parameter " + (i + 1) + " is not a valid path", e);
            }
        }
    }
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:33,代碼來源:ModelRuleExtractor.java

示例4: MethodSignature

import java.lang.reflect.Method; //導入方法依賴的package包/類
MethodSignature(Method method) {
  name = method.getName();
  parameterTypes = Arrays.asList(method.getParameterTypes());
  typeSignature = new TypeSignature(method.getTypeParameters());
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:6,代碼來源:FauxveridesTest.java


注:本文中的java.lang.reflect.Method.getTypeParameters方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。