本文整理了Java中com.atlassian.fugue.Option.getOrElse()
方法的一些代码示例,展示了Option.getOrElse()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Option.getOrElse()
方法的具体详情如下:
包路径:com.atlassian.fugue.Option
类名称:Option
方法名:getOrElse
暂无
代码示例来源:origin: com.atlassian.jira/jira-core
private Iterable<WebPanelModuleDescriptor> getDisplayableWebPanelDescriptors(final Map<String, Object> context)
{
return Iterables.filter(SafePluginPointAccess.call(new Callable<List<WebPanelModuleDescriptor>>()
{
@Override
public List<WebPanelModuleDescriptor> call() throws Exception
{
return webInterfaceManager.getDisplayableWebPanelDescriptors(TAB_PANELS_LOCATION, context);
}
}).getOrElse(Collections.<WebPanelModuleDescriptor>emptyList()), Predicates.notNull());
}
}
代码示例来源:origin: com.atlassian.jira/jira-core
private String getSupplierValueOrHtmlErrorMessage(final Callable<String> callable)
{
final Supplier<String> errorMessageSupplier = new Supplier<String>()
{
@Override
public String get()
{
return getHtmlErrorMessage();
}
};
return SafePluginPointAccess.call(callable).getOrElse(errorMessageSupplier);
}
代码示例来源:origin: com.atlassian.jira/jira-tests
@Override
public String getUserCountDescription(final Option<Integer> count)
{
final Supplier<String> unlimited = () -> String.format("Unlimited %s users", key);
return count.map(c -> String.format("%d %s users", c, key)).getOrElse(unlimited);
}
代码示例来源:origin: com.atlassian.jira/jira-core
public List<QueryLiteral> getValues(final QueryCreationContext queryCreationContext, final FunctionOperand operand, final TerminalClause terminalClause)
{
return SafePluginPointAccess.call(new Callable<List<QueryLiteral>>()
{
@Override
public List<QueryLiteral> call() throws Exception
{
return jqlFunction.getValues(queryCreationContext, operand, terminalClause);
}
}).getOrElse(Collections.<QueryLiteral>emptyList());
}
代码示例来源:origin: com.atlassian.jira/jira-core
public boolean isList()
{
return SafePluginPointAccess.call(new Callable<Boolean>()
{
@Override
public Boolean call() throws Exception
{
return jqlFunction.isList();
}
}).getOrElse(false);
}
代码示例来源:origin: com.atlassian.jira/jira-core
@Nonnull
public List<SimpleLinkSection> getSectionsForLocation(@Nonnull final String location, final ApplicationUser remoteUser, @Nonnull final JiraHelper jiraHelper)
{
final Iterable<WebSection> sections = SafePluginPointAccess.call(() -> webInterfaceManager.getDisplayableWebSections(location, makeContext(remoteUser, jiraHelper))).getOrElse(Collections.emptyList());
final List<SimpleLinkSection> returnSections = new ArrayList<SimpleLinkSection>(Iterables.size(sections));
for (final WebSection section : sections)
{
returnSections.add(convertWebSectionToSimpleLinkSection(section));
}
return returnSections;
}
代码示例来源:origin: com.atlassian.jira/jira-core
@Nonnull
@Override
public Set<Group> getDefaultGroups(@Nonnull final ApplicationKey key)
{
notNull("key", key);
return getRole(key).map(ApplicationRole::getDefaultGroups).getOrElse(ImmutableSet.of());
}
代码示例来源:origin: com.atlassian.jira/jira-api
/**
* Generate a localised message for this exception.
* @param localisedMessages Internationalisation helper that can provide localised messages for given codes.
* @return a localised message for this exception
*/
public final String generateMessage(final I18nHelper localisedMessages)
{
Option<String> generatedMessage = doGenerateMessage(localisedMessages);
return generatedMessage.getOrElse(this.getMessage());
}
代码示例来源:origin: com.atlassian.jira/jira-core
@Override
public Clause visit(final TerminalClause clause)
{
return queryRegistry.getClauseQueryFactory(queryCreationContext, clause).map(new Function<WorklogClauseQueryFactory, Clause>()
{
@Override
public Clause apply(final WorklogClauseQueryFactory input)
{
return toIssueSet(input.getWorklogQuery(queryCreationContext, clause));
}
}).getOrElse(clause);
}
代码示例来源:origin: com.atlassian.jira/jira-core
@Nonnull
public List<SimpleLink> getLinksForSectionIgnoreConditions(@Nonnull final String section, final ApplicationUser remoteUser, @Nonnull final JiraHelper jiraHelper)
{
return SafePluginPointAccess.call(() -> getLinks(section, webInterfaceManager.getWebItems(section, makeContext(remoteUser, jiraHelper)), remoteUser, jiraHelper, false)).getOrElse(Collections.emptyList());
}
代码示例来源:origin: com.atlassian.jira/jira-core
@Override
public void apply(final Comment comment)
{
commentManager.update(comment, validationResult.getCommentProperties().getOrElse(Collections.EMPTY_MAP), dispatchEvent);
}
});
代码示例来源:origin: com.atlassian.jira/jira-core
@Override
public String getUserCountDescription(final Option<Integer> count)
{
return ctx.getI18nHelper().getText("jira.core.user.count", count.getOrElse(-1));
}
代码示例来源:origin: com.atlassian.jira/jira-api
public boolean shouldDisplay(final Map<String, Object> context)
{
final JiraHelper jiraHelper = (JiraHelper) context.get(JiraWebInterfaceManager.CONTEXT_KEY_HELPER);
final ApplicationUser appUser = getApplicationUser(context);
return SafePluginPointAccess.call(() -> shouldDisplay(appUser, jiraHelper)).getOrElse(false);
}
代码示例来源:origin: com.atlassian.jira/jira-core
private String renderPanel(final String location, final ImmutableMap<String, Object> context)
{
return SafePluginPointAccess.call(() -> {
final List<WebPanel> panels = dynamicWebInterfaceManager.getDisplayableWebPanels(location, ImmutableMap.of());
return SafePluginPointAccess.to()
.modules(panels, (PluginPointFunction<ModuleDescriptor<WebPanel>, WebPanel, String>) (descriptor, webPanel) -> webPanel.getHtml(context))
.stream().collect(Collectors.joining());
}).getOrElse("");
}
}
代码示例来源:origin: com.atlassian.jira/jira-core
private Either<IOException, Option<Properties>> tryLoadProperties(final Supplier<Option<InputStream>> resourceSupplier)
{
final Option<InputStream> streamOption = resourceSupplier.get();
final Supplier<Either<IOException, Option<Properties>>> emptyPropertiesSupplier =
() -> Either.<IOException, Option<Properties>>right(Option.none());
return streamOption.map(this::tryLoadProperties).
getOrElse(emptyPropertiesSupplier);
}
代码示例来源:origin: com.atlassian.jira/jira-core
private String getApplicationDisplayName(final ApplicationKey applicationKey)
{
return applicationManager.getApplication(applicationKey).map(Application::getName)
.getOrElse(applicationRoleManager.getRole(applicationKey).map(ApplicationRole::getName)
.getOrElse(applicationKey.toString()));
}
代码示例来源:origin: com.atlassian.jira/jira-core
public static String getSchemaName()
{
// DatabaseConfigurationManager.getDatabaseConfiguration() will throw a RuntimeException if you call it before
// we have a configured DB config (i.e on a fresh install before DB Setup).
// Once it actually returns successfully, the schema name will not change.
if (schemaName == null)
{
schemaName = Option.option(ComponentAccessor.getComponent(DatabaseConfigurationService.class).getSchemaName());
}
return schemaName.getOrElse("");
}
}
代码示例来源:origin: com.atlassian.jira/jira-core
private Map<Object, Object> getSalDarkFeatures()
{
final String salDarkFeaturesProperty = jiraSystemProperties.getProperty(
DARKFEATURES_PROPERTIES_FILE_PROPERTY, DARKFEATURES_PROPERTIES_FILE_PROPERTY_DEFAULT);
final Supplier<Properties> emptyProperties = Properties::new;
return tryLoadProperties(() -> resourceLoader.getResourceAsStream(salDarkFeaturesProperty))
.fold(ex -> emptyMap(),
(Option<Properties> propertiesOption) -> propertiesOption.getOrElse(emptyProperties));
}
代码示例来源:origin: com.atlassian.jira/jira-core
private String getDefaultGroupName(final ApplicationKey applicationKey)
{
return toGroupName(applicationManager.getApplication(applicationKey).map(Application::getDefaultGroup)
.getOrElse((Supplier<String>) () -> String.format("%s-users", applicationKey.value())));
}
代码示例来源:origin: com.atlassian.jira/jira-core
public Hint get(final WebItem input)
{
final Option<String> label = option(input.getLabel());
if(label.isEmpty())
{
log.warn("Hint web item with key '" + input.getCompleteKey() + "' does not define a label");
}
return new HintImpl(label.getOrElse(""), input.getTitle());
}
});
内容来源于网络,如有侵权,请联系作者删除!