本文整理了Java中org.opencastproject.util.data.Option.get()
方法的一些代码示例,展示了Option.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Option.get()
方法的具体详情如下:
包路径:org.opencastproject.util.data.Option
类名称:Option
方法名:get
[英]Get the contained value or throw an exception.
[中]获取包含的值或引发异常。
代码示例来源:origin: opencast/opencast
@Override public A apply(Option<A> as) {
return as.get();
}
};
代码示例来源: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
/**
* {@inheritDoc}
*
* @see org.opencastproject.workingfilerepository.api.WorkingFileRepository#getDiskSpace()
*/
public String getDiskSpace() {
int usable = Math.round(getUsableSpace().get() / 1024 / 1024 / 1024);
int total = Math.round(getTotalSpace().get() / 1024 / 1024 / 1024);
long percent = Math.round(100.0 * getUsableSpace().get() / (1 + getTotalSpace().get()));
return "Usable space " + usable + " Gb out of " + total + " Gb (" + percent + "%)";
}
代码示例来源: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
@SuppressWarnings("unchecked")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("storage")
@RestQuery(name = "storage", description = "Returns a report on the disk usage and availability", returnDescription = "Plain text containing the report", reponses = { @RestResponse(responseCode = SC_OK, description = "Report returned") })
public Response restGetTotalStorage() {
long total = this.getTotalSpace().get();
long usable = this.getUsableSpace().get();
long used = this.getUsedSpace().get();
String summary = this.getDiskSpace();
JSONObject json = new JSONObject();
json.put("size", total);
json.put("usable", usable);
json.put("used", used);
json.put("summary", summary);
return Response.ok(json.toJSONString()).build();
}
代码示例来源:origin: opencast/opencast
@Override
public Option<Long> getTemporalDuration() {
if (temporalOpt.isSome()) {
if (temporalOpt.get() instanceof Long) {
return temporalOpt;
}
}
return Option.none();
}
代码示例来源:origin: opencast/opencast
@Override
public Option<Date> getTemporalInstant() {
if (temporalOpt.isSome()) {
if (temporalOpt.get() instanceof Date) {
return temporalOpt;
}
}
return Option.none();
}
代码示例来源:origin: opencast/opencast
/**
* Return the base URL of the HTTP server. <code>http://host:port</code> public URL getBaseUrl() { return baseUrl; }
*
* Call in @BeforeClass annotated method.
*/
public void setUpServer() {
try {
// cut of any base pathbasestUrl might have
int port = baseUrl.getPort();
logger.info("Start http server at port " + port);
hs = new Server(port);
ServletContainer servletContainer = cfg.isSome() ? new ServletContainer(cfg.get()) : new ServletContainer();
ServletHolder jerseyServlet = new ServletHolder(servletContainer);
ServletContextHandler context = new ServletContextHandler(hs, "/");
context.addServlet(jerseyServlet, "/*");
hs.start();
} catch (Exception e) {
chuck(e);
}
}
代码示例来源: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();
}
代码示例来源: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
/** 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
/**
* 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));
}
}
内容来源于网络,如有侵权,请联系作者删除!