@Override public Node visit(QualifiedNameExpr _n, Object _arg) { NameExpr scope = cloneNodes(_n.getQualifier(), _arg); Comment comment = cloneNodes(_n.getComment(), _arg); QualifiedNameExpr r = new QualifiedNameExpr( _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), scope, _n.getName() ); r.setComment(comment); return r; }
public void setQualifier(final NameExpr qualifier) { this.qualifier = qualifier; setAsParentNodeOf(this.qualifier); } }
@Override public Boolean visit(final QualifiedNameExpr n1, final Node arg) { final QualifiedNameExpr n2 = (QualifiedNameExpr) arg; if (!nodeEquals(n1.getQualifier(), n2.getQualifier())) { return Boolean.FALSE; } if (!objEquals(n1.getName(), n2.getName())) { return Boolean.FALSE; } return Boolean.TRUE; }
@Override public Node visit(final QualifiedNameExpr n, final A arg) { n.setQualifier((NameExpr) n.getQualifier().accept(this, arg)); return n; }
/** * Creates a new {@link NameExpr} from a qualified name.<br> * The qualified name can contains "." (dot) characters. * * @param qualifiedName * qualified name * @return instanceof {@link NameExpr} */ public static NameExpr createNameExpr(String qualifiedName) { String[] split = qualifiedName.split("\\."); NameExpr ret = new NameExpr(split[0]); for (int i = 1; i < split.length; i++) { ret = new QualifiedNameExpr(ret, split[i]); } return ret; }
@Override public void visit(final QualifiedNameExpr n, final Object arg) { printJavaComment(n.getComment(), arg); n.getQualifier().accept(this, arg); printer.print("."); printer.print(n.getName()); printOrphanCommentsEnding(n); }
@Override public void visit(final QualifiedNameExpr n, final A arg) { visitComment(n.getComment(), arg); n.getQualifier().accept(this, arg); }
@Override public R visit(final QualifiedNameExpr n, final A arg) { { R result = n.getQualifier().accept(this, arg); if (result != null) { return result; } } return null; }
@Override protected NodeData getAnnotationNodes(String enclosingClass, String fieldName, String mappedClass) { final List<Expression> joinColumns = getJoinColumns(enclosingClass, fieldName, mappedClass); if (joinColumns != null && joinColumns.size() == 1) { return new NodeData((AnnotationExpr) joinColumns.get(0), new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false)); } return null; } }
private String toString(NameExpr n) { if (n instanceof QualifiedNameExpr) { QualifiedNameExpr qn = (QualifiedNameExpr)n; return qn.getQualifier() + "." + qn.getName(); } else { return n.getName(); } }
@Override protected NodeData getAnnotationNodes(String enclosingClass, String fieldName, String mappedClass) { final List<Expression> joinColumns = getJoinColumns(enclosingClass, fieldName, mappedClass); if (joinColumns != null && joinColumns.size() == 1) { return new NodeData((AnnotationExpr) joinColumns.get(0), new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false)); } return null; } }
public void visit(QualifiedNameExpr n, Object arg) { n.getQualifier().accept(this, arg); printer.print("."); printer.print(n.getName()); }
@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; } }
@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; } }
@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; }
@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 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); if (isEnum(fc)) { final Comment fixme = new BlockComment("\nFIXME:\n" + "Enums must be annotated with the @Enumerated annotation.\n " + "The @Enumerated annotation should set the EnumType.\n" + "If the EnumType is not set, then the Enumerated annotation is defaulted to EnumType.ORDINAL.\n" + "This conversion program cannot tell whether EnumType.ORDINAL is the appropriate EnumType."); AnnotationExpr enumerated = new NormalAnnotationExpr(new NameExpr(SIMPLE_NAME), Collections.singletonList(new MemberValuePair("value", new NameExpr("EnumType.")))); enumerated.setComment(fixme); return new NodeData(enumerated, new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false), Collections.singletonList(new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), "TemporalType"), false, false))); } } return null; }
+ " but a replacement converter was not configured, unable to set Convert class"); return new NodeData(new NormalAnnotationExpr(new NameExpr(SIMPLE_NAME), Collections.singletonList(new MemberValuePair("converter", new NameExpr(null)))), new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false)); } else if ( StringUtils.isBlank(jpaConverter) ) { LOG.info(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has a converter " + fc.getClass().getName() final String packageName = ClassUtils.getPackageName(jpaConverter); return new NodeData(new NormalAnnotationExpr(new NameExpr(SIMPLE_NAME), Collections.singletonList(new MemberValuePair("converter", new NameExpr(shortClassName + ".class")))), new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false), Collections.singletonList(new ImportDeclaration(new QualifiedNameExpr(new NameExpr(packageName), shortClassName), false, false)));
@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 protected NodeData getAnnotationNodes(String enclosingClass, String fieldName, String mappedClass) { final FieldDescriptor fd = OjbUtil.findFieldDescriptor(mappedClass, fieldName, descriptorRepositories); if (fd != null) { final boolean autoInc = fd.isAutoIncrement(); final String seqName = fd.getSequenceName(); if (autoInc && StringUtils.isBlank(seqName)) { LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has autoincrement set to true but sequenceName is blank."); } if (!autoInc && StringUtils.isNotBlank(seqName)) { LOG.error(ResolverUtil.logMsgForField(enclosingClass, fieldName, mappedClass) + " field has autoincrement set to false but sequenceName is " + seqName + "."); } if (autoInc || StringUtils.isNotBlank(seqName)) { return new NodeData(new NormalAnnotationExpr(new NameExpr(SIMPLE_NAME), Collections.singletonList(new MemberValuePair("name", new StringLiteralExpr(upperCaseTableName ? seqName.toUpperCase() : seqName)))), new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false)); } } return null; } }