本文整理了Java中org.opencastproject.util.data.Option.isSome()
方法的一些代码示例,展示了Option.isSome()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Option.isSome()
方法的具体详情如下:
包路径:org.opencastproject.util.data.Option
类名称:Option
方法名:isSome
暂无
代码示例来源:origin: opencast/opencast
/** Throw <code>none</code> if none. */
public <T extends Throwable> Option<A> orError(T none) throws T {
if (isSome())
return this;
else
throw none;
}
代码示例来源:origin: opencast/opencast
@Override
public Boolean apply(Option<A> a) {
return a.isSome();
}
};
代码示例来源:origin: opencast/opencast
/** If this is none return <code>none</code> else this. */
public Option<A> orElse(Option<A> none) {
return isSome() ? this : none;
}
代码示例来源:origin: opencast/opencast
public boolean isNone() {
return !isSome();
}
代码示例来源:origin: opencast/opencast
@Override
public boolean equals(Object o) {
if (o instanceof Option) {
Option<?> opt = (Option<?>) o;
// since an Option should NEVER contain any null this is safe
return opt.isSome() && a.equals(opt.get());
} else {
return false;
}
}
代码示例来源:origin: opencast/opencast
/** Throw exception returned by <code>none</code> if none. */
public <T extends Throwable> Option<A> orError(Function0<T> none) throws T {
if (isSome())
return this;
else
throw none.apply();
}
代码示例来源:origin: opencast/opencast
/** If this is some return <code>some</code>. Like {@link #bind(Function)} but ignores the option's content. */
public <B> Option<B> andThen(Option<B> some) {
return isSome() ? some : Option.<B> none();
}
代码示例来源:origin: opencast/opencast
/** Lazy version of {@link #orElse(Option)}. */
public Option<A> orElse(Function0<Option<A>> none) {
return isSome() ? this : none.apply();
}
代码示例来源:origin: opencast/opencast
/** Throw <code>none</code> if none. */
public <T extends Throwable> Option<A> orError(Class<T> none) throws T {
if (isSome())
return this;
else {
T t;
try {
t = none.newInstance();
} catch (InstantiationException e) {
return chuck(new Error("Error creating exception", e));
} catch (IllegalAccessException e) {
return chuck(new Error("Error creating exception", e));
}
throw t;
}
}
代码示例来源:origin: opencast/opencast
@Override
public Option<Date> getTemporalInstant() {
if (temporalOpt.isSome()) {
if (temporalOpt.get() instanceof Date) {
return temporalOpt;
}
}
return Option.none();
}
代码示例来源:origin: opencast/opencast
@Override
public Option<Long> getTemporalDuration() {
if (temporalOpt.isSome()) {
if (temporalOpt.get() instanceof Long) {
return temporalOpt;
}
}
return Option.none();
}
代码示例来源:origin: opencast/opencast
/** If this is some return <code>some</code>. Like {@link #map(Function)} but ignores the option's content. */
public <B> Option<B> andThenV(B some) {
return isSome() ? some(some) : Option.<B> none();
}
代码示例来源:origin: opencast/opencast
/** Lazy version of {@link #andThen(Option)}. */
public <B> Option<B> andThen(Function0<Option<B>> some) {
return isSome() ? some.apply() : Option.<B> none();
}
代码示例来源:origin: opencast/opencast
/** Inversion. If some return none. If none return some(zero). */
public Option<A> inv(A zero) {
return isSome() ? Option.<A> none() : some(zero);
}
代码示例来源:origin: opencast/opencast
public <B> Option<Tuple<A, B>> and(Option<B> b) {
if (isSome() && b.isSome()) {
return some(tuple(get(), b.get()));
} else {
return none();
}
}
代码示例来源:origin: opencast/opencast
/** Lazy version of {@link #andThenV(Object)}. */
public <B> Option<B> andThenV(Function0<B> some) {
return isSome() ? some(some.apply()) : Option.<B> none();
}
代码示例来源:origin: opencast/opencast
/** Safe decomposition of the option type using functions. */
public <B> B fold(Function<A, B> some, Function0<B> none) {
return isSome() ? some.apply(get()) : none.apply();
}
代码示例来源:origin: opencast/opencast
/**
* OSGI callback for activating this component
*
* @param cc
* the osgi component context
*/
public void activate(ComponentContext cc) throws ConfigurationException {
logger.info("Static File REST Service started.");
serverUrl = OsgiUtil.getContextProperty(cc, OpencastConstants.SERVER_URL_PROPERTY);
useWebserver = BooleanUtils.toBoolean(OsgiUtil.getOptCfg(cc.getProperties(), STATICFILES_WEBSERVER_ENABLED_KEY)
.getOrElse("false"));
webserverURL = OsgiUtil.getOptCfg(cc.getProperties(), STATICFILES_WEBSERVER_URL_KEY);
Option<String> cfgMaxUploadSize = OsgiUtil.getOptContextProperty(cc, STATICFILES_UPLOAD_MAX_SIZE_KEY);
if (cfgMaxUploadSize.isSome())
maxUploadSize = Long.parseLong(cfgMaxUploadSize.get());
}
代码示例来源:origin: opencast/opencast
/**
* Get the URI for a static file resource depending on whether to get it direct from Opencast or from a webserver.
*
* @param uuid
* The unique identifier for the static file.
* @return The URL for the static file resource.
* @throws NotFoundException
* if the resource couldn't been found
*/
public URI getStaticFileURL(String uuid) throws NotFoundException {
if (useWebserver && webserverURL.isSome()) {
return URI.create(UrlSupport.concat(webserverURL.get(), securityService.getOrganization().getId(), uuid,
staticFileService.getFileName(uuid)));
} else {
return URI.create(UrlSupport.concat(serverUrl, STATICFILES_URL_PATH, uuid));
}
}
代码示例来源:origin: opencast/opencast
@Override
public Option<Date[]> getTemporalPeriod() {
if (temporalOpt.isSome()) {
if (temporalOpt.get() instanceof DCMIPeriod) {
DCMIPeriod p = (DCMIPeriod) temporalOpt.get();
return option(new Date[] { p.getStart(), p.getEnd() });
}
}
return Option.none();
}
内容来源于网络,如有侵权,请联系作者删除!