@Override public Node visit(MarkerAnnotationExpr _n, Object _arg) { NameExpr name = cloneNodes(_n.getName(), _arg); Comment comment = cloneNodes(_n.getComment(), _arg); MarkerAnnotationExpr r = new MarkerAnnotationExpr( _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), name ); r.setComment(comment); return r; }
@Override public void visit(final MarkerAnnotationExpr n, final A arg) { visitComment(n.getComment(), arg); n.getName().accept(this, arg); }
final public MarkerAnnotationExpr MarkerAnnotation() throws ParseException { NameExpr name; int line; int column; jj_consume_token(AT); line=token.beginLine; column=token.beginColumn; name = Name(); MarkerAnnotationExpr tmp = new MarkerAnnotationExpr(line, column, token.endLine, token.endColumn,name); {if (true) return tmp;} throw new Error("Missing return statement in function"); }
public MarkerAnnotationExpr(final int beginLine, final int beginColumn, final int endLine, final int endColumn, final NameExpr name) { super(beginLine, beginColumn, endLine, endColumn); setName(name); }
final public MarkerAnnotationExpr MarkerAnnotation() throws ParseException { NameExpr name; int line; int column; jj_consume_token(AT); line=token.beginLine; column=token.beginColumn; name = Name(); {if (true) return new MarkerAnnotationExpr(line, column, token.endLine, token.endColumn,name);} throw new Error("Missing return statement in function"); }
@Override public void visit(final MarkerAnnotationExpr n, final Object arg) { printJavaComment(n.getComment(), arg); printer.print("@"); n.getName().accept(this, arg); }
@Override public R visit(final MarkerAnnotationExpr n, final A arg) { { R result = n.getName().accept(this, arg); if (result != null) { return result; } } return null; }
public MarkerAnnotationExpr(final NameExpr name) { setName(name); }
@Override protected NodeData getAnnotationNodes(String enclosingClass, String fieldName, String mappedClass) { final boolean pk = isPrimaryKeyColumn(mappedClass, fieldName); if (pk) { return new NodeData(new MarkerAnnotationExpr(new NameExpr(SIMPLE_NAME)), new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false)); } return null; }
public void visit(MarkerAnnotationExpr n, Object arg) { printer.print("@"); n.getName().accept(this, arg); }
@Override protected NodeData getAnnotationNodes(String enclosingClass, String fieldName, String mappedClass) { final FieldDescriptor fd = OjbUtil.findFieldDescriptor(mappedClass, fieldName, descriptorRepositories); if (fd != null) { if (fd.isLocking()) { return new NodeData(new MarkerAnnotationExpr(new NameExpr(SIMPLE_NAME)), new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false)); } } return null; } }
@Override public 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 boolean mappedColumn = OjbUtil.isMappedColumn(mappedClass, ParserUtil.getFieldName(field), descriptorRepositories); if (!mappedColumn) { return new NodeData(new MarkerAnnotationExpr(new NameExpr(SIMPLE_NAME)), new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false)); } } return null; } }
@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; } }
private NodeAndImports<MethodDeclaration> createPrimaryKeyHashCode(Collection<FieldDescriptor> primaryKeyDescriptors) { final MethodDeclaration hashCode = new MethodDeclaration(ModifierSet.PUBLIC, new PrimitiveType(PrimitiveType.Primitive.Int), "hashCode"); hashCode.setAnnotations(Collections.<AnnotationExpr>singletonList(new MarkerAnnotationExpr(new NameExpr("Override")))); final List<Expression> ctorArgs = new ArrayList<Expression>(); ctorArgs.add(new IntegerLiteralExpr("17")); ctorArgs.add(new IntegerLiteralExpr("37")); Expression hashCodeExpr = new ObjectCreationExpr(null, new ClassOrInterfaceType("HashCodeBuilder"), ctorArgs); for (FieldDescriptor f : primaryKeyDescriptors) { final List<Expression> args = new ArrayList<Expression>(); args.add(new FieldAccessExpr(new ThisExpr(), f.getAttributeName())); hashCodeExpr = new MethodCallExpr(hashCodeExpr, "append", args); } hashCodeExpr = new MethodCallExpr(hashCodeExpr, "toHashCode"); final BlockStmt equalsBody = new BlockStmt(Collections.<Statement>singletonList(new ReturnStmt(hashCodeExpr))); hashCode.setBody(equalsBody); return new NodeAndImports<MethodDeclaration>(hashCode, Collections.singleton(new ImportDeclaration(new QualifiedNameExpr(new NameExpr("org.apache.commons.lang.builder"), "HashCodeBuilder"), false, false))); }
@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 (isLob(columnType)) { if (isValidFieldType(fc)) { return new NodeData(new MarkerAnnotationExpr(new NameExpr(SIMPLE_NAME)), new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false)); } else { LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " is not a valid field type for the @Lob annotation, must be one of " + VALID_TYPES_STR); } } return null; } return null; }
private NodeAndImports<MethodDeclaration> createPrimaryKeyToString(Collection<FieldDescriptor> primaryKeyDescriptors) { final MethodDeclaration toString = new MethodDeclaration(ModifierSet.PUBLIC, new ClassOrInterfaceType("String"), "toString"); toString.setAnnotations(Collections.<AnnotationExpr>singletonList(new MarkerAnnotationExpr(new NameExpr("Override")))); Expression toStringBuilderExpr = new ObjectCreationExpr(null, new ClassOrInterfaceType("ToStringBuilder"), Collections.<Expression>singletonList(new ThisExpr())); for (FieldDescriptor f : primaryKeyDescriptors) { final List<Expression> args = new ArrayList<Expression>(); args.add(new StringLiteralExpr(f.getAttributeName())); args.add(new FieldAccessExpr(new ThisExpr(), f.getAttributeName())); toStringBuilderExpr = new MethodCallExpr(toStringBuilderExpr, "append", args); } toStringBuilderExpr = new MethodCallExpr(toStringBuilderExpr, "toString"); final BlockStmt toStringBody = new BlockStmt(Collections.<Statement>singletonList(new ReturnStmt(toStringBuilderExpr))); toString.setBody(toStringBody); return new NodeAndImports<MethodDeclaration>(toString, Collections.singleton(new ImportDeclaration(new QualifiedNameExpr(new NameExpr("org.apache.commons.lang.builder"), "ToStringBuilder"), false, false))); }
private NodeAndImports<MethodDeclaration> createPrimaryKeyCompareTo(Collection<FieldDescriptor> primaryKeyDescriptors, String enclosingClassName) { final MethodDeclaration compareTo = new MethodDeclaration(ModifierSet.PUBLIC, new PrimitiveType(PrimitiveType.Primitive.Int), "compareTo", Collections.singletonList(new Parameter(new ClassOrInterfaceType(enclosingClassName), new VariableDeclaratorId("other")))); compareTo.setAnnotations(Collections.<AnnotationExpr>singletonList(new MarkerAnnotationExpr(new NameExpr("Override")))); Expression compareToBuilderExpr = new ObjectCreationExpr(null, new ClassOrInterfaceType("CompareToBuilder"), Collections.<Expression>emptyList()); for (FieldDescriptor f : primaryKeyDescriptors) { final List<Expression> args = new ArrayList<Expression>(); args.add(new FieldAccessExpr(new ThisExpr(), f.getAttributeName())); args.add(new FieldAccessExpr(new NameExpr("other"), f.getAttributeName())); compareToBuilderExpr = new MethodCallExpr(compareToBuilderExpr, "append", args); } compareToBuilderExpr = new MethodCallExpr(compareToBuilderExpr, "toComparison"); final List<Statement> statements = new ArrayList<Statement>(); statements.add(new ReturnStmt(compareToBuilderExpr)); final BlockStmt equalsBody = new BlockStmt(statements); compareTo.setBody(equalsBody); return new NodeAndImports<MethodDeclaration>(compareTo, Collections.singleton(new ImportDeclaration(new QualifiedNameExpr(new NameExpr("org.apache.commons.lang.builder"), "CompareToBuilder"), false, false))); }
@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; } }