org.eclipse.jdt.core.dom.Annotation.isSingleMemberAnnotation()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(95)

本文整理了Java中org.eclipse.jdt.core.dom.Annotation.isSingleMemberAnnotation()方法的一些代码示例,展示了Annotation.isSingleMemberAnnotation()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Annotation.isSingleMemberAnnotation()方法的具体详情如下:
包路径:org.eclipse.jdt.core.dom.Annotation
类名称:Annotation
方法名:isSingleMemberAnnotation

Annotation.isSingleMemberAnnotation介绍

[英]Returns whether this is a single member annotation. ( SingleMemberAnnotation).
[中]返回此注释是否为单成员注释。(单成员注释)。

代码示例

代码示例来源:origin: org.projectlombok/lombok

if (annotation.isSingleMemberAnnotation()) {
  org.eclipse.jdt.core.dom.SingleMemberAnnotation smAnn = (org.eclipse.jdt.core.dom.SingleMemberAnnotation) annotation;
  values.add(smAnn.getValue().toString());

代码示例来源:origin: org.jboss.forge/roaster-jdt

@Override
public boolean isSingleValue()
{
 return annotation.isSingleMemberAnnotation();
}

代码示例来源:origin: forge/roaster

@Override
public boolean isSingleValue()
{
 return annotation.isSingleMemberAnnotation();
}

代码示例来源: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>
 *     &#64;Foo(xxx={"abc"}) => &#64;Foo(xxx="abc")
 * or
 *     &#64;Foo({"abc"}) => &#64;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

else if (annotation.isSingleMemberAnnotation())

代码示例来源:origin: org.jboss.forge/roaster-jdt

else if (annotation.isSingleMemberAnnotation())

代码示例来源: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

} else if (annotation.isSingleMemberAnnotation()) {
  annotationNode.setProperty(ClassFileSequencerLexicon.ANNOTATION_TYPE,
                ClassFileSequencerLexicon.AnnotationType.SINGLE_MEMBER.toString());

代码示例来源:origin: org.modeshape/modeshape-sequencer-java

} else if (annotation.isSingleMemberAnnotation()) {
  annotationNode.setProperty(ClassFileSequencerLexicon.ANNOTATION_TYPE,
                ClassFileSequencerLexicon.AnnotationType.SINGLE_MEMBER.toString());

代码示例来源:origin: org.eclipse/org.eclipse.jpt.core

return false;
if (containerAnnotation.isSingleMemberAnnotation()) {
  if (this.elementName().equals("value")) {
    return (((SingleMemberAnnotation) containerAnnotation).getValue().getNodeType() != ASTNode.ARRAY_INITIALIZER)

代码示例来源: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);
}

相关文章