private static AnnotationTypeMemberDeclaration parseElement(JavaAnnotationSource parent, String declaration) { if (!declaration.trim().endsWith(";")) { declaration = declaration + ";"; } String stub = "public @interface Stub { " + declaration + " }"; JavaAnnotationSource temp = (JavaAnnotationSource) Roaster.parse(stub); List<AnnotationElementSource> fields = temp.getAnnotationElements(); AnnotationTypeMemberDeclaration newField = (AnnotationTypeMemberDeclaration) fields.get(0).getInternal(); return (AnnotationTypeMemberDeclaration) ASTNode.copySubtree(((ASTNode) parent.getInternal()).getAST(), newField); }
private static AnnotationTypeMemberDeclaration parseElement(JavaAnnotationSource parent, String declaration) { if (!declaration.trim().endsWith(";")) { declaration = declaration + ";"; } String stub = "public @interface Stub { " + declaration + " }"; JavaAnnotationSource temp = (JavaAnnotationSource) Roaster.parse(stub); List<AnnotationElementSource> fields = temp.getAnnotationElements(); AnnotationTypeMemberDeclaration newField = (AnnotationTypeMemberDeclaration) fields.get(0).getInternal(); return (AnnotationTypeMemberDeclaration) ASTNode.copySubtree(((ASTNode) parent.getInternal()).getAST(), newField); }
private static AnnotationTypeMemberDeclaration parseElement(JavaAnnotationSource parent, String declaration) { if (!declaration.trim().endsWith(";")) { declaration = declaration + ";"; } String stub = "public @interface Stub { " + declaration + " }"; JavaAnnotationSource temp = (JavaAnnotationSource) Roaster.parse(stub); List<AnnotationElementSource> fields = temp.getAnnotationElements(); AnnotationTypeMemberDeclaration newField = (AnnotationTypeMemberDeclaration) fields.get(0).getInternal(); return (AnnotationTypeMemberDeclaration) ASTNode.copySubtree(((ASTNode) parent.getInternal()).getAST(), newField); }
@Override public DefaultValue setLiteral(String value) { if (value == null) { member.setDefault(null); } else { String stub = "public @interface Stub { String stub() default " + value + "; }"; JavaAnnotationSource temp = (JavaAnnotationSource) Roaster.parse(stub); AnnotationTypeMemberDeclaration internal = (AnnotationTypeMemberDeclaration) temp.getAnnotationElements() .get(0).getInternal(); member.setDefault((Expression) ASTNode.copySubtree(ast, internal.getDefault())); } return this; }
@Override public DefaultValue setLiteral(String value) { if (value == null) { member.setDefault(null); } else { String stub = "public @interface Stub { String stub() default " + value + "; }"; JavaAnnotationSource temp = (JavaAnnotationSource) Roaster.parse(stub); AnnotationTypeMemberDeclaration internal = (AnnotationTypeMemberDeclaration) temp.getAnnotationElements() .get(0).getInternal(); member.setDefault((Expression) ASTNode.copySubtree(ast, internal.getDefault())); } return this; }
@Override public DefaultValue setLiteral(String value) { if (value == null) { member.setDefault(null); } else { String stub = "public @interface Stub { String stub() default " + value + "; }"; JavaAnnotationSource temp = (JavaAnnotationSource) Roaster.parse(stub); AnnotationTypeMemberDeclaration internal = (AnnotationTypeMemberDeclaration) temp.getAnnotationElements() .get(0).getInternal(); member.setDefault((Expression) ASTNode.copySubtree(ast, internal.getDefault())); } return this; }