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


Java ClassOrInterfaceDeclaration.getTypeParameters方法代碼示例

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


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

示例1: visit

import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; //導入方法依賴的package包/類
@Override public Node visit(final ClassOrInterfaceDeclaration n, final A arg) {
	visitAnnotations(n, arg);
	visitComment(n, arg);
	final List<TypeParameter> typeParameters = n.getTypeParameters();
	if (typeParameters != null) {
		for (int i = 0; i < typeParameters.size(); i++) {
			typeParameters.set(i, (TypeParameter) typeParameters.get(i).accept(this, arg));
		}
		removeNulls(typeParameters);
	}
	final List<ClassOrInterfaceType> extendz = n.getExtends();
	if (extendz != null) {
		for (int i = 0; i < extendz.size(); i++) {
			extendz.set(i, (ClassOrInterfaceType) extendz.get(i).accept(this, arg));
		}
		removeNulls(extendz);
	}
	final List<ClassOrInterfaceType> implementz = n.getImplements();
	if (implementz != null) {
		for (int i = 0; i < implementz.size(); i++) {
			implementz.set(i, (ClassOrInterfaceType) implementz.get(i).accept(this, arg));
		}
		removeNulls(implementz);
	}
       final List<BodyDeclaration<?>> members = n.getMembers();
	if (members != null) {
		for (int i = 0; i < members.size(); i++) {
               members.set(i, (BodyDeclaration<?>) members.get(i).accept(this, arg));
		}
		removeNulls(members);
	}
	return n;
}
 
開發者ID:javaparser,項目名稱:javasymbolsolver,代碼行數:34,代碼來源:ModifierVisitorAdapter.java

示例2: visit

import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; //導入方法依賴的package包/類
@Override public Node visit(final ClassOrInterfaceDeclaration n, final A arg) {
	if (n.getJavaDoc() != null) {
		n.setJavaDoc((JavadocComment) n.getJavaDoc().accept(this, arg));
	}
	final List<AnnotationExpr> annotations = n.getAnnotations();
	if (annotations != null) {
		for (int i = 0; i < annotations.size(); i++) {
			annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg));
		}
		removeNulls(annotations);
	}
	final List<TypeParameter> typeParameters = n.getTypeParameters();
	if (typeParameters != null) {
		for (int i = 0; i < typeParameters.size(); i++) {
			typeParameters.set(i, (TypeParameter) typeParameters.get(i).accept(this, arg));
		}
		removeNulls(typeParameters);
	}
	final List<ClassOrInterfaceType> extendz = n.getExtends();
	if (extendz != null) {
		for (int i = 0; i < extendz.size(); i++) {
			extendz.set(i, (ClassOrInterfaceType) extendz.get(i).accept(this, arg));
		}
		removeNulls(extendz);
	}
	final List<ClassOrInterfaceType> implementz = n.getImplements();
	if (implementz != null) {
		for (int i = 0; i < implementz.size(); i++) {
			implementz.set(i, (ClassOrInterfaceType) implementz.get(i).accept(this, arg));
		}
		removeNulls(implementz);
	}
	final List<BodyDeclaration> members = n.getMembers();
	if (members != null) {
		for (int i = 0; i < members.size(); i++) {
			members.set(i, (BodyDeclaration) members.get(i).accept(this, arg));
		}
		removeNulls(members);
	}
	return n;
}
 
開發者ID:plum-umd,項目名稱:java-sketch,代碼行數:42,代碼來源:ModifierVisitorAdapter.java

示例3: getJavaType

import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; //導入方法依賴的package包/類
/**
 * Resolves the effective {@link JavaType} a
 * {@link ClassOrInterfaceDeclaration} represents, including any type
 * parameters.
 * 
 * @param compilationUnitService for package management (required)
 * @param typeDeclaration the type declaration to resolve (required)
 * @return the effective Java type (never null)
 */
public static JavaType getJavaType(
        final CompilationUnitService compilationUnitService,
        final TypeDeclaration typeDeclaration) {
    Validate.notNull(compilationUnitService,
            "Compilation unit services required");
    Validate.notNull(typeDeclaration, "Type declaration required");

    // Convert the ClassOrInterfaceDeclaration name into a JavaType
    final NameExpr nameExpr = getNameExpr(typeDeclaration.getName());
    final JavaType effectiveType = getJavaType(compilationUnitService,
            nameExpr, null);

    final List<JavaType> parameterTypes = new ArrayList<JavaType>();
    if (typeDeclaration instanceof ClassOrInterfaceDeclaration) {
        final ClassOrInterfaceDeclaration clazz = (ClassOrInterfaceDeclaration) typeDeclaration;
        // Populate JavaType with type parameters
        final List<TypeParameter> typeParameters = clazz
                .getTypeParameters();
        if (typeParameters != null) {
            final Set<JavaSymbolName> locatedTypeParameters = new HashSet<JavaSymbolName>();
            for (final TypeParameter candidate : typeParameters) {
                final JavaSymbolName currentTypeParam = new JavaSymbolName(
                        candidate.getName());
                locatedTypeParameters.add(currentTypeParam);
                JavaType javaType = null;
                if (candidate.getTypeBound() == null) {
                    javaType = new JavaType(
                        JavaType.OBJECT.getFullyQualifiedTypeName(), 0,
                            DataType.TYPE, currentTypeParam, null);
                }
                else {
                    final ClassOrInterfaceType cit = candidate
                            .getTypeBound().get(0);
                    javaType = JavaParserUtils.getJavaTypeNow(
                        compilationUnitService, cit,
                            locatedTypeParameters);
                    javaType = new JavaType(
                            javaType.getFullyQualifiedTypeName(),
                            javaType.getArray(), javaType.getDataType(),
                            currentTypeParam, javaType.getParameters());
                }
                parameterTypes.add(javaType);
            }
        }
    }

    return new JavaType(effectiveType.getFullyQualifiedTypeName(),
            effectiveType.getArray(), effectiveType.getDataType(), null,
            parameterTypes);
}
 
開發者ID:BenDol,項目名稱:Databind,代碼行數:60,代碼來源:JavaParserUtils.java


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