本文整理了Java中io.atlassian.fugue.Option.isEmpty()
方法的一些代码示例,展示了Option.isEmpty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Option.isEmpty()
方法的具体详情如下:
包路径:io.atlassian.fugue.Option
类名称:Option
方法名:isEmpty
暂无
代码示例来源:origin: io.atlassian.fugue/fugue-hamcrest
@Override protected boolean matchesSafely(Option<?> actual) {
return actual.isEmpty();
}
代码示例来源:origin: io.atlassian.fugue/fugue
/** {@inheritDoc} */
@Override public final boolean forall(final Predicate<? super A> p) {
requireNonNull(p);
return isEmpty() || p.test(get());
}
代码示例来源:origin: io.atlassian.fugue/fugue
/**
* Returns this {@link io.atlassian.fugue.Option} if it is nonempty
* <strong>and</strong> applying the predicate to this option's value returns
* true. Otherwise, return {@link #none()}.
*
* @param p the predicate to test
* @return this option, or none
*/
public final Option<A> filter(final Predicate<? super A> p) {
requireNonNull(p);
return (isEmpty() || p.test(get())) ? this : Option.<A> none();
}
代码示例来源:origin: com.atlassian.swagger/atlassian-swagger-doclet
/**
* Loads a class for the given name
*
* @param fqClassName the fully qualified class name
* @return the loaded class
*/
public static
@Nonnull
Option<Class<?>> loadClass(String fqClassName) {
fqClassName = twizzleClassName(fqClassName);
Option<Class<?>> loadedClass = loadClassWith(fqClassName, Thread.currentThread().getContextClassLoader());
if (loadedClass.isEmpty()) {
loadedClass = loadClassWith(fqClassName, MethodDoc.class.getClassLoader());
}
if (loadedClass.isEmpty()) {
loadedClass = loadClassWith(fqClassName, ReflectionKitClassLoader.loader());
}
if (loadedClass.isEmpty()) {
log.error(format("Unable to load class %s", fqClassName));
}
return loadedClass;
}
代码示例来源:origin: io.atlassian.fugue/fugue
/**
* Apply {@code f} to the value if defined.
* <p>
* Transforms to an option of the result type.
*
* @param <B> return type of {@code f}
* @param f function to apply to wrapped value
* @return new wrapped value
*/
public final <B> Option<B> map(final Function<? super A, ? extends B> f) {
requireNonNull(f);
return isEmpty() ? Option.<B> none() : new Some<>(f.apply(get()));
}
代码示例来源:origin: io.atlassian.fugue/fugue
/**
* Creates an Either from this Option. Puts the contained value in a left if
* {@link #isDefined()} otherwise puts the supplier's value in a right.
*
* @param <X> the right type
* @param right the Supplier to evaluate and return if this is empty
* @return the content of this option if defined as a left, or the supplier's
* content as a right if not defined.
* @see Option#toRight
*/
public final <X> Either<A, X> toLeft(final Supplier<X> right) {
return isEmpty() ? Either.<A, X> right(right.get()) : Either.<A, X> left(get());
}
代码示例来源:origin: io.atlassian.fugue/fugue
/**
* Creates an Either from this Option. Puts the contained value in a right if
* {@link #isDefined()} otherwise puts the supplier's value in a left.
*
* @param <X> the left type
* @param left the Supplier to evaluate and return if this is empty
* @return the content of this option if defined as a right, or the supplier's
* content as a left if not
* @see Option#toLeft
*/
public final <X> Either<X, A> toRight(final Supplier<X> left) {
return isEmpty() ? Either.<X, A> left(left.get()) : Either.<X, A> right(get());
}
代码示例来源:origin: com.atlassian.prettyurls/atlassian-pretty-urls-plugin
@Override
public RoutePredicate<UrlRouteRule> makeRulePredicate(final Element route) {
final Option<Condition> condition = makeCondition(route);
if (condition.isEmpty()) {
return RoutePredicates.alwaysTrue();
} else {
return new RoutePredicate<UrlRouteRule>() {
@Override
public boolean apply(final HttpServletRequest httpServletRequest, final UrlRouteRule routeRule) {
Map<String, Object> contextMap = Maps.newHashMap();
contextMap.put("request", httpServletRequest);
contextMap.put("route", routeRule);
return runCondition(condition, contextMap);
}
};
}
}
};
代码示例来源:origin: com.atlassian.prettyurls/atlassian-pretty-urls-plugin
@Override
public RoutePredicate<UrlRouteRuleSet> makeRuleSetPredicate(final Element routing) {
final Option<Condition> condition = makeCondition(routing);
if (condition.isEmpty()) {
return RoutePredicates.alwaysTrue();
} else {
return new RoutePredicate<UrlRouteRuleSet>() {
@Override
public boolean apply(final HttpServletRequest httpServletRequest, final UrlRouteRuleSet routeRuleSet) {
Map<String, Object> contextMap = Maps.newHashMap();
contextMap.put("request", httpServletRequest);
contextMap.put("routing", routeRuleSet);
return runCondition(condition, contextMap);
}
};
}
}
代码示例来源:origin: com.atlassian.plugins/atlassian-plugins-webresource
@Override
public List<PluginResource> getPluginResources(final String moduleCompleteKey) {
if (moduleCompleteKey.contains(":")) {
// If it's the web resource.
Option<WebResourceModuleDescriptor> option = getDescriptor(moduleCompleteKey);
if (option.isEmpty()) {
return Collections.emptyList();
}
WebResourceModuleDescriptor wrmd = option.get();
final Set<PluginResource> resources = new LinkedHashSet<PluginResource>();
for (final ResourceDescriptor resourceDescriptor : wrmd.getResourceDescriptors()) {
resources.add(new BatchPluginResource(moduleCompleteKey, wrmd.getCompleteKey()));
}
return ImmutableList.copyOf(resources);
} else {
// If it's the module.
List<PluginResource> resources = new ArrayList<>();
resources.add(new BatchPluginResource(moduleCompleteKey, moduleCompleteKey));
return resources;
}
}
代码示例来源:origin: com.atlassian.application/atlassian-application-host
@Override
public Option<DateTime> apply(@Nullable final Plugin plugin)
{
if (plugin == null)
{
return none();
}
else
{
for (Bundle bundle : getPluginBundle(plugin))
{
final Object value = bundle.getHeaders().get(BUILD_DATE_ATTRIBUTE);
if (value != null)
{
final Option<DateTime> buildDate = PluginDateTimeUtils.fromPluginString(value.toString());
if (buildDate.isEmpty())
{
log.debug("Plugin with key \"{}\" has invalid Atlassian-Build-Date of \"{}\".",
plugin.getKey(), value);
}
return buildDate;
}
}
return none();
}
}
代码示例来源:origin: com.atlassian.swagger/atlassian-swagger-doclet
private static Option<Class<?>[]> loadParameterClasses(MethodDoc methodDoc) {
Parameter[] jp = methodDoc.parameters();
List<Class<?>> parameters = new ArrayList<>();
for (Parameter p : jp) {
final String classForName = getClassForNameFromType(p.type());
Option<Class<?>> clz = loadClass(classForName);
if (clz.isEmpty()) {
log.error("Could not load Class.forName({}). Returning no parameters for {}.", classForName, methodDoc.name());
return none();
}
parameters.add(clz.get());
}
return some(parameters.toArray(new Class[parameters.size()]));
}
代码示例来源:origin: com.atlassian.swagger/atlassian-swagger-doclet
/**
* Loads a Method object from the JavaDoc description of that method
*
* @param methodDoc the method in javadoc
* @return the method if it can be loaded
*/
public static Option<Method> loadMethod(MethodDoc methodDoc) {
ClassDoc classDoc = methodDoc.containingClass();
Option<Method> method = none();
Option<Class<?>[]> parameters = loadParameterClasses(methodDoc);
Option<Class<?>> clz = loadClass(classDoc.qualifiedName());
if (clz.isDefined() && parameters.isDefined()) {
method = matchMethod(methodDoc.name(), clz.get(), parameters.get());
}
if (method.isEmpty()) {
log.error(String.format("Unable to load methodDoc %s", methodDoc.qualifiedName()));
}
return method;
}
代码示例来源:origin: com.atlassian.swagger/atlassian-swagger-doclet
if (httpMethodOpt.isEmpty()) {
内容来源于网络,如有侵权,请联系作者删除!