org.eclipse.uml2.uml.Operation.getOwnedComments()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(2.0k)|赞(0)|评价(0)|浏览(99)

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

Operation.getOwnedComments介绍

暂无

代码示例

代码示例来源:origin: crowdcode-de/KissMDA

/**
 * Generate Javadoc for UML Operation.
 * 
 * @param ast
 *            AST tree JDT
 * @param operation
 *            UML Operation - Method
 * @param md
 *            MethodDeclaration
 */
public void generateMethodJavadoc(AST ast, Operation operation,
    MethodDeclaration md) {
  EList<Comment> comments = operation.getOwnedComments();
  for (Comment comment : comments) {
    Javadoc javadoc = ast.newJavadoc();
    generateJavadoc(ast, comment, javadoc);
    md.setJavadoc(javadoc);
  }
}

代码示例来源:origin: crowdcode-de/KissMDA

@SuppressWarnings("unchecked")
@Test
public void testGenerateMethodJavadoc() {
  AST ast = AST.newAST(AST.JLS3);
  ast.newCompilationUnit();
  TypeDeclaration td = ast.newTypeDeclaration();
  td.setInterface(true);
  Modifier modifier = ast
      .newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD);
  td.modifiers().add(modifier);
  td.setName(ast.newSimpleName("Company"));
  MethodDeclaration md = ast.newMethodDeclaration();
  md.setName(ast.newSimpleName("calculateAge"));
  Operation operation = mock(Operation.class,
      Answers.RETURNS_DEEP_STUBS.get());
  EList<Comment> comments = mock(EList.class,
      Answers.RETURNS_DEEP_STUBS.get());
  Iterator<Comment> commentIterator = mock(Iterator.class);
  Comment comment = mock(Comment.class, Answers.RETURNS_DEEP_STUBS.get());
  when(operation.getOwnedComments()).thenReturn(comments);
  when(comments.iterator()).thenReturn(commentIterator);
  when(commentIterator.hasNext()).thenReturn(true, false);
  when(commentIterator.next()).thenReturn(comment);
  when(comment.getBody()).thenReturn(
      "Comment...\nTest\n@author: Lofi Dewanto");
  interfaceGenerator.generateMethodJavadoc(ast, operation, md);
  assertEquals(
      "/** \n * Comment...\n * Test\n * @author: Lofi Dewanto\n */\nvoid calculateAge();\n",
      md.toString());
}

相关文章