本文整理了Java中org.eclipse.jdt.core.dom.Annotation.isNormalAnnotation()
方法的一些代码示例,展示了Annotation.isNormalAnnotation()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Annotation.isNormalAnnotation()
方法的具体详情如下:
包路径:org.eclipse.jdt.core.dom.Annotation
类名称:Annotation
方法名:isNormalAnnotation
[英]Returns whether this is a normal annotation ( NormalAnnotation).
[中]返回这是否为普通批注(NormalAnnotation)。
代码示例来源:origin: org.projectlombok/lombok
org.eclipse.jdt.core.dom.SingleMemberAnnotation smAnn = (org.eclipse.jdt.core.dom.SingleMemberAnnotation) annotation;
values.add(smAnn.getValue().toString());
} else if (annotation.isNormalAnnotation()) {
org.eclipse.jdt.core.dom.NormalAnnotation normalAnn = (org.eclipse.jdt.core.dom.NormalAnnotation) annotation;
for (Object value : normalAnn.values()) values.add(value.toString());
代码示例来源:origin: forge/roaster
@Override
public boolean isNormal()
{
return annotation.isNormalAnnotation();
}
代码示例来源:origin: org.jboss.forge/roaster-jdt
@Override
public boolean isNormal()
{
return annotation.isNormalAnnotation();
}
代码示例来源:origin: org.eclipse/org.eclipse.jpt.core
/**
* Return the value of the *first* annotation element
* with the adapter's element name.
* Return null if the annotation has no such element.
* (An element name of "value" will return the value of a single
* member annotation.)
*/
protected Expression elementValue(Annotation annotation) {
if (annotation.isNormalAnnotation()) {
return this.elementValue((NormalAnnotation) annotation);
}
if (annotation.isSingleMemberAnnotation()) {
return this.elementValue((SingleMemberAnnotation) annotation);
}
return null;
}
代码示例来源:origin: org.eclipse/org.eclipse.jpt.core
/**
* Remove the *first* annotation element with the specified name
* from the specified annotation, converting the annotation as appropriate.
*/
protected void removeElementAndNormalize(ModifiedDeclaration declaration, Annotation outer) {
if (outer.isNormalAnnotation()) {
this.removeElementAndNormalize(declaration, (NormalAnnotation) outer);
} else if (outer.isSingleMemberAnnotation()) {
this.removeElementAndNormalize(declaration, (SingleMemberAnnotation) outer);
} else if (outer.isMarkerAnnotation()) {
this.removeElementAndNormalize(declaration, (MarkerAnnotation) outer);
} else {
throw new IllegalArgumentException("unknown annotation type: " + outer);
}
}
代码示例来源:origin: org.eclipse/org.eclipse.jpt.core
protected void removeElement(Annotation annotation, ModifiedDeclaration declaration) {
if (annotation == null) {
this.removeElementNoAnnotation(declaration);
}
else if (annotation.isMarkerAnnotation()) {
this.removeElementMarkerAnnotation((MarkerAnnotation) annotation, declaration);
}
else if (annotation.isSingleMemberAnnotation()) {
this.removeElementSingleMemberAnnotation((SingleMemberAnnotation) annotation, declaration);
}
else if (annotation.isNormalAnnotation()) {
this.removeElementNormalAnnotation((NormalAnnotation) annotation, declaration);
}
else {
throw new IllegalArgumentException("unknown annotation type: " + annotation);
}
}
代码示例来源:origin: org.eclipse/org.eclipse.jpt.core
/**
* When there is only a single element in an array initializer, convert the
* expression to be just the single element; e.g.
* <pre>
* @Foo(xxx={"abc"}) => @Foo(xxx="abc")
* or
* @Foo({"abc"}) => @Foo("abc")
* </pre>
*/
private void convertArrayToLastRemainingExpression(Annotation outer, Expression lastValue) {
lastValue = (Expression) ASTNode.copySubtree(lastValue.getAST(), lastValue);
if (outer.isNormalAnnotation()) {
this.memberValuePair((NormalAnnotation) outer).setValue(lastValue);
} else if (outer.isSingleMemberAnnotation()) {
((SingleMemberAnnotation) outer).setValue(lastValue);
} else {
throw new IllegalArgumentException("unexpected annotation type: " + outer);
}
}
代码示例来源:origin: org.eclipse/org.eclipse.jpt.core
/**
* Return the expression value of the *first* annotation element
* with the adapter's element name.
* Return null if the annotation has no such element.
* (An element name of "value" will return the value of a single
* member annotation.)
*/
protected E expression(Annotation annotation) {
if (annotation == null) {
return this.expressionNoAnnotation();
}
if (annotation.isMarkerAnnotation()) {
return this.expressionMarkerAnnotation((MarkerAnnotation) annotation);
}
if (annotation.isSingleMemberAnnotation()) {
return this.expressionSingleMemberAnnotation((SingleMemberAnnotation) annotation);
}
if (annotation.isNormalAnnotation()) {
return this.expressionNormalAnnotation((NormalAnnotation) annotation);
}
throw new IllegalArgumentException("unknown annotation type: " + annotation);
}
代码示例来源:origin: org.eclipse/org.eclipse.jpt.core
@Override
protected void addAnnotation(ModifiedDeclaration declaration, Annotation inner) {
Annotation outer = this.outerAnnotationAdapter.getAnnotation(declaration);
if (outer == null) {
this.buildNewOuterAnnotation(declaration, inner);
} else if (outer.isMarkerAnnotation()) {
this.modifyAnnotation(declaration, (MarkerAnnotation) outer, inner);
} else if (outer.isSingleMemberAnnotation()) {
this.modifyAnnotation(declaration, (SingleMemberAnnotation) outer, inner);
} else if (outer.isNormalAnnotation()) {
this.modifyAnnotation(declaration, (NormalAnnotation) outer, inner);
} else {
throw new IllegalStateException("unknown annotation type: " + outer);
}
}
代码示例来源:origin: forge/roaster
public AnnotationSource<O> removeValue(final String name)
if (annotation.isNormalAnnotation())
代码示例来源:origin: org.jboss.forge/roaster-jdt
public AnnotationSource<O> removeValue(final String name)
if (annotation.isNormalAnnotation())
代码示例来源:origin: org.eclipse/org.eclipse.jpt.core
/**
* set non-null, non-empty value
*/
protected void setValue(Expression value, Annotation annotation, ModifiedDeclaration declaration) {
if (value == null) {
this.removeElement(annotation, declaration);
}
else if (annotation == null) {
this.setValueNoAnnotation(value, declaration);
}
else if (annotation.isMarkerAnnotation()) {
this.setValueMarkerAnnotation(value, (MarkerAnnotation) annotation, declaration);
}
else if (annotation.isSingleMemberAnnotation()) {
this.setValueSingleMemberAnnotation(value, (SingleMemberAnnotation) annotation, declaration);
}
else if (annotation.isNormalAnnotation()) {
this.setValueNormalAnnotation(value, (NormalAnnotation) annotation, declaration);
}
else {
throw new IllegalArgumentException("unknown annotation type: " + annotation);
}
}
代码示例来源:origin: ModeShape/modeshape
ClassFileSequencerLexicon.AnnotationType.MARKER.toString());
LOGGER.debug("Marker annotation {0} created", name);
} else if (annotation.isNormalAnnotation()) {
annotationNode.setProperty(ClassFileSequencerLexicon.ANNOTATION_TYPE,
ClassFileSequencerLexicon.AnnotationType.NORMAL.toString());
代码示例来源:origin: org.modeshape/modeshape-sequencer-java
ClassFileSequencerLexicon.AnnotationType.MARKER.toString());
LOGGER.debug("Marker annotation {0} created", name);
} else if (annotation.isNormalAnnotation()) {
annotationNode.setProperty(ClassFileSequencerLexicon.ANNOTATION_TYPE,
ClassFileSequencerLexicon.AnnotationType.NORMAL.toString());
代码示例来源:origin: org.eclipse/org.eclipse.jpt.core
if (containerAnnotation.isNormalAnnotation()) {
NormalAnnotation na = (NormalAnnotation) containerAnnotation;
if (na.values().size() == 0) {
代码示例来源:origin: org.eclipse/org.eclipse.jpt.core
/**
* move the annotation in the container annotation at index=0
* to the stand-alone annotation
*/
private void convertLastElementAnnotationToStandAloneAnnotation(ModifiedDeclaration declaration) {
Annotation last = this.zeroNestedAnnotationAdapter.getAnnotation(declaration);
if (last == null) {
throw new IllegalStateException("the last nested annotation is missing");
} else if (last.isMarkerAnnotation()) {
this.newStandAloneMarkerAnnotation(declaration);
} else if (last.isSingleMemberAnnotation()) {
Expression vv = ((SingleMemberAnnotation) last).getValue();
vv = (Expression) ASTNode.copySubtree(vv.getAST(), vv);
this.newStandAloneSingleMemberAnnotation(declaration).setValue(vv);
} else if (last.isNormalAnnotation()) {
NormalAnnotation newNA = this.newStandAloneNormalAnnotation(declaration);
List<MemberValuePair> values = this.values(newNA);
for (MemberValuePair pair : this.values((NormalAnnotation) last)) {
values.add((MemberValuePair) ASTNode.copySubtree(pair.getAST(), pair));
}
} else {
throw new IllegalStateException("unknown annotation type: " + last);
}
this.zeroNestedAnnotationAdapter.removeAnnotation(declaration);
}
代码示例来源:origin: org.eclipse/org.eclipse.jpt.core
/**
* move the specified, non-null, stand-alone annotation to
* the container annotation at index=0
*/
private void moveStandAloneAnnotationToContainerAnnotation(Annotation standAloneAnnotation, ModifiedDeclaration declaration) {
if (standAloneAnnotation.isMarkerAnnotation()) {
this.zeroNestedAnnotationAdapter.newMarkerAnnotation(declaration);
} else if (standAloneAnnotation.isSingleMemberAnnotation()) {
Expression vv = ((SingleMemberAnnotation) standAloneAnnotation).getValue();
vv = (Expression) ASTNode.copySubtree(vv.getAST(), vv);
this.zeroNestedAnnotationAdapter.newSingleMemberAnnotation(declaration).setValue(vv);
} else if (standAloneAnnotation.isNormalAnnotation()) {
NormalAnnotation newNA = this.zeroNestedAnnotationAdapter.newNormalAnnotation(declaration);
List<MemberValuePair> values = this.values(newNA);
for (MemberValuePair pair : this.values((NormalAnnotation) standAloneAnnotation)) {
values.add((MemberValuePair) ASTNode.copySubtree(pair.getAST(), pair));
}
} else {
throw new IllegalStateException("unknown annotation type: " + standAloneAnnotation);
}
this.removeStandAloneAnnotation(declaration);
}
内容来源于网络,如有侵权,请联系作者删除!