當前位置: 首頁>>代碼示例>>Java>>正文


Java ClassOrInterfaceDeclaration.setMembers方法代碼示例

本文整理匯總了Java中com.github.javaparser.ast.body.ClassOrInterfaceDeclaration.setMembers方法的典型用法代碼示例。如果您正苦於以下問題:Java ClassOrInterfaceDeclaration.setMembers方法的具體用法?Java ClassOrInterfaceDeclaration.setMembers怎麽用?Java ClassOrInterfaceDeclaration.setMembers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.github.javaparser.ast.body.ClassOrInterfaceDeclaration的用法示例。


在下文中一共展示了ClassOrInterfaceDeclaration.setMembers方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doMerge

import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; //導入方法依賴的package包/類
@Override
public ClassOrInterfaceDeclaration doMerge(ClassOrInterfaceDeclaration first, ClassOrInterfaceDeclaration second) {

  ClassOrInterfaceDeclaration declaration = new ClassOrInterfaceDeclaration();

  declaration.setInterface(first.isInterface());
  declaration.setName(first.getName());

  declaration.setModifiers(mergeModifiers(first.getModifiers(), second.getModifiers()));
  declaration.setJavaDoc(mergeSingle(first.getJavaDoc(), second.getJavaDoc()));
  declaration.setTypeParameters(mergeCollections(first.getTypeParameters(), second.getTypeParameters()));

  declaration.setImplements(mergeCollections(first.getImplements(), second.getImplements()));
  declaration.setExtends(mergeCollections(first.getExtends(), second.getExtends()));

  declaration.setAnnotations(mergeCollections(first.getAnnotations(), second.getAnnotations()));
  declaration.setMembers(mergeCollections(first.getMembers(), second.getMembers()));

  return declaration;
}
 
開發者ID:beihaifeiwu,項目名稱:dolphin,代碼行數:21,代碼來源:ClassOrInterfaceDeclarationMerger.java

示例2: getClassDeclaration

import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; //導入方法依賴的package包/類
/**
 * Generates the class definition for the Operation
 */
private ClassOrInterfaceDeclaration getClassDeclaration() {
  ClassOrInterfaceDeclaration operation = new ClassOrInterfaceDeclaration(ModifierSet.PUBLIC,
      false, getOperationClassName());
  operation.setImplements(Collections.singletonList(iOperation));
  operation.setJavaDoc(javadocComment);
  operation.setComment(new BlockComment(
      " * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n"
          + " * ===== THIS CODE HAS BEEN DYNAMICALLY GENERATED! DO NOT MODIFY! ==== *\n"
          + " * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * "));
  operation.setMembers(socketHintDeclarationCollection
      .getAllSocketHints()
      .stream()
      .map(SocketHintDeclaration::getDeclaration)
      .filter(declaration -> declaration != null)
      .collect(Collectors.toList()));
  ASTHelper.addMember(operation, getNameMethod());
  ASTHelper.addMember(operation, getDescriptionMethod());
  ASTHelper.addMember(operation, getCategoryMethod());
  ASTHelper.addMember(operation, getCreateInputSocketsMethod());
  ASTHelper.addMember(operation, getCreateOutputSocketsMethod());
  ASTHelper.addMember(operation, getPerformMethod());
  return operation;
}
 
開發者ID:WPIRoboticsProjects,項目名稱:GRIP,代碼行數:27,代碼來源:Operation.java

示例3: getClassDeclaration

import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; //導入方法依賴的package包/類
private ClassOrInterfaceDeclaration getClassDeclaration() {
  final ClassOrInterfaceType eventBusType = new ClassOrInterfaceType("EventBus");
  final ClassOrInterfaceType eventType = new ClassOrInterfaceType("OperationAddedEvent");

  // This method is how the generated code tells the rest of the application about all of the
  // generated OpenCV
  // operations. It sends an OperationAddedEvent with a new instance of every operation.
  final MethodDeclaration addOperations = new MethodDeclaration(ModifierSet.PUBLIC |
      ModifierSet.STATIC,
      new VoidType(), "addOperations");

  ASTHelper.addParameter(addOperations, ASTHelper.createParameter(eventBusType, "eventBus"));

  addOperations.setBody(new BlockStmt(this.operations.stream()
      .sorted((o1, o2) -> o1.getOperationClassName().toLowerCase().compareToIgnoreCase(o2
          .getOperationClassName()))
      .map(Operation::getOperationClassName)
      .map(ClassOrInterfaceType::new)
      // Create a new instance of each operation
      .map(type -> new ObjectCreationExpr(null, type, null))
      // Create a new OperationAddedEvent for every operation
      .map(expr -> new ObjectCreationExpr(null, eventType, Collections.singletonList(expr)))
      // Post all of the events to the event bus
      .map(expr -> new MethodCallExpr(new NameExpr("eventBus"), "post", Collections
          .singletonList(expr)))
      .map(ExpressionStmt::new)
      .collect(Collectors.toList())));

  final ClassOrInterfaceDeclaration cvoperations = new ClassOrInterfaceDeclaration(ModifierSet
      .PUBLIC, false,
      "CVOperations");
  cvoperations.setMembers(Collections.singletonList(addOperations));
  return cvoperations;
}
 
開發者ID:WPIRoboticsProjects,項目名稱:GRIP,代碼行數:35,代碼來源:OperationList.java

示例4: visit

import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; //導入方法依賴的package包/類
@Override
  public Node visit(final ClassOrInterfaceDeclaration n, final Object arg) {

      if (!(n.isInterface())) {

          // Preserve the value of flag indicating that enclosing class
          // has found the default constructor.
          boolean storedprev = founddefault;
          founddefault = false;

          // Generates a new list, which might even be empty.
          Vector<BodyDeclaration> lnewlist = new Vector<BodyDeclaration>();

/* Code for unfolding field declaration */
          if (n.getMembers() != null) {
              for (final BodyDeclaration b : n.getMembers()) {
                  BodyDeclaration mydecl = (BodyDeclaration) b.accept(this, arg);

                  // Append the expanded list to list of bodydeclaration
                  if (mydecl instanceof ListFieldDeclaration) {
                      lnewlist.addAll(((ListFieldDeclaration) mydecl).getVarDecls());
                  } else {
                      lnewlist.add(mydecl);
                  }
              }
          }

/*
        Code for detecting declaration of default contructor.
 Clone metadata from class declaration.
 */
          if (!(founddefault)) {
              lnewlist.add(new ConstructorDeclaration(n.getModifiers(),
                      new Vector<AnnotationExpr>(),
                      new Vector<TypeParameter>(),
                      n.getName(),
                      new Vector<Parameter>(),
                      new Vector<NameExpr>(),
                      new BlockStmt(new Vector<Statement>())));
          }

          // Restore the value for the flag relative to enclosing class
          founddefault = storedprev;

          // Set the generated list
          n.setMembers(lnewlist);
      }

      return n;
  }
 
開發者ID:pcgomes,項目名稱:javaparser2jctree,代碼行數:51,代碼來源:ComplyToJCVisitor.java


注:本文中的com.github.javaparser.ast.body.ClassOrInterfaceDeclaration.setMembers方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。