当前位置: 首页>>代码示例>>Java>>正文


Java ClassOrInterfaceType类代码示例

本文整理汇总了Java中com.github.javaparser.ast.type.ClassOrInterfaceType的典型用法代码示例。如果您正苦于以下问题:Java ClassOrInterfaceType类的具体用法?Java ClassOrInterfaceType怎么用?Java ClassOrInterfaceType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ClassOrInterfaceType类属于com.github.javaparser.ast.type包,在下文中一共展示了ClassOrInterfaceType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTypeName

import com.github.javaparser.ast.type.ClassOrInterfaceType; //导入依赖的package包/类
@Override
protected String getTypeName(CompilationUnit compilationUnit, int index) {
    ClassOrInterfaceDeclaration type = (ClassOrInterfaceDeclaration) compilationUnit.getType(0);
    NodeList<ClassOrInterfaceType> extendedTypes = type.getExtendedTypes();
    ClassOrInterfaceType extendedType = extendedTypes.get(index);
    String typeSimpleName = extendedType.getName().getIdentifier();
    Optional<ClassOrInterfaceType> scope = extendedType.getScope();
    String typeName;
    if (scope.isPresent()) {
        String typePackageName = scope.get().toString();
        typeName = String.format("%s.%s", typePackageName, typeSimpleName);
    } else {
        typeName = typeSimpleName;
    }
    return typeName;
}
 
开发者ID:paypal,项目名称:butterfly,代码行数:17,代码来源:Extends.java

示例2: typeOf

import com.github.javaparser.ast.type.ClassOrInterfaceType; //导入依赖的package包/类
@Nullable
Class<?> typeOf( Type type ) {
    if ( type instanceof ReferenceType ) {
        ReferenceType referenceType = ( ReferenceType ) type;
        if ( referenceType.getArrayCount() > 0 ) {
            return Array.class;
        }
        // unwrap the reference type and try again
        return typeOf( referenceType.getType() );
    }

    if ( type instanceof PrimitiveType ) {
        String typeName = ( ( PrimitiveType ) type ).getType().name();
        return primitiveType( typeName );
    } else if ( type instanceof ClassOrInterfaceType ) try {
        return classForName( ( ( ClassOrInterfaceType ) type ).getName() );
    } catch ( ClassNotFoundException e ) {
        // class not found, ignore
    }

    return null;
}
 
开发者ID:renatoathaydes,项目名称:osgiaas,代码行数:23,代码来源:TypeDiscoverer.java

示例3: calculate

import com.github.javaparser.ast.type.ClassOrInterfaceType; //导入依赖的package包/类
public void calculate(ClassOrInterfaceDeclaration classOrInterfaceDeclaration, CompilationUnit compilationUnit) {
    List<ClassOrInterfaceType> implementedInterfaces = classOrInterfaceDeclaration.getImplementedTypes();
    for (ClassOrInterfaceType implementedInterface : implementedInterfaces) {
        String implementedInterfaceName = implementedInterface.getNameAsString();
        String implementedInterfacePackageName = implementedInterface
                .findCompilationUnit()
                .flatMap(CompilationUnit::getPackageDeclaration)
                .flatMap(pkg -> Optional.of(pkg.getNameAsString())).orElse("???");
        if (typeDao.exist(implementedInterfaceName, implementedInterfacePackageName)) { // JDK interfaces are not indexed
            int interfaceId = typeDao.getId(implementedInterfaceName, implementedInterfacePackageName);
            String cuPackageName = compilationUnit.getPackageDeclaration().get().getNameAsString();
            int nbClasses = typeDao.count(classOrInterfaceDeclaration.getNameAsString(), cuPackageName);
            if (nbClasses > 1) {
                System.err.println("More than one class having the same name '" + classOrInterfaceDeclaration.getName() + "' and package '" + cuPackageName + "'");
            } else {
                int classId = typeDao.getId(classOrInterfaceDeclaration.getNameAsString(), cuPackageName);
                implementsDao.save(new Implements(classId, interfaceId));
            }
        }
    }
}
 
开发者ID:benas,项目名称:jql,代码行数:22,代码来源:ImplementsRelationCalculator.java

示例4: calculate

import com.github.javaparser.ast.type.ClassOrInterfaceType; //导入依赖的package包/类
public void calculate(ClassOrInterfaceDeclaration classOrInterfaceDeclaration, CompilationUnit compilationUnit) {
    List<ClassOrInterfaceType> extendedTypes = classOrInterfaceDeclaration.getExtendedTypes();
    for (ClassOrInterfaceType extendedType : extendedTypes) {
        String extendedTypeName = extendedType.getNameAsString();
        String extendedTypePackageName = extendedType
                .findCompilationUnit()
                .flatMap(CompilationUnit::getPackageDeclaration)
                .flatMap(pkg -> Optional.of(pkg.getNameAsString())).orElse("???");

        if (typeDao.exist(extendedTypeName, extendedTypePackageName)) { // JDK interfaces are not indexed
            int extendedInterfaceId = typeDao.getId(extendedTypeName, extendedTypePackageName);
            int interfaceId = typeDao.getId(classOrInterfaceDeclaration.getNameAsString(), compilationUnit.getPackageDeclaration().get().getNameAsString());
            extendsDao.save(new Extends(interfaceId, extendedInterfaceId));
        }
    }
}
 
开发者ID:benas,项目名称:jql,代码行数:17,代码来源:ExtendsRelationCalculator.java

示例5: generateFakeRelation

import com.github.javaparser.ast.type.ClassOrInterfaceType; //导入依赖的package包/类
private void generateFakeRelation(String fk) throws Exception {
	DbTable parent = g().findTableByNames(null, fk);
	if(null == parent) {
		g().error(this + ": user specified FK specifies unknown table '" + fk + "'");
		return;
	}

	ClassWrapper parentClass = g().findClassByTable(parent);
	if(null == parentClass) {
		g().error("Cannot locate class source file for " + parent + ", mapping as non-relation");
		calculateBasicType();
		return;
	}

	ClassOrInterfaceType referent = new ClassOrInterfaceType(parentClass.getClassName());
	setPropertyType(referent);
	setManyToOne(parentClass);
}
 
开发者ID:fjalvingh,项目名称:domui,代码行数:19,代码来源:ColumnWrapper.java

示例6: resolveManyToOne

import com.github.javaparser.ast.type.ClassOrInterfaceType; //导入依赖的package包/类
public void resolveManyToOne() {
	if(getRelationType() != RelationType.manyToOne)
		return;

	ClassOrInterfaceType ct = (ClassOrInterfaceType) getPropertyType();
	String parentClassName = ct.getName().asString();
	parentClassName = m_classWrapper.tryResolveFullName(parentClassName);

	ClassWrapper parentClass = g().findClassWrapper(m_classWrapper.getPackageName(), parentClassName);
	if(null == parentClass) {
		m_classWrapper.error(this + ": cannot locate class " + parentClassName + " inside parsed entities");
		return;
	} else {
		m_parentClass = parentClass;
	}
}
 
开发者ID:fjalvingh,项目名称:domui,代码行数:17,代码来源:ColumnWrapper.java

示例7: changePropertyType

import com.github.javaparser.ast.type.ClassOrInterfaceType; //导入依赖的package包/类
public void changePropertyType(ClassOrInterfaceType newType) {
	VariableDeclarator vd = getVariableDeclaration();
	if(null != vd) {
		vd.setType(newType);
	}

	MethodDeclaration getter = getGetter();
	if(null != getter) {
		getter.setType(newType);
	}

	MethodDeclaration setter = getSetter();
	if(null != setter) {
		setter.getParameter(0).setType(newType);
	}
	m_propertyType = newType;
}
 
开发者ID:fjalvingh,项目名称:domui,代码行数:18,代码来源:ColumnWrapper.java

示例8: visit

import com.github.javaparser.ast.type.ClassOrInterfaceType; //导入依赖的package包/类
@Override
public final void visit(ClassOrInterfaceType ctx, Object arg) {

    if (!componentStack.isEmpty()) {
        final Component currCmp = componentStack.peek();
        currCmp.insertComponentInvocation(new TypeDeclaration(resolveType(ctx.asClassOrInterfaceType().getNameAsString())));
        List<Type> typeArguments = new ArrayList<>();
        if (ctx.getTypeArguments().isPresent()) {
            typeArguments.addAll(ctx.getTypeArguments().get());
            for (Type typeArg : typeArguments) {
                if (typeArg.isClassOrInterfaceType()) {
                    if (((ClassOrInterfaceType) typeArg).getTypeArguments().isPresent()) {
                        visit(((ClassOrInterfaceType) typeArg), arg);
                    } else {
                        currCmp.insertComponentInvocation(new TypeDeclaration(resolveType(typeArg.asClassOrInterfaceType().getNameAsString())));
                    }
                } else {
                    currCmp.insertComponentInvocation(new TypeDeclaration(resolveType(typeArg.asString())));
                }
            }
        }
    }
}
 
开发者ID:Zir0-93,项目名称:clarpse,代码行数:24,代码来源:JavaTreeListener.java

示例9: visit

import com.github.javaparser.ast.type.ClassOrInterfaceType; //导入依赖的package包/类
@Override
public void visit(final ClassOrInterfaceType n, final Object arg) {
    printer.printLn("ClassOrInterfaceType");
    printJavaComment(n.getComment(), arg);

    if (n.getAnnotations() != null) {
        for (AnnotationExpr ae : n.getAnnotations()) {
            ae.accept(this, arg);
            printer.print(" ");
        }
    }

    if (n.getScope() != null) {
        n.getScope().accept(this, arg);
        printer.print(".");
    }
    printer.print(n.getName());
    printTypeArgs(n.getTypeArgs(), arg);
}
 
开发者ID:pcgomes,项目名称:javaparser2jctree,代码行数:20,代码来源:ASTDumpVisitor.java

示例10: doIsEquals

import com.github.javaparser.ast.type.ClassOrInterfaceType; //导入依赖的package包/类
@Override
public boolean doIsEquals(TypeParameter first, TypeParameter second) {

    if(!StringUtils.equals(first.getName(),second.getName())) return false;

    List<ClassOrInterfaceType> firstTypeBounds = first.getTypeBound();
    List<ClassOrInterfaceType> secondTypeBounds = second.getTypeBound();

    if(firstTypeBounds == null) return secondTypeBounds == null;
    if(secondTypeBounds == null) return false;

    if(firstTypeBounds.size() != secondTypeBounds.size()) return false;

    AbstractMerger<ClassOrInterfaceType> merger = getMerger(ClassOrInterfaceType.class);

    for(int i = 0; i < firstTypeBounds.size(); i++){
        if(!merger.isEquals(firstTypeBounds.get(i),secondTypeBounds.get(i))){
            return false;
        }
    }

    return true;
}
 
开发者ID:beihaifeiwu,项目名称:dolphin,代码行数:24,代码来源:TypeParameterMerger.java

示例11: apply

import com.github.javaparser.ast.type.ClassOrInterfaceType; //导入依赖的package包/类
public TypeRef apply(Type type) {
    if (type instanceof VoidType) {
        return new VoidRef();
    } else if (type instanceof WildcardType) {
        return new WildcardRef();
    } else if (type instanceof ReferenceType) {
        ReferenceType referenceType = (ReferenceType) type;
        int dimensions = referenceType.getArrayCount();
        TypeRef typeRef = TYPEREF.apply(referenceType.getType());
        if (dimensions == 0) {
            return typeRef;
        } else if (typeRef instanceof ClassRef) {
            return new ClassRefBuilder((ClassRef)typeRef).withDimensions(dimensions).build();
        } else if (typeRef instanceof PrimitiveRef) {
            return new PrimitiveRefBuilder((PrimitiveRef)typeRef).withDimensions(dimensions).build();
        } else if (typeRef instanceof TypeParamRef) {
            return new TypeParamRefBuilder((TypeParamRef)typeRef).withDimensions(dimensions).build();
        }
    } else if (type instanceof PrimitiveType) {
        PrimitiveType primitiveType = (PrimitiveType) type;
        return new PrimitiveRefBuilder().withName(primitiveType.getType().name()).build();
    } else if (type instanceof ClassOrInterfaceType) {
        return CLASS_OR_TYPEPARAM_REF.apply((ClassOrInterfaceType) type);
    }
    throw new IllegalArgumentException("Can't handle type:[" + type + "].");
}
 
开发者ID:sundrio,项目名称:sundrio,代码行数:27,代码来源:Sources.java

示例12: replaceType

import com.github.javaparser.ast.type.ClassOrInterfaceType; //导入依赖的package包/类
private String replaceType(String typeString, Node type, Map<String, String> scanedNames, Set<String> scanedImputs,
							Map<String, Pattern> scanedRefeWrap) {
	//!!!!!String ,Object ,Integer
	if (!commonsTypes.contains(typeString)) {
		String result;
		if (hasLength(result = hasScanedTypeName(typeString, scanedNames, scanedImputs))) {
			Utils.InvokedMethod(type, "setType", new ClassOrInterfaceType(java_lang_Object));
			return result;
		}
		else {
			String theScanName = containsInPattern(scanedRefeWrap, typeString);
			if (Utils.hasLength(theScanName)) {
				StringBuilder sb = new StringBuilder(100);
				Utils.replaceWholeWord(sb, 0, typeString, theScanName, java_lang_Object);
				Utils.InvokedMethod(type, "setType", new ClassOrInterfaceType(sb.toString()));
			}
		}
	}
	return null;
}
 
开发者ID:niaoge,项目名称:spring-dynamic,代码行数:21,代码来源:SourceScaner.java

示例13: getAncestors

import com.github.javaparser.ast.type.ClassOrInterfaceType; //导入依赖的package包/类
@Override
public List<ResolvedReferenceType> getAncestors() {
    List<ResolvedReferenceType> ancestors = new ArrayList<>();
    ResolvedReferenceType enumClass = ReflectionFactory.typeUsageFor(Enum.class, typeSolver).asReferenceType();
    ResolvedTypeParameterDeclaration eTypeParameter = enumClass.getTypeDeclaration().getTypeParameters().get(0);
    enumClass = enumClass.deriveTypeParameters(new ResolvedTypeParametersMap.Builder().setValue(eTypeParameter, new ReferenceTypeImpl(this, typeSolver)).build());
    ancestors.add(enumClass);
    if (wrappedNode.getImplementedTypes() != null) {
        for (ClassOrInterfaceType implementedType : wrappedNode.getImplementedTypes()) {
            SymbolReference<ResolvedTypeDeclaration> implementedDeclRef = new SymbolSolver(typeSolver).solveTypeInType(this, implementedType.getName().getId());
            if (!implementedDeclRef.isSolved()) {
                throw new UnsolvedSymbolException(implementedType.getName().getId());
            }
            ancestors.add(new ReferenceTypeImpl((ResolvedReferenceTypeDeclaration) implementedDeclRef.getCorrespondingDeclaration(), typeSolver));
        }
    }
    return ancestors;
}
 
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:19,代码来源:JavaParserEnumDeclaration.java

示例14: getResolvedName

import com.github.javaparser.ast.type.ClassOrInterfaceType; //导入依赖的package包/类
public static ClassOrInterfaceType getResolvedName(final JavaType target,
        final JavaType current, final com.github.javaparser.ast.CompilationUnit compilationUnit) {
    final NameExpr nameExpr = JavaParserUtils.importTypeIfRequired(target,
            compilationUnit.getImports(), current);
    final ClassOrInterfaceType resolvedName = JavaParserUtils
            .getClassOrInterfaceType(nameExpr);
    if (current.getParameters() != null
            && current.getParameters().size() > 0) {
        resolvedName.setTypeArgs(new ArrayList<Type>());
        for (final JavaType param : current.getParameters()) {
            resolvedName.getTypeArgs().add(
                    getResolvedName(target, param, compilationUnit));
        }
    }

    return resolvedName;
}
 
开发者ID:BenDol,项目名称:Databind,代码行数:18,代码来源:JavaParserUtils.java

示例15: importParametersForType

import com.github.javaparser.ast.type.ClassOrInterfaceType; //导入依赖的package包/类
public static ReferenceType importParametersForType(
        final JavaType targetType, final List<ImportDeclaration> imports,
        final JavaType typeToImport) {
    Validate.notNull(targetType, "Target type is required");
    Validate.notNull(imports, "Compilation unit imports required");
    Validate.notNull(typeToImport, "Java type to import is required");

    final ClassOrInterfaceType cit = getClassOrInterfaceType(importTypeIfRequired(
            targetType, imports, typeToImport));
    
    // Add any type arguments presented for the return type
    if (typeToImport.getParameters().size() > 0) {
        final List<Type> typeArgs = new ArrayList<Type>();
        cit.setTypeArgs(typeArgs);
        for (final JavaType parameter : typeToImport
                .getParameters()) {
            typeArgs.add(JavaParserUtils.importParametersForType(
                    targetType,
                    imports, parameter));
        }
    }
    return  new ReferenceType(cit);
}
 
开发者ID:BenDol,项目名称:Databind,代码行数:24,代码来源:JavaParserUtils.java


注:本文中的com.github.javaparser.ast.type.ClassOrInterfaceType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。