本文整理了Java中org.opencastproject.util.data.Option.option()
方法的一些代码示例,展示了Option.option()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Option.option()
方法的具体详情如下:
包路径:org.opencastproject.util.data.Option
类名称:Option
方法名:option
[英]#option(Object) as a function.
[中]
代码示例来源:origin: opencast/opencast
@Override
public Option<T> unmarshal(T o) throws Exception {
return Option.option(o);
}
代码示例来源:origin: opencast/opencast
@Override
public Option<A> apply(A a) {
return option(a);
}
};
代码示例来源:origin: opencast/opencast
@Override
public Option<A> apply(EntityManager em) {
return option(em.find(clazz, primaryKey));
}
};
代码示例来源:origin: opencast/opencast
@Override public Option<A> apply(EntityManager em) {
return option(em.find(clazz, primaryKey));
}
};
代码示例来源:origin: opencast/opencast
@Override
public Option<B> apply(A a) {
return option(map.get(a));
}
};
代码示例来源:origin: opencast/opencast
/**
* Open a classpath resource using the class loader of the given class.
*
* @return an input stream to the resource wrapped in a Some or none if the resource cannot be found
*/
public static Option<InputStream> openClassPathResource(String resource, Class<?> clazz) {
return option(clazz.getResourceAsStream(resource));
}
代码示例来源:origin: opencast/opencast
/** Extract the build number of a bundle. */
public static Option<String> getBuildNumber(Bundle bundle) {
return option(bundle.getHeaders().get(MANIFEST_BUILD_NUMBER));
}
}
代码示例来源:origin: opencast/opencast
/** Evaluate the xpath expression against the contained document. The expression must return a nodelist. */
// todo replace return type with Valid once it is implemented
public Option<NodeList> nodeSet(String expr) {
try {
return option(((NodeList) xpath.evaluate(expr, node, XPathConstants.NODESET)));
} catch (XPathExpressionException e) {
return none();
}
}
代码示例来源:origin: opencast/opencast
/**
* Get an optional, non-blank value from the <em>bundle</em> context.
*
* @throws RuntimeException
* key does not exist or its value is blank
*/
public static Option<String> getOptContextProperty(ComponentContext cc, String key) {
return option(cc.getBundleContext().getProperty(key)).bind(Strings.trimToNone);
}
代码示例来源:origin: opencast/opencast
@Override public Option<Date> apply(DublinCoreValue dublinCoreValue) {
return option(decodeDate(dublinCoreValue));
}
};
代码示例来源:origin: opencast/opencast
/** Evaluate the xpath expression against the contained document. The expression must return a node. */
// todo replace return type with Valid once it is implemented
public Option<Node> node(String expr) {
try {
return option((Node) xpath.evaluate(expr, node, XPathConstants.NODE));
} catch (XPathExpressionException e) {
return none();
}
}
代码示例来源:origin: opencast/opencast
/** Evaluate the xpath expression against the contained document. The expression must return a string (text). */
// todo replace return type with Valid once it is implemented
public Option<String> string(String expr) {
try {
return option(((String) xpath.evaluate(expr, node, XPathConstants.STRING)).trim());
} catch (XPathExpressionException e) {
return none();
}
}
代码示例来源:origin: opencast/opencast
@Override public String getMountPoint() {
for (HttpResponse r : option(getResponse(get("mountpoint"), HttpStatus.SC_OK))) {
try {
return EntityUtils.toString(r.getEntity());
} catch (IOException e) {
logger.error("Cannot contact remote service", e);
return chuck(e);
}
}
throw new RuntimeException("Cannot contact remote service");
}
}
代码示例来源:origin: opencast/opencast
/** Get the OAI-PMH server URL of the current organization. */
public static Option<String> oaiPmhServerUrlOfCurrentOrganization(SecurityService secSvc) {
return option(secSvc.getOrganization().getProperties().get(ORG_CFG_OAIPMH_SERVER_HOSTURL));
}
}
代码示例来源:origin: opencast/opencast
/**
* Get a configuration option.
*
* @deprecated use {@link #getConfig(WorkflowInstance, String)} or {@link #getOptConfig(org.opencastproject.workflow.api.WorkflowInstance, String)}
*/
protected Option<String> getCfg(WorkflowInstance wi, String key) {
return option(wi.getCurrentOperation().getConfiguration(key));
}
代码示例来源:origin: opencast/opencast
@Override
public Option<String> apply(MediaPackageElement mpe) {
return option(mpe.getChecksum().getValue());
}
};
代码示例来源:origin: opencast/opencast
@Override public String getPrefix(final String uri) {
return option(b.getPrefix(uri)).getOrElse(new Function0<String>() {
@Override public String apply() {
return a.getPrefix(uri);
}
});
}
代码示例来源:origin: opencast/opencast
/** OSGi callback */
public void activate(ComponentContext cc) {
host = option(getContextProperty(cc, OpencastConstants.SERVER_URL_PROPERTY)).bind(Strings.trimToNone).getOrElse(
UrlSupport.DEFAULT_BASE_URL);
for (BundleInfoDb a : db)
a.clear(host);
cc.getBundleContext().addBundleListener(this);
for (Bundle b : cc.getBundleContext().getBundles()) {
logBundle(b);
}
}
代码示例来源:origin: opencast/opencast
/**
* Get an optional boolean from a dictionary.
*/
public static Option<Boolean> getOptCfgAsBoolean(Dictionary d, String key) {
return option(d.get(key)).bind(Strings.asString()).map(Strings.toBool);
}
代码示例来源: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();
}
内容来源于网络,如有侵权,请联系作者删除!