private AnnotationElementSource add(AnnotationElementSource annotationElement) { @SuppressWarnings("unchecked") final ListIterator<BodyDeclaration> members = getDeclaration().bodyDeclarations().listIterator(); // skip any members before annotation elements, i.e. nested types while (members.hasNext()) { if (members.next() instanceof AnnotationTypeMemberDeclaration) { break; } } // find the last annotation element while (members.hasNext()) { if (members.next() instanceof AnnotationTypeMemberDeclaration) { continue; } // back up a step members.previous(); break; } members.add((BodyDeclaration) annotationElement.getInternal()); return annotationElement; }
@Override public AnnotationElementSource getAnnotationElement(String name) { for (AnnotationElementSource annotationElement : getAnnotationElements()) { if (Strings.areEqual(name, annotationElement.getName())) { return annotationElement; } } return null; }
private AnnotationElementSource add(AnnotationElementSource annotationElement) { @SuppressWarnings("unchecked") final ListIterator<BodyDeclaration> members = getBodyDeclaration().bodyDeclarations().listIterator(); // skip any members before annotation elements, i.e. nested types while (members.hasNext()) { if (members.next() instanceof AnnotationTypeMemberDeclaration) { break; } } // find the last annotation element while (members.hasNext()) { if (members.next() instanceof AnnotationTypeMemberDeclaration) { continue; } // back up a step members.previous(); break; } members.add((BodyDeclaration) annotationElement.getInternal()); return annotationElement; }
@Override public boolean hasAnnotationElement(String name) { for (AnnotationElementSource annotationElement : getAnnotationElements()) { if (Strings.areEqual(name, annotationElement.getName())) { return true; } } return false; }
private AnnotationElementSource add(AnnotationElementSource annotationElement) { @SuppressWarnings("unchecked") final ListIterator<BodyDeclaration> members = getBodyDeclaration().bodyDeclarations().listIterator(); //skip any members before annotation elements, i.e. nested types while (members.hasNext()) { if (members.next() instanceof AnnotationTypeMemberDeclaration) { break; } } //find the last annotation element while (members.hasNext()) { if (members.next() instanceof AnnotationTypeMemberDeclaration) { continue; } //back up a step members.previous(); break; } members.add((BodyDeclaration) annotationElement.getInternal()); return annotationElement; }
@Override public AnnotationElementSource getAnnotationElement(String name) { for (AnnotationElementSource annotationElement : getAnnotationElements()) { if (Strings.areEqual(name, annotationElement.getName())) { return annotationElement; } } return null; }
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 boolean hasAnnotationElement(String name) { for (AnnotationElementSource annotationElement : getAnnotationElements()) { if (Strings.areEqual(name, annotationElement.getName())) { return true; } } return false; }
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 AnnotationElementSource getAnnotationElement(String name) { for (AnnotationElementSource annotationElement : getAnnotationElements()) { if (Strings.areEqual(name, annotationElement.getName())) { return annotationElement; } } return null; }
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 boolean hasAnnotationElement(String name) { for (AnnotationElementSource annotationElement : getAnnotationElements()) { if (Strings.areEqual(name, annotationElement.getName())) { return true; } } return false; }
@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; }