com.thoughtworks.go.api.base.OutputWriter.addChildList()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(58)

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

OutputWriter.addChildList介绍

暂无

代码示例

代码示例来源:origin: gocd/gocd

public static void toJSON(OutputWriter outputWriter, BulkUpdateUsersOperationResult result) {
    outputWriter.add("message", result.message());

    List<String> nonExistentUsers = result.getNonExistentUsers();
    List<String> enabledUsers = result.getEnabledUsers();

    if (!nonExistentUsers.isEmpty()) {
      outputWriter.addChildList("non_existent_users", nonExistentUsers);
    }

    if (!enabledUsers.isEmpty()) {
      outputWriter.addChildList("enabled_users", enabledUsers);
    }
  }
}

代码示例来源:origin: gocd/gocd

public static void toJSON(OutputWriter jsonWriter, AuthConfig authConfig) {
 if (!authConfig.errors().isEmpty()) {
  jsonWriter.addChild("errors", errorWriter -> {
   new ErrorGetter(new HashMap<>()).toJSON(errorWriter, authConfig);
  });
 }
 jsonWriter.addChildList("roles", authConfig.getRoles().stream().map(eachItem -> eachItem.getName().toString()).collect(Collectors.toList()));
 jsonWriter.addChildList("users", authConfig.getUsers().stream().map(eachItem -> eachItem.getName().toString()).collect(Collectors.toList()));
}

代码示例来源:origin: gocd/gocd

public static void toJSON(OutputWriter jsonWriter, AuthConfig authConfig) {
 if (!authConfig.errors().isEmpty()) {
  jsonWriter.addChild("errors", errorWriter -> {
   new ErrorGetter(new HashMap<>()).toJSON(errorWriter, authConfig);
  });
 }
 jsonWriter.addChildList("roles", authConfig.getRoles().stream().map(eachItem -> eachItem.getName().toString()).collect(Collectors.toList()));
 jsonWriter.addChildList("users", authConfig.getUsers().stream().map(eachItem -> eachItem.getName().toString()).collect(Collectors.toList()));
}

代码示例来源:origin: gocd/gocd

public static void toJSON(OutputWriter json, PreflightResult result) {
    json.addChildList("errors", result.getErrors());
    json.add("valid", result.isValid());
  }
}

代码示例来源:origin: gocd/gocd

public static void toJSON(OutputWriter jsonWriter, AbstractTask task) {
  jsonWriter.addChildList("run_if", task.getConditions().stream().map(RunIfConfig::toString).collect(Collectors.toList()));
  if (task.hasCancelTask()) {
    jsonWriter.addChild("on_cancel", attributeWriter -> OnCancelRepresenter.toJSON(attributeWriter, task.getOnCancelConfig()));
  }
}

代码示例来源:origin: gocd/gocd

public static void toJSON(OutputWriter jsonWriter, AbstractTask task) {
  jsonWriter.addChildList("run_if", task.getConditions().stream().map(RunIfConfig::toString).collect(Collectors.toList()));
  if (task.hasCancelTask()) {
    jsonWriter.addChild("on_cancel", attributeWriter -> OnCancelRepresenter.toJSON(attributeWriter, task.getOnCancelConfig()));
  }
}

代码示例来源:origin: gocd/gocd

public static void toJSON(OutputWriter json, List<ConfigRepoWithResult> repos) {
  attachLinks(json);
  json.addChild("_embedded", w -> w.addChildList(
      "config_repos", all -> repos.forEach(
          repo -> all.addChild(
              el -> ConfigRepoWithResultRepresenter.toJSON(el, repo)
          )
      )
  ));
}

代码示例来源:origin: gocd/gocd

public static void toJSONWithoutLinks(OutputWriter jsonWriter, AdminsConfig admin) {
  jsonWriter.addChildList("roles", rolesAsString(admin.getRoles()));
  jsonWriter.addChildList("users", userAsString(admin.getUsers()));
  if (admin.hasErrors()) {
    jsonWriter.addChild("errors", errorWriter -> new ErrorGetter(Collections.singletonMap("SystemAdmin", "system_admin"))
        .toJSON(errorWriter, admin));
  }
}

代码示例来源:origin: gocd/gocd

private static void writeStages(OutputWriter jsonWriter, PipelineConfig pipelineConfig) {
  if (pipelineConfig.getStages().isEmpty()) {
    jsonWriter.renderNull("stages");
  } else {
    jsonWriter.addChildList("stages", stagesWriter -> StageRepresenter.toJSONArray(stagesWriter, pipelineConfig));
  }
}

代码示例来源:origin: gocd/gocd

public static void toJSON(OutputWriter jsonWriter, AdminsConfig admin) {
  jsonWriter.addLinks(
      outputLinkWriter -> outputLinkWriter.addAbsoluteLink("doc", Routes.SystemAdmins.DOC)
          .addLink("self", Routes.SystemAdmins.BASE));
  jsonWriter.addChildList("roles", rolesAsString(admin.getRoles()));
  jsonWriter.addChildList("users", userAsString(admin.getUsers()));
  if (admin.hasErrors()) {
    jsonWriter.addChild("errors", errorWriter -> new ErrorGetter(Collections.singletonMap("SystemAdmin", "system_admin"))
        .toJSON(errorWriter, admin));
  }
}

代码示例来源:origin: gocd/gocd

public static void toJSON(OutputWriter json, ConfigReposConfig repos) {
  attachLinks(json);
  json.addChild("_embedded", w -> w.addChildList(
      "config_repos", all -> repos.forEach(
          repo -> all.addChild(el -> ConfigRepoConfigRepresenterV1.toJSON(el, repo))
      )
  ));
}

代码示例来源:origin: gocd/gocd

public static void toJSON(OutputWriter writer, List<Role> roles) {
    writer.addLinks(
      outputLinkWriter -> outputLinkWriter.addAbsoluteLink("doc", Routes.Roles.DOC)
        .addLink("find", Routes.Roles.find())
        .addLink("self", Routes.Roles.BASE))
      .addChild("_embedded", embeddedWriter -> embeddedWriter.addChildList("roles", rolesWriter -> roles.forEach(role -> rolesWriter.addChild(roleWriter -> RoleRepresenter.toJSON(roleWriter, role)))));
  }
}

代码示例来源:origin: gocd/gocd

public static void toJSON(OutputWriter jsonWriter, PluggableTask pluggableTask) {
  BaseTaskRepresenter.toJSON(jsonWriter, pluggableTask);
  jsonWriter.addChild("plugin_configuration", attributeWriter -> PluginConfigurationRepresenter.toJSON(attributeWriter, pluggableTask.getPluginConfiguration()));
  jsonWriter.addChildList("configuration", configurationWriter -> ConfigurationPropertyRepresenter.toJSON(configurationWriter, pluggableTask.getConfiguration()));
}

代码示例来源:origin: gocd/gocd

public static void toJSON(OutputWriter jsonWriter, PluggableTask pluggableTask) {
  BaseTaskRepresenter.toJSON(jsonWriter, pluggableTask);
  jsonWriter.addChild("plugin_configuration", attributeWriter -> PluginConfigurationRepresenter.toJSON(attributeWriter, pluggableTask.getPluginConfiguration()));
  jsonWriter.addChildList("configuration", configurationWriter -> ConfigurationPropertyRepresenter.toJSON(configurationWriter, pluggableTask.getConfiguration()));
}

代码示例来源:origin: gocd/gocd

public static void toJSON(OutputWriter jsonWriter, PluggableArtifactConfig pluggableArtifactConfig) {
  jsonWriter.add("artifact_id", pluggableArtifactConfig.getId());
  jsonWriter.add("store_id", pluggableArtifactConfig.getStoreId());
  jsonWriter.addChildList("configuration", configurationWriter -> ConfigurationPropertyRepresenter.toJSON(configurationWriter, pluggableArtifactConfig.getConfiguration()));
}

代码示例来源:origin: gocd/gocd

public static void toJSON(OutputWriter jsonOutputWriter, DashboardGroup model, Username username) {
  jsonOutputWriter
    .addLinks(linkWriterFor(model))
    .add("name", model.name())
    .addChildList("pipelines", model.pipelines())
    .add("can_administer", model.canAdminister(username));
}

代码示例来源:origin: gocd/gocd

public static void toJSON(OutputWriter jsonWriter, PipelineGroups pipelineGroups) {
  jsonWriter.addLinks(linksWriter -> linksWriter
      .addLink("self", Routes.PipelineGroupsAdmin.BASE)
      .addAbsoluteLink("doc", Routes.PipelineGroupsAdmin.DOC)
      .addLink("find", Routes.PipelineGroupsAdmin.find())
  );
  jsonWriter.addChild("_embedded", childWriter -> {
    childWriter.addChildList("groups", groupsWriter -> writePipelineGroups(groupsWriter, pipelineGroups));
  });
}

代码示例来源:origin: gocd/gocd

public static void toJSON(OutputWriter jsonOutputWriter, DashboardGroup model, Username username) {
  jsonOutputWriter
    .addLinks(linkWriterFor(model))
    .add("name", model.name())
    .addChildList("pipelines", model.pipelines())
    .add("can_administer", model.canAdminister(username));
}

代码示例来源:origin: gocd/gocd

public static void represent(OutputWriter childWriter, UserToRepresent user) {
  childWriter.add("login_name", user.getUsername().getUsername().toString())
      .add("display_name", user.getDisplayName())
      .add("enabled", user.isEnabled())
      .add("email", user.getEmail())
      .add("email_me", user.isEmailMe())
      .add("is_admin", user.isAdmin())
      .addChildList("roles", listWriter -> user.getRoles().forEach(role -> listWriter.addChild(propertyWriter -> RoleRepresenter.toJSON(propertyWriter, role))))
      .addChildList("checkin_aliases", user.getMatchers());
}

代码示例来源:origin: gocd/gocd

public static void toJSON(OutputWriter jsonOutputWriter, PipelineInstanceModel model) {
  jsonOutputWriter
    .addLinks(addLinks(model))
    .add("label", model.getLabel())
    .add("counter", model.getCounter())
    .add("triggered_by", model.getApprovedByForDisplay())
    .add("scheduled_at", model.getScheduledDate())
    .addChild("_embedded", childWriter -> {
      childWriter.addChildList("stages", getStages(model));
    });
}

相关文章