com.atlassian.fugue.Option.fold()方法的使用及代码示例

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

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

Option.fold介绍

暂无

代码示例

代码示例来源:origin: com.atlassian.jira/jira-core

private File delegateToFileStoreOrThrowException(final Function<FileBasedAttachmentStore, File> delegateToFileStore)
{
  return fileSystemAttachmentStore.fold(new Supplier<File>()
  {
    @Override
    public File get()
    {
      throw new UnsupportedOperationException("Direct operations on file system are not supported.");
    }
  }, delegateToFileStore);
}

代码示例来源:origin: com.atlassian.jira/jira-core

@Override
public Option<String> getIssuePageEditHtml(final Map<String, Object> context)
{
  return resources.get(TEMPLATE_NAME_ISSUE_EDIT).fold(emptySupplier, new RenderCommentPanelFunction(context));
}

代码示例来源:origin: com.atlassian.jira/jira-core

@Override
public Option<String> getFieldViewHtml(final Map<String, Object> context)
{
  return resources.get(TEMPLATE_NAME_VIEW).fold(emptySupplier, new RenderCommentPanelFunction(context));
}

代码示例来源:origin: com.atlassian.jira/jira-core

@Override
public Option<String> getIssuePageViewHtml(final Map<String, Object> context)
{
  return resources.get(TEMPLATE_NAME_ISSUE_VIEW).fold(emptySupplier, new RenderCommentPanelFunction(context));
}

代码示例来源:origin: com.atlassian.jira/jira-core

@Override
public Option<String> getFieldEditHtml(final Map<String, Object> context)
{
  return resources.get(TEMPLATE_NAME_EDIT).fold(emptySupplier, new RenderCommentPanelFunction(context));
}

代码示例来源:origin: com.atlassian.jira/jira-postsetup-announcements-plugin

private Boolean isAdmin(final Option<ApplicationUser> userOption)
  {
    return userOption.fold(Suppliers.alwaysFalse(), new Function<ApplicationUser, Boolean>()
    {
      @Override
      public Boolean apply(final ApplicationUser user)
      {
        final boolean isAdmin = permissionManager.hasPermission(GlobalPermissionKey.ADMINISTER, user);
        return isAdmin;
      }
    });
  }
}

代码示例来源:origin: com.atlassian.jira/jira-postsetup-announcements-plugin

@Override
  public Boolean apply(final ApplicationUser user)
  {
    return instantSetupUser.fold(Suppliers.alwaysFalse(), new Function<String, Boolean>()
    {
      @Override
      public Boolean apply(final String input)
      {
        return user.getKey().equals(input);
      }
    });
  }
});

代码示例来源:origin: com.atlassian.plugins/atlassian-connect-server-integration-tests-support

public void clickRemotePluginLinkWithoutBinding() {
  link.get().fold(
      () -> {
        throw new IllegalStateException(format("Could not find link '%s'", link()));
      },
      actualLink -> {
        actualLink.click();
        logger.debug("Link '{}' was found and clicked.", actualLink);
        return null;
      }
  );
}

代码示例来源:origin: com.atlassian.plugins/atlassian-connect-server-integration-tests-support

public String getRemotePluginLinkHref() {
  return link.get().fold(
      () -> {
        throw new IllegalStateException(format("Could not find link '%s'", link()));
      },
      actualLink -> actualLink.getAttribute("href")
  );
}

代码示例来源:origin: com.atlassian.jira/jira-core

@Override
public Promise<Unit> deleteAttachmentContainerForIssue(@Nonnull final Issue issue)
{
  //noinspection NullableProblems
  return fileSystemAttachmentStore.fold(Suppliers.ofInstance(Promises.promise(Unit.VALUE)),
      new Function<FileBasedAttachmentStore, Promise<Unit>>()
  {
    @Override
    public Promise<Unit> apply(final FileBasedAttachmentStore fileBasedAttachmentStore)
    {
      return fileBasedAttachmentStore.deleteAttachmentContainerForIssue(issue);
    }
  });
}

代码示例来源:origin: com.atlassian.jira/jira-core

@Override
  protected int getCount(final Map<String, Object> context)
  {
    return WorkflowTransitionContext.getTransition(context).fold(Suppliers.ofInstance(0), new Function<ActionDescriptor, Integer>()
    {
      @Override
      public Integer apply(final ActionDescriptor input)
      {
        return input.getValidators() == null ? 0 : input.getValidators().size();
      }
    });
  }
}

代码示例来源:origin: com.atlassian.jira/jira-core

@Override
  protected int getCount(final Map<String, Object> context)
  {
    return WorkflowTransitionContext.getTransition(context).fold(Suppliers.ofInstance(0), new Function<ActionDescriptor, Integer>()
    {
      @Override
      public Integer apply(final ActionDescriptor input)
      {
        final ResultDescriptor result = input.getUnconditionalResult();
        return result != null && result.getPostFunctions() != null ? result.getPostFunctions().size() : 0 ;
      }
    });
  }
}

代码示例来源:origin: com.atlassian.jira/jira-core

@Override
public boolean removePermission(final int permissionId, final String group)
{
  // When roles enabled, passing USE as a permission is unsupported; roles should be used
  ensureUsePermissionNotUsedIfRolesEnabled(permissionId);
  return getGlobalPermission(permissionId).fold(() -> {
        throw new IllegalArgumentException("Permission id passed must be a global permission, " + permissionId + " is not");
      },
      globalPermissionType -> removePermission(globalPermissionType, group)
  );
}

代码示例来源:origin: com.atlassian.jira/jira-core

public String getPermTypeName()
{
  return globalPermissionManager.getGlobalPermission(globalPermTypeName).fold(
      returnUnknownString,
      globalPermissionType -> getText(globalPermissionType.getNameI18nKey())
  );
}

代码示例来源:origin: com.atlassian.jira/jira-core

public String getDescription(String permType)
{
  return globalPermissionManager.getGlobalPermission(permType).fold(
      returnUnknownString,
      globalPermissionType -> getText(globalPermissionType.getDescriptionI18nKey())
  );
}

代码示例来源:origin: com.atlassian.jira/jira-core

@Override
public ServiceOutcome<IssueSecurityLevelScheme> getIssueSecurityLevelScheme(ApplicationUser user, final long schemeId)
{
  return asAdminOrProjectAdminWithAccessToScheme(user, schemeId, () -> {
    Supplier<ServiceOutcome<IssueSecurityLevelScheme>> notFoundSupplier =
        notFoundSupplier("rest.error.issuesecurityscheme.securityscheme.not.found", String.valueOf(schemeId));
    return Option.option(issueSecuritySchemeManager.getIssueSecurityLevelScheme(schemeId))
        .fold(notFoundSupplier, IssueSecuritySchemeServiceImpl.<IssueSecurityLevelScheme>okOutcome());
  });
}

代码示例来源:origin: com.atlassian.jira/jira-core

@Override
public ServiceOutcome<IssueSecurityLevel> getIssueSecurityLevel(ApplicationUser user, final long securityLevelId)
{
  return asAdmin(user, () -> {
    Supplier<ServiceOutcome<IssueSecurityLevel>> notFoundSupplier =
        notFoundSupplier("rest.error.issuesecurityscheme.securitylevel.not.found", String.valueOf(securityLevelId));
    return Option.option(issueSecurityLevelManager.getSecurityLevel(securityLevelId))
        .fold(notFoundSupplier, IssueSecuritySchemeServiceImpl.<IssueSecurityLevel>okOutcome());
  });
}

代码示例来源:origin: com.atlassian.jira/jira-core

@Override
public ServiceOutcome<? extends List<IssueSecurityLevel>> getIssueSecurityLevels(ApplicationUser user, final long schemeId)
{
  return asAdminOrProjectAdminWithAccessToScheme(user, schemeId, () -> {
    Supplier<ServiceOutcome<List<IssueSecurityLevel>>> notFoundSupplier =
        notFoundSupplier("rest.error.issuesecurityscheme.securityscheme.not.found", String.valueOf(schemeId));
    return Option.option(issueSecuritySchemeManager.getIssueSecurityLevelScheme(schemeId))
        .fold(notFoundSupplier, securityLevelScheme -> ServiceOutcomeImpl.ok(issueSecurityLevelManager.getIssueSecurityLevels(schemeId)));
  });
}

代码示例来源:origin: com.atlassian.jira/jira-core

@Override
public ServiceOutcome<? extends Collection<IssueSecurityLevelPermission>> getPermissionsByIssueSecurityLevel(ApplicationUser user, final long securityLevelId)
{
  return asAdmin(user, () -> {
    Supplier<ServiceOutcome<Collection<IssueSecurityLevelPermission>>> notFoundSupplier =
        notFoundSupplier("rest.error.issuesecurityscheme.securitylevel.not.found", String.valueOf(securityLevelId));
    return Option.option(issueSecurityLevelManager.getSecurityLevel(securityLevelId))
        .fold(notFoundSupplier, issueSecurityLevel -> {
          Collection<IssueSecurityLevelPermission> collection = issueSecuritySchemeManager.getPermissionsBySecurityLevel(securityLevelId);
          return ServiceOutcomeImpl.ok(collection);
        });
  });
}

代码示例来源:origin: com.atlassian.jira/jira-core

private ServiceOutcome<IssueSecurityLevelScheme> getIssueSecurityLevelSchemeForProject(final ApplicationUser user, final Either<Long, String> projectIdOrKey)
{
  Supplier<ServiceOutcome<IssueSecurityLevelScheme>> notFoundSupplier =
      notFoundSupplier("rest.error.issuesecurityscheme.securitylevel.for.project.not.found", projectIdOrKey.fold(l -> l.toString(), String::toString));
  return asAdminOrProjectAdminWithAdminAccessToProject(user, projectIdOrKey, project -> {
    final Long schemeIdForProject = issueSecuritySchemeManager.getSchemeIdFor(project);
    final IssueSecurityLevelScheme issueSecurityLevelScheme = issueSecuritySchemeManager.getIssueSecurityLevelScheme(schemeIdForProject);
    return Option.option(issueSecurityLevelScheme)
        .fold(notFoundSupplier, IssueSecuritySchemeServiceImpl.okOutcome());
  });
}

相关文章