本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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));
}
示例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;
}
示例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());
}
}
示例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());
}
}
示例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;
}
示例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();
}