public AnnotationImpl(final AnnotationTargetSource<O, T> parent, final Object internal) { this.parent = parent; ast = ((ASTNode) parent.getInternal()).getAST(); annotation = (org.eclipse.jdt.core.dom.Annotation) internal; }
@Override public O getOrigin() { return parent.getOrigin(); }
public void updateAnnotations(AnnotationTargetSource annotationTargetSource, List<Annotation> annotations, ClassTypeResolver classTypeResolver) throws Exception { List<AnnotationSource<?>> currentAnnotations = annotationTargetSource.getAnnotations(); if (currentAnnotations != null) { for (AnnotationSource<?> currentAnnotation : currentAnnotations) { annotationTargetSource.removeAnnotation(currentAnnotation); } } if (annotations != null) { for (Annotation annotation : annotations) { addAnnotation(annotationTargetSource, annotation); } } }
public AnnotationSource<?> addAnnotation(AnnotationTargetSource annotationTargetSource, Annotation annotation) { AnnotationSource<?> newAnnotationSource = annotationTargetSource.addAnnotation(); newAnnotationSource.setName(annotation.getClassName()); AnnotationDefinition annotationDefinition = annotation.getAnnotationDefinition(); if (!annotationDefinition.isMarker()) { for (AnnotationValuePairDefinition memberDefinition : annotationDefinition.getValuePairs()) { Object value = annotation.getValue(memberDefinition.getName()); if (value != null) { addMemberValue(newAnnotationSource, memberDefinition, value); } } } return newAnnotationSource; }
@Override public O getOrigin() { return parent.getOrigin(); }
public AnnotationImpl(final AnnotationTargetSource<O, T> parent, final Object internal) { this.parent = parent; ast = ((ASTNode) parent.getInternal()).getAST(); Assert.notNull(internal, "internal representation must not be null"); annotation = (org.eclipse.jdt.core.dom.Annotation) internal; }
@Override public O getOrigin() { return parent.getOrigin(); }
public AnnotationImpl(final AnnotationTargetSource<O, T> parent, final Object internal) { this.parent = parent; ast = ((ASTNode) parent.getInternal()).getAST(); Assert.notNull(internal, "internal representation must not be null"); annotation = (org.eclipse.jdt.core.dom.Annotation) internal; }
@Override public String getQualifiedName() { return parent.getOrigin().resolveType(getName()); }
private static org.eclipse.jdt.core.dom.Annotation createAnnotation(final AnnotationTargetSource<?, ?> parent, final AnnotationType type) { AST ast = ((ASTNode) parent.getInternal()).getAST(); switch (type) { case MARKER: return ast.newMarkerAnnotation(); case SINGLE: return ast.newSingleMemberAnnotation(); case NORMAL: return ast.newNormalAnnotation(); default: throw new IllegalArgumentException("Unknown annotation type: " + type); } }
@Override public String getQualifiedName() { return parent.getOrigin().resolveType(getName()); }
private static org.eclipse.jdt.core.dom.Annotation createAnnotation(final AnnotationTargetSource<?, ?> parent, final AnnotationType type) { AST ast = ((ASTNode) parent.getInternal()).getAST(); switch (type) { case MARKER: return ast.newMarkerAnnotation(); case SINGLE: return ast.newSingleMemberAnnotation(); case NORMAL: return ast.newNormalAnnotation(); default: throw new IllegalArgumentException("Unknown annotation type: " + type); } }
@Override public String getQualifiedName() { return parent.getOrigin().resolveType(getName()); }
private static org.eclipse.jdt.core.dom.Annotation createAnnotation(final AnnotationTargetSource<?, ?> parent, final AnnotationType type) { AST ast = ((ASTNode) parent.getInternal()).getAST(); switch (type) { case MARKER: return ast.newMarkerAnnotation(); case SINGLE: return ast.newSingleMemberAnnotation(); case NORMAL: return ast.newNormalAnnotation(); default: throw new IllegalArgumentException("Unknown annotation type: " + type); } }
private AnnotationSource<O> addAnnotation(final AnnotationTargetSource<O, T> target, final List<?> modifiers, final String className) { if (target.getOrigin().requiresImport(className) && !target.getOrigin().hasImport(className) && Types.isQualified(className)) { target.getOrigin().addImport(className); } return addAnnotation(target, modifiers).setName(Types.toSimpleName(className)); }
private AnnotationSource<O> addAnnotation(final AnnotationTargetSource<O, T> target, final List<?> modifiers, final String className) { if (target.getOrigin().requiresImport(className) && !target.getOrigin().hasImport(className) && Types.isQualified(className)) { target.getOrigin().addImport(className); } return addAnnotation(target, modifiers).setName(Types.toSimpleName(className)); }
private AnnotationSource<O> addAnnotation(final AnnotationTargetSource<O, T> target, final List<?> modifiers, final String className) { if (!target.getOrigin().hasImport(className) && Types.isQualified(className)) { target.getOrigin().addImport(className); } return addAnnotation(target, modifiers).setName(Types.toSimpleName(className)); }