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


Java TypeDeclaration.getName方法代码示例

本文整理汇总了Java中japa.parser.ast.body.TypeDeclaration.getName方法的典型用法代码示例。如果您正苦于以下问题:Java TypeDeclaration.getName方法的具体用法?Java TypeDeclaration.getName怎么用?Java TypeDeclaration.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在japa.parser.ast.body.TypeDeclaration的用法示例。


在下文中一共展示了TypeDeclaration.getName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolve

import japa.parser.ast.body.TypeDeclaration; //导入方法依赖的package包/类
@Override
public NodeData resolve(Node node, String mappedClass) {
    if (!(node instanceof ClassOrInterfaceDeclaration)) {
        throw new IllegalArgumentException("this annotation belongs only on ClassOrInterfaceDeclaration");
    }

    final TypeDeclaration dclr = (TypeDeclaration) node;
    if (!(dclr.getParentNode() instanceof CompilationUnit)) {
        //handling nested classes
        return null;
    }
    final String name = dclr.getName();

    final Collection<FieldDescriptor> primaryKeyDescriptors = getPrimaryKeyDescriptors(mappedClass);

    if (primaryKeyDescriptors != null && primaryKeyDescriptors.size() > 1  && nodeContainsPkFields(dclr,
            primaryKeyDescriptors)) {
        final NodeAndImports<ClassOrInterfaceDeclaration> primaryKeyClass = createPrimaryKeyClass(name, primaryKeyDescriptors);
        final String pkClassName = primaryKeyClass.node.getName();
        return new NodeData(new SingleMemberAnnotationExpr(new NameExpr(SIMPLE_NAME), new NameExpr(name + "." + pkClassName + ".class")),
                new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false), primaryKeyClass.imprts, primaryKeyClass.node);

    }
    return null;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:26,代码来源:IdClassResolver.java

示例2: resolve

import japa.parser.ast.body.TypeDeclaration; //导入方法依赖的package包/类
@Override
public NodeData resolve(Node node, String mappedClass) {
    if (!(node instanceof ClassOrInterfaceDeclaration)) {
        throw new IllegalArgumentException("this annotation belongs only on ClassOrInterfaceDeclaration");
    }

    final TypeDeclaration dclr = (TypeDeclaration) node;
    if (!(dclr.getParentNode() instanceof CompilationUnit)) {
        //handling nested classes
        return null;
    }

    final String name = dclr.getName();
    final String pckg = ((CompilationUnit) dclr.getParentNode()).getPackage().getName().toString();
    final String enclosingClass = pckg + "." + name;

    final ClassDescriptor cd = OjbUtil.findClassDescriptor(enclosingClass, descriptorRepositories);
    if (cd != null) {
        return new NodeData(new MarkerAnnotationExpr(new NameExpr(SIMPLE_NAME)),
                new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
    }

    return null;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:25,代码来源:EntityResolver.java

示例3: resolve

import japa.parser.ast.body.TypeDeclaration; //导入方法依赖的package包/类
@Override
public final NodeData resolve(Node node, String mappedClass) {
    if (!(node instanceof FieldDeclaration)) {
        throw new IllegalArgumentException("this annotation belongs only on FieldDeclaration");
    }

    final FieldDeclaration field = (FieldDeclaration) node;

    if (ResolverUtil.canFieldBeAnnotated(field)) {
        final TypeDeclaration dclr = (TypeDeclaration) node.getParentNode();

        final String name = dclr.getName();
        final String pckg = ((CompilationUnit) dclr.getParentNode()).getPackage().getName().toString();
        final String fullyQualifiedClass = pckg + "." + name;
        final boolean mappedColumn = OjbUtil.isMappedColumn(mappedClass, ParserUtil.getFieldName(field),
                descriptorRepositories);
        if (mappedColumn) {
            return getAnnotationNodes(fullyQualifiedClass, ParserUtil.getFieldName(field), mappedClass);
        }
    }
    return null;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:23,代码来源:AbstractMappedFieldResolver.java

示例4: resolve

import japa.parser.ast.body.TypeDeclaration; //导入方法依赖的package包/类
@Override
public NodeData resolve(Node node, String mappedClass) {
    if (!(node instanceof ClassOrInterfaceDeclaration)) {
        throw new IllegalArgumentException("this annotation belongs only on ClassOrInterfaceDeclaration");
    }

    final TypeDeclaration dclr = (TypeDeclaration) node;
    if (!(dclr.getParentNode() instanceof CompilationUnit)) {
        //handling nested classes
        return null;
    }

    final String name = dclr.getName();
    final String pckg = ((CompilationUnit) dclr.getParentNode()).getPackage().getName().toString();
    final String enclosingClass = pckg + "." + name;
    if (!enclosingClass.equals(mappedClass)) {
        return new NodeData(new MarkerAnnotationExpr(new NameExpr(SIMPLE_NAME)),
            new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
    }
    return null;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:22,代码来源:MappedSuperClassResolver.java

示例5: resolve

import japa.parser.ast.body.TypeDeclaration; //导入方法依赖的package包/类
@Override
public NodeData resolve(Node node, String mappedClass) {
    if (!(node instanceof ClassOrInterfaceDeclaration)) {
        throw new IllegalArgumentException("this annotation belongs only on ClassOrInterfaceDeclaration");
    }

    final TypeDeclaration dclr = (TypeDeclaration) node;
    if (!(dclr.getParentNode() instanceof CompilationUnit)) {
        //handling nested classes
        return null;
    }
    final String name = dclr.getName();
    final String pckg = ((CompilationUnit) dclr.getParentNode()).getPackage().getName().toString();
    final String enclosingClass = pckg + "." + name;
    final Collection<String> customizedFieldsOnNode = getFieldsOnNode(dclr, getCustomizedFields(mappedClass));
    if (customizedFieldsOnNode == null || customizedFieldsOnNode.isEmpty()) {
        LOG.info(ResolverUtil.logMsgForClass(enclosingClass, mappedClass) + " has no customized fields");
        return null;
    }
    return new NodeData(new SingleMemberAnnotationExpr(new NameExpr(SIMPLE_NAME), new NameExpr("CreateCustomizerFor" + customizedFieldsOnNode.toString())),
            new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:23,代码来源:CustomizerResolver.java

示例6: getTypeOrFieldNameForMsg

import japa.parser.ast.body.TypeDeclaration; //导入方法依赖的package包/类
private String getTypeOrFieldNameForMsg(final BodyDeclaration n) {
    if (n instanceof TypeDeclaration) {
        return ((TypeDeclaration) n).getName();
    } else if (n instanceof FieldDeclaration) {
        final FieldDeclaration fd = (FieldDeclaration) n;
        //this wont work for nested classes but we should be in nexted classes at this point
        final CompilationUnit unit = getCompilationUnit(n);
        final TypeDeclaration parent = unit.getTypes().get(0);
        Collection<String> variableNames = new ArrayList<String>();
        if (fd.getVariables() != null) {
            for (VariableDeclarator vd : fd.getVariables()) {
                variableNames.add(vd.getId().getName());
            }
        }
        return variableNames.size() == 1 ?
                parent.getName() + "." + variableNames.iterator().next() :
                parent.getName() + "." + variableNames.toString();

    }
    return null;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:22,代码来源:AnnotationHelper.java

示例7: Declaration

import japa.parser.ast.body.TypeDeclaration; //导入方法依赖的package包/类
public Declaration(TypeDeclaration decl) {
    className = decl.getName();
    methods = new ArrayList<String>();
    attributes = new HashSet<String>();
    processAnnotations(decl);
    for (BodyDeclaration method : decl.getMembers()) {
        processAnnotations(method);
        if (method instanceof MethodDeclaration)
            methods.add(((MethodDeclaration)method).getName());
    }
}
 
开发者ID:amritbhat786,项目名称:DocIT,代码行数:12,代码来源:Fact.java

示例8: getJavaType

import japa.parser.ast.body.TypeDeclaration; //导入方法依赖的package包/类
public final JavaType getJavaType(final String fileIdentifier) {
    Validate.notBlank(fileIdentifier, "Compilation unit path required");
    Validate.isTrue(new File(fileIdentifier).exists(),
            "The file doesn't exist");
    Validate.isTrue(new File(fileIdentifier).isFile(),
            "The identifier doesn't represent a file");
    try {
        final File file = new File(fileIdentifier);
        String typeContents = "";
        try {
            typeContents = FileUtils.readFileToString(file);
        }
        catch (IOException ignored) {
        }
        if (StringUtils.isBlank(typeContents)) {
            return null;
        }
        final CompilationUnit compilationUnit = JavaParser
                .parse(new ByteArrayInputStream(typeContents.getBytes()));
        final String typeName = fileIdentifier.substring(
                fileIdentifier.lastIndexOf(File.separator) + 1,
                fileIdentifier.lastIndexOf("."));
        for (final TypeDeclaration typeDeclaration : compilationUnit
                .getTypes()) {
            if (typeName.equals(typeDeclaration.getName())) {
                return new JavaType(compilationUnit.getPackage().getName()
                        .getName()
                        + "." + typeDeclaration.getName());
            }
        }
        return null;
    }
    catch (final ParseException e) {
        throw new IllegalStateException("Failed to parse " + fileIdentifier
                + " : " + e.getMessage());
    }
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:38,代码来源:JavaParserTypeResolutionService.java

示例9: resolve

import japa.parser.ast.body.TypeDeclaration; //导入方法依赖的package包/类
@Override
public NodeData resolve(Node node, String mappedClass) {
    if (!(node instanceof ClassOrInterfaceDeclaration)) {
        throw new IllegalArgumentException("this annotation belongs only on ClassOrInterfaceDeclaration");
    }

    final TypeDeclaration dclr = (TypeDeclaration) node;
    if (!(dclr.getParentNode() instanceof CompilationUnit)) {
        //handling nested classes
        return null;
    }
    final String name = dclr.getName();
    final String pckg = ((CompilationUnit) dclr.getParentNode()).getPackage().getName().toString();
    final String enclosingClass = pckg + "." + name;

    final ClassDescriptor cd = OjbUtil.findClassDescriptor(enclosingClass, descriptorRepositories);
    if (cd != null) {
        final String tableName = getMappedTable(enclosingClass);
        if (tableName == null) {
            LOG.error(ResolverUtil.logMsgForClass(enclosingClass, mappedClass) + " table could not be found");
            return null;
        }

        return new NodeData(new NormalAnnotationExpr(new NameExpr(SIMPLE_NAME), Collections.singletonList(new MemberValuePair("name", new StringLiteralExpr(upperCaseTableName ? tableName.toUpperCase() : tableName)))),
                new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
    }
    return null;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:29,代码来源:TableResolver.java

示例10: getTypeNameForMsg

import japa.parser.ast.body.TypeDeclaration; //导入方法依赖的package包/类
private String getTypeNameForMsg(final Node n) {
    final CompilationUnit unit = getCompilationUnit(n);
    final TypeDeclaration parent = unit.getTypes().get(0);
    return parent.getName();
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:6,代码来源:AnnotationHelper.java


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