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


Java TypeDeclaration.getParentNode方法代码示例

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


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

示例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;
    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

示例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 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

示例6: canFieldBeAnnotated

import japa.parser.ast.body.TypeDeclaration; //导入方法依赖的package包/类
public static boolean canFieldBeAnnotated(FieldDeclaration node) {
    final TypeDeclaration dclr = (TypeDeclaration) node.getParentNode();
    if (!ModifierSet.isStatic(node.getModifiers()) && dclr.getParentNode() instanceof CompilationUnit) {
        //handling nested classes
        return true;
    }
    return false;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:9,代码来源:ResolverUtil.java


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