本文整理汇总了Java中japa.parser.ast.expr.SingleMemberAnnotationExpr类的典型用法代码示例。如果您正苦于以下问题:Java SingleMemberAnnotationExpr类的具体用法?Java SingleMemberAnnotationExpr怎么用?Java SingleMemberAnnotationExpr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SingleMemberAnnotationExpr类属于japa.parser.ast.expr包,在下文中一共展示了SingleMemberAnnotationExpr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolve
import japa.parser.ast.expr.SingleMemberAnnotationExpr; //导入依赖的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: getAnnotationNodes
import japa.parser.ast.expr.SingleMemberAnnotationExpr; //导入依赖的package包/类
/** gets the annotation but also adds an import in the process if a Convert annotation is required. */
@Override
protected NodeData getAnnotationNodes(String enclosingClass, String fieldName, String mappedClass) {
final CollectionDescriptor cld = OjbUtil.findCollectionDescriptor(mappedClass, fieldName, descriptorRepositories);
if (cld != null) {
Collection<FieldHelper> orderBy = cld.getOrderBy();
if (orderBy != null && !orderBy.isEmpty()) {
String orderByStr = "";
for (FieldHelper fh : orderBy) {
orderByStr += fh.name + (fh.isAscending ? "" : " DESC") + ", ";
}
orderByStr = orderByStr.replaceAll(", $", "");
return new NodeData(new SingleMemberAnnotationExpr(new NameExpr(SIMPLE_NAME), new StringLiteralExpr(orderByStr)),
new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false));
}
}
return null;
}
示例3: resolve
import japa.parser.ast.expr.SingleMemberAnnotationExpr; //导入依赖的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));
}
示例4: getAnnotationNodes
import japa.parser.ast.expr.SingleMemberAnnotationExpr; //导入依赖的package包/类
@Override
protected NodeData getAnnotationNodes(String enclosingClass, String fieldName, String mappedClass) {
final List<Expression> joinColumns = getJoinColumns(enclosingClass, fieldName, mappedClass);
if (joinColumns != null && joinColumns.size() > 1) {
final Comment fixme = new BlockComment("\nFIXME: JPA_CONVERSION\n"
+ "For compound primary keys, make sure the join columns are in the correct order.\n");
AnnotationExpr
annotation = new SingleMemberAnnotationExpr(new NameExpr(SIMPLE_NAME), new ArrayInitializerExpr(joinColumns));
annotation.setComment(fixme);
return new NodeData(annotation,
new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false),
Arrays.asList(
new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PrimaryKeyJoinColumnResolver.PACKAGE),PrimaryKeyJoinColumnResolver.SIMPLE_NAME), false, false)
, new ImportDeclaration(new QualifiedNameExpr(new NameExpr(JoinColumnResolver.PACKAGE),JoinColumnResolver.SIMPLE_NAME), false, false)
));
}
return null;
}
示例5: visit
import japa.parser.ast.expr.SingleMemberAnnotationExpr; //导入依赖的package包/类
@Override
public void visit(SingleMemberAnnotationExpr expression, Object arg)
{ // annotation de type @SuppressWarnings("javadoc")
NameExpr name = expression.getName();
if(name.getName().equalsIgnoreCase("SuppressWarnings"))
{ Expression expr = expression.getMemberValue();
if(expr instanceof StringLiteralExpr)
{ StringLiteralExpr sle = (StringLiteralExpr) expr;
if(sle.getValue().equalsIgnoreCase("javadoc"))
{ int line = expression.getBeginLine();
printErr("Erreur ligne "+line+" : utilisation de l'annotation SuppressWarnings sur 'javadoc'. Il faut supprimer cette annotation et compléter la Javadoc.");
errorCount++;
}
}
}
//NOTE ne traite pas le cas où on a plusieurs membres, e.g. @SuppressWarnings({"javadoc","xxxx"})
}
示例6: visit
import japa.parser.ast.expr.SingleMemberAnnotationExpr; //导入依赖的package包/类
@Override
public void visit(SingleMemberAnnotationExpr expression, Object arg)
{ // annotation de type @SuppressWarnings("javadoc")
NameExpr name = expression.getName();
if(name.getName().equalsIgnoreCase("SuppressWarnings"))
{ Expression expr = expression.getMemberValue();
if(expr instanceof StringLiteralExpr)
{ StringLiteralExpr sle = (StringLiteralExpr) expr;
if(sle.getValue().equalsIgnoreCase("javadoc"))
{ int line = expression.getBeginLine();
printErr("Erreur ligne "+line+" : utilisation de l'annotation SuppressWarnings sur 'javadoc'. Il faut supprimer cette annotation et compléter la Javadoc.");
errorCount++;
}
}
}
//ne traite pas le cas où on a plusieurs membres, e.g. @SuppressWarnings({"javadoc","xxxx"})
}
示例7: visit
import japa.parser.ast.expr.SingleMemberAnnotationExpr; //导入依赖的package包/类
@Override
public void visit(SingleMemberAnnotationExpr expression, Object arg)
{ // annotation de type @SuppressWarnings("javadoc")
NameExpr name = expression.getName();
if(name.getName().equalsIgnoreCase("SuppressWarnings"))
{ Expression expr = expression.getMemberValue();
if(expr instanceof StringLiteralExpr)
{ StringLiteralExpr sle = (StringLiteralExpr) expr;
if(sle.getValue().equalsIgnoreCase("javadoc"))
{ int line = expression.getBeginLine();
printErr("Erreur ligne "+line+" : utilisation de l'annotation SuppressWarnings sur 'javadoc'. Il faut supprimer cette annotation et compléter la Javadoc.");
errorCount++;
}
}
}
//
}
示例8: isClaraHandler
import japa.parser.ast.expr.SingleMemberAnnotationExpr; //导入依赖的package包/类
private static boolean isClaraHandler(MethodDeclaration method, String id,
String className) {
if (method.getAnnotations()==null) {
return false;
}
for (AnnotationExpr ann : method.getAnnotations()) {
if ("UiHandler".equals(ann.getName().getName())) {
if (ann instanceof SingleMemberAnnotationExpr) {
SingleMemberAnnotationExpr smae = (SingleMemberAnnotationExpr)ann;
if (smae.getMemberValue() instanceof StringLiteralExpr) {
String v = ((StringLiteralExpr)smae.getMemberValue()).getValue();
if (id.equals(v)) {
return hasOneParamWithType(method, className);
}
}
}
}
}
return false;
}
示例9: isClaraField
import japa.parser.ast.expr.SingleMemberAnnotationExpr; //导入依赖的package包/类
private static boolean isClaraField(FieldDeclaration field, String id,
String className) {
if (field.getAnnotations()==null) {
return false;
}
for (AnnotationExpr ann : field.getAnnotations()) {
if ("UiField".equals(ann.getName().getName())) {
if (ann instanceof SingleMemberAnnotationExpr) {
SingleMemberAnnotationExpr smae = (SingleMemberAnnotationExpr)ann;
if (smae.getMemberValue() instanceof StringLiteralExpr) {
String v = ((StringLiteralExpr)smae.getMemberValue()).getValue();
if (id.equals(v)) {
return true;
}
}
}
}
}
return false;
}
示例10: getAnnotationNodes
import japa.parser.ast.expr.SingleMemberAnnotationExpr; //导入依赖的package包/类
@Override
protected NodeData getAnnotationNodes(String enclosingClass, String fieldName, String mappedClass) {
final FieldDescriptor fd = OjbUtil.findFieldDescriptor(mappedClass, fieldName, descriptorRepositories);
if (fd != null) {
final Class<?> fc = ResolverUtil.getType(enclosingClass, fieldName);
final String columnType = fd.getColumnType();
if (isJavaSqlDate(fc)) {
LOG.warn(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " is a java.sql.Date. " + getWarnMessageFragment(columnType));
} else if (isJavaSqlTimestamp(fc)) {
LOG.warn(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " is a java.sql.Timestamp. " + getWarnMessageFragment(columnType));
} else if (isJavaSqlTime(fc)) {
LOG.warn(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " is a java.sql.Time. " + getWarnMessageFragment(columnType));
} else if (isJavaUtilDate(fc) || isJavaUtilCalendar(fc)) {
if (DATE.equals(columnType)) {
return new NodeData(new SingleMemberAnnotationExpr(new NameExpr(SIMPLE_NAME), new NameExpr("TemporalType.DATE")),
new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false),
Collections.singletonList(new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), "TemporalType"), false, false)));
} else if (TIMESTAMP.equals(columnType)) {
return new NodeData(new SingleMemberAnnotationExpr(new NameExpr(SIMPLE_NAME), new NameExpr("TemporalType.TIMESTAMP")),
new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false),
Collections.singletonList(new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), "TemporalType"), false, false)));
} else if (TIME.equals(columnType)) {
return new NodeData(new SingleMemberAnnotationExpr(new NameExpr(SIMPLE_NAME), new NameExpr("TemporalType.TIME")),
new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false),
Collections.singletonList(new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), "TemporalType"), false, false)));
}
LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " is a java.sql.Date or java.util.Calendar but the column type " + columnType + " is unknown. Unable to add @Temporal annotation");
}
return null;
}
return null;
}
示例11: getAnnotationNodes
import japa.parser.ast.expr.SingleMemberAnnotationExpr; //导入依赖的package包/类
@Override
protected NodeData getAnnotationNodes(String enclosingClass, String fieldName, String mappedClass) {
final List<Expression> joinColumns = getJoinColumns(enclosingClass, fieldName, mappedClass);
if (joinColumns != null && joinColumns.size() > 1) {
final Comment fixme = new BlockComment("\nFIXME: JPA_CONVERSION\n"
+ "For compound primary keys, make sure the join columns are in the correct order.\n");
AnnotationExpr annotation = new SingleMemberAnnotationExpr(new NameExpr(SIMPLE_NAME), new ArrayInitializerExpr(joinColumns));
annotation.setComment(fixme);
return new NodeData(annotation,
new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false),
Collections.singletonList(new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), "PrimaryKeyJoinColumn"), false, false)));
}
return null;
}
示例12: getNestedClassNames
import japa.parser.ast.expr.SingleMemberAnnotationExpr; //导入依赖的package包/类
private static String[ ] getNestedClassNames( TypeDeclaration decl )
{
SingleMemberAnnotationExpr fullNameAnnot = ( SingleMemberAnnotationExpr ) decl.getAnnotations( ).get( 0 );
StringLiteralExpr fullNameExpr = ( StringLiteralExpr ) fullNameAnnot.getMemberValue( );
String fullName = fullNameExpr.getValue( );
int lastDot = fullName.lastIndexOf( '.' );
return fullName.substring( lastDot + 1 ).split( "\\$" );
}
示例13: findJavaFile
import japa.parser.ast.expr.SingleMemberAnnotationExpr; //导入依赖的package包/类
private static File findJavaFile( TypeDeclaration builderParentDecl )
{
SingleMemberAnnotationExpr fullNameAnnot = ( SingleMemberAnnotationExpr ) builderParentDecl.getAnnotations( ).get( 0 );
StringLiteralExpr fullNameExpr = ( StringLiteralExpr ) fullNameAnnot.getMemberValue( );
String fullName = fullNameExpr.getValue( );
int lastDot = fullName.lastIndexOf( '.' );
String path = fullName.substring( 0 , lastDot ).replace( '.' , File.separatorChar );
String[ ] classNames = fullName.substring( lastDot + 1 ).split( "\\$" );
String filePath = path + File.separator + classNames[ 0 ] + ".java";
return FileFinder.findFile( filePath , new File( "applet/src" ) , 2 );
}
示例14: visit
import japa.parser.ast.expr.SingleMemberAnnotationExpr; //导入依赖的package包/类
public Boolean visit(SingleMemberAnnotationExpr n1, Node arg) {
SingleMemberAnnotationExpr n2 = (SingleMemberAnnotationExpr) arg;
if (!nodeEquals(n1.getName(), n2.getName())) {
return Boolean.FALSE;
}
if (!nodeEquals(n1.getMemberValue(), n2.getMemberValue())) {
return Boolean.FALSE;
}
return Boolean.TRUE;
}
示例15: visit
import japa.parser.ast.expr.SingleMemberAnnotationExpr; //导入依赖的package包/类
public void visit(SingleMemberAnnotationExpr n, Object arg) {
printer.print("@");
n.getName().accept(this, arg);
printer.print("(");
n.getMemberValue().accept(this, arg);
printer.print(")");
}