protected SingleMemberAnnotation newSingleMemberAnnotation(AST ast, String name) { SingleMemberAnnotation annotation = ast.newSingleMemberAnnotation(); annotation.setTypeName(ast.newName(name)); return annotation; }
/** * Builds a new {@link SingleMemberAnnotation} instance. * * @param typeName the annotation type name * @param value the annotation single value * @return a new single member annotation */ public SingleMemberAnnotation singleValueAnnotation(Name typeName, Expression value) { final SingleMemberAnnotation sma = ast.newSingleMemberAnnotation(); sma.setTypeName(typeName); sma.setValue(value); return sma; }
public SingleMemberAnnotation createCatchMark(String catchMark) { SingleMemberAnnotation supp = ast.newSingleMemberAnnotation(); supp.setTypeName(ast.newSimpleName("SuppressWarnings")); StringLiteral sl = ast.newStringLiteral(); sl.setLiteralValue(catchMark); supp.setValue(sl); return supp; }
final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { if (property == TYPE_NAME_PROPERTY) { if (get) { return getTypeName(); } else { setTypeName((Name) child); return null; } } if (property == VALUE_PROPERTY) { if (get) { return getValue(); } else { setValue((Expression) child); return null; } } // allow default implementation to flag the error return super.internalGetSetChildProperty(property, get, child); }
final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { if (property == TYPE_NAME_PROPERTY) { if (get) { return getTypeName(); } else { setTypeName((Name) child); return null; } } if (property == VALUE_PROPERTY) { if (get) { return getValue(); } else { setValue((Expression) child); return null; } } // allow default implementation to flag the error return super.internalGetSetChildProperty(property, get, child); }
final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { if (property == TYPE_NAME_PROPERTY) { if (get) { return getTypeName(); } else { setTypeName((Name) child); return null; } } if (property == VALUE_PROPERTY) { if (get) { return getValue(); } else { setValue((Expression) child); return null; } } // allow default implementation to flag the error return super.internalGetSetChildProperty(property, get, child); }
final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { if (property == TYPE_NAME_PROPERTY) { if (get) { return getTypeName(); } else { setTypeName((Name) child); return null; } } if (property == VALUE_PROPERTY) { if (get) { return getValue(); } else { setValue((Expression) child); return null; } } // allow default implementation to flag the error return super.internalGetSetChildProperty(property, get, child); }
@Override final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { if (property == TYPE_NAME_PROPERTY) { if (get) { return getTypeName(); } else { setTypeName((Name) child); return null; } } if (property == VALUE_PROPERTY) { if (get) { return getValue(); } else { setValue((Expression) child); return null; } } // allow default implementation to flag the error return super.internalGetSetChildProperty(property, get, child); }
final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { if (property == TYPE_NAME_PROPERTY) { if (get) { return getTypeName(); } else { setTypeName((Name) child); return null; } } if (property == VALUE_PROPERTY) { if (get) { return getValue(); } else { setValue((Expression) child); return null; } } // allow default implementation to flag the error return super.internalGetSetChildProperty(property, get, child); }
/** * For given java source, add {@code @XmlAccessorType(XmlAccessType.NONE)} class annotation * * @param source * @see XmlAccessorType * @see XmlAccessType#NONE */ public static String addXmlAccessNoneAnnotation(final String source) { final CompilationUnit unit = JavaSourceUtils.getCompilationUnit(source); if (unit.types() == null || unit.types().size() < 1) { log.warn("Invalid java file"); return source; } final TypeDeclaration classType = (TypeDeclaration) unit.types().get(0); final AST ast = unit.getAST(); // create annotation final SingleMemberAnnotation xmlAccessAnnotation = ast.newSingleMemberAnnotation(); xmlAccessAnnotation.setTypeName(ast.newSimpleName(XmlAccessorType.class.getSimpleName())); // add annotation value final FieldAccess value = ast.newFieldAccess(); value.setExpression(ast.newName(XmlAccessType.class.getSimpleName())); value.setName(ast.newSimpleName("NONE")); xmlAccessAnnotation.setValue(value); // rewrite & add imports: JavaSourceUtils.addImport(unit, XmlAccessType.class.getName()); JavaSourceUtils.addImport(unit, XmlAccessorType.class.getName()); JavaSourceUtils.addAnnotation(classType, xmlAccessAnnotation); return JavaSourceUtils.rewrite(unit, ast); }
/** * For given java source, add {@code @XmlAccessorType(XmlAccessType.NONE)} class annotation * * @param source * @see XmlAccessorType * @see XmlAccessType#NONE */ public static String addXmlAccessNoneAnnotation(final String source) { final CompilationUnit unit = JavaSourceUtils.getCompilationUnit(source); if (unit.types() == null || unit.types().size() < 1) { log.warn("Invalid java file"); return source; } final TypeDeclaration classType = (TypeDeclaration) unit.types().get(0); final AST ast = unit.getAST(); // create annotation final SingleMemberAnnotation xmlAccessAnnotation = ast.newSingleMemberAnnotation(); xmlAccessAnnotation.setTypeName(ast.newSimpleName(XmlAccessorType.class.getSimpleName())); // add annotation value final FieldAccess value = ast.newFieldAccess(); value.setExpression(ast.newName(XmlAccessType.class.getSimpleName())); value.setName(ast.newSimpleName("NONE")); xmlAccessAnnotation.setValue(value); // rewrite & add imports: JavaSourceUtils.addImport(unit, XmlAccessType.class.getName()); JavaSourceUtils.addImport(unit, XmlAccessorType.class.getName()); JavaSourceUtils.addAnnotation(classType, xmlAccessAnnotation); return JavaSourceUtils.rewrite(unit, ast); }
@Override ASTNode clone0(AST target) { SingleMemberAnnotation result = new SingleMemberAnnotation(target); result.setSourceRange(getStartPosition(), getLength()); result.setTypeName((Name) ASTNode.copySubtree(target, getTypeName())); result.setValue((Expression) ASTNode.copySubtree(target, getValue())); return result; }
ASTNode clone0(AST target) { SingleMemberAnnotation result = new SingleMemberAnnotation(target); result.setSourceRange(getStartPosition(), getLength()); result.setTypeName((Name) ASTNode.copySubtree(target, getTypeName())); result.setValue((Expression) ASTNode.copySubtree(target, getValue())); return result; }
ASTNode clone0(AST target) { SingleMemberAnnotation result = new SingleMemberAnnotation(target); result.setSourceRange(getStartPosition(), getLength()); result.setTypeName((Name) ASTNode.copySubtree(target, getTypeName())); result.setValue((Expression) ASTNode.copySubtree(target, getValue())); return result; }
ASTNode clone0(AST target) { SingleMemberAnnotation result = new SingleMemberAnnotation(target); result.setSourceRange(getStartPosition(), getLength()); result.setTypeName((Name) ASTNode.copySubtree(target, getTypeName())); result.setValue((Expression) ASTNode.copySubtree(target, getValue())); return result; }
ASTNode clone0(AST target) { SingleMemberAnnotation result = new SingleMemberAnnotation(target); result.setSourceRange(getStartPosition(), getLength()); result.setTypeName((Name) ASTNode.copySubtree(target, getTypeName())); result.setValue((Expression) ASTNode.copySubtree(target, getValue())); return result; }
ASTNode clone0(AST target) { SingleMemberAnnotation result = new SingleMemberAnnotation(target); result.setSourceRange(getStartPosition(), getLength()); result.setTypeName((Name) ASTNode.copySubtree(target, getTypeName())); result.setValue((Expression) ASTNode.copySubtree(target, getValue())); return result; }
newAnnot.setTypeName(ast.newName(importString));
newAnnot.setTypeName(ast.newName(importString));
newAnnot.setTypeName(ast.newName(importString));