private ModifiersTree addAnnotation( String annotationFqn , TreeMaker maker,ModifiersTree modifiers ) { AnnotationTree newAnnotation = maker.Annotation( maker.QualIdent(annotationFqn) , Collections.<ExpressionTree>emptyList()); if (modifiers != null) { modifiers = maker.addModifiersAnnotation(modifiers, newAnnotation); } return modifiers; }
/** * Creates a new annotation. * * @param annotationType the fully-qualified name of the annotation type; * cannot be null. * <code>java.lang.SuppressWarnings</code>; cannot be null. * @param arguments the arguments of the new annotation; cannot be null. * @return the new annotation; never null. */ public AnnotationTree createAnnotation(String annotationType, List<? extends ExpressionTree> arguments) { Parameters.notNull("annotationType", annotationType); // NOI18N Parameters.notNull("arguments", arguments); // NOI18N ExpressionTree annotationTypeTree = createQualIdent(annotationType); return getTreeMaker().Annotation(annotationTypeTree, arguments); }
private static AnnotationTree createAnnotation(ProxyAction action, TreeMaker make, WorkingCopy workingCopy) { List<AssignmentTree> annAttrs = new LinkedList<AssignmentTree>(); for (String attrName : ProxyAction.getAnnotationAttributeNames()) { if (action.isAnnotationAttributeSet(attrName)) { Object value = action.getAnnotationAttributeValue(attrName); ExpressionTree expTree; if (value instanceof String) { expTree = make.Literal(value); } else if (value instanceof ProxyAction.BlockingType) { expTree = make.MemberSelect( make.MemberSelect(make.QualIdent(workingCopy.getElements().getTypeElement("org.jdesktop.application.Task")), // NOI18N "BlockingScope"), // NOI18N value.toString()); } else { continue; } ExpressionTree identTree = make.Identifier(attrName); AssignmentTree attrTree = make.Assignment(identTree, expTree); annAttrs.add(attrTree); } } return make.Annotation(make.QualIdent(workingCopy.getElements().getTypeElement("org.jdesktop.application.Action")), annAttrs); // NOI18N }
TypeMirror transientMirror = transientElement.asType(); Tree transientType = make.Type(transientMirror); AnnotationTree transientTree = make.Annotation(transientType, Collections.EMPTY_LIST); ModifiersTree modifiers = make.Modifiers(Modifier.PRIVATE, Collections.singletonList(transientTree)); TypeElement changeSupportElement = wc.getElements().getTypeElement("java.beans.PropertyChangeSupport"); // NOI18N
AnnotationTree joinColumnTree = make.Annotation(make.QualIdent(joinColumnElement), parameters); TypeElement manyToOneElement = wc.getElements().getTypeElement("javax.persistence.ManyToOne"); // NOI18N AnnotationTree manyToOneTree = make.Annotation(make.QualIdent(manyToOneElement), Collections.EMPTY_LIST); // NOI18N List<AnnotationTree> annotations = new ArrayList<AnnotationTree>(2); annotations.add(joinColumnTree);
parameters.add(mappedByParameter); TypeElement oneToManyElement = wc.getElements().getTypeElement("javax.persistence.OneToMany"); // NOI18N AnnotationTree oneToManyTree = make.Annotation(make.QualIdent(oneToManyElement), parameters); ModifiersTree modifiers = make.Modifiers(Collections.singleton(Modifier.PRIVATE), Collections.singletonList(oneToManyTree)); TypeElement collectionElement = wc.getElements().getTypeElement("java.util.Collection"); // NOI18N
AnnotationTree newAnnotation = make.Annotation(make.QualIdent(annotation), Collections.singletonList(attributeAssignmentTree));
mt = make.addModifiersAnnotation(prototype.getModifiers(), make.Annotation(make.Identifier("Override"), Collections.<ExpressionTree>emptyList()));