本文整理了Java中org.opencastproject.util.data.Option.none()
方法的一些代码示例,展示了Option.none()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Option.none()
方法的具体详情如下:
包路径:org.opencastproject.util.data.Option
类名称:Option
方法名:none
[英]Create a new none.
[中]创建一个新的无。
代码示例来源:origin: opencast/opencast
/**
* Create a none with the type of <code>example</code>. This saves some nasty typing, e.g.
* <code>Option.<String>none()</code> vs. <code>none("")</code>.
* <p>
* Please note that this constructor is only due to Java's insufficient type inference.
*/
public static <A> Option<A> none(A example) {
return none();
}
代码示例来源:origin: opencast/opencast
@Override
public Option<B> apply(A a) {
return none();
}
};
代码示例来源:origin: opencast/opencast
@Override
public Option<A> apply() {
return none();
}
};
代码示例来源: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
/** Return the head of list <code>as</code> or <code>none</code>. */
public static <A> Option<A> head(List<A> as) {
if (!as.isEmpty()) {
return some(as.get(0));
} else {
return Option.none();
}
}
代码示例来源:origin: opencast/opencast
/** Create a new entity manager or return none, if the factory has already been closed. */
public static Option<EntityManager> createEntityManager(EntityManagerFactory emf) {
try {
return some(emf.createEntityManager());
} catch (IllegalStateException ex) {
// factory is already closed
return none();
}
}
代码示例来源:origin: opencast/opencast
/** Wrap an arbitrary object into an option with <code>null</code> being mapped to none. */
public static <A> Option<A> option(A a) {
if (a != null)
return some(a);
else
return none();
}
代码示例来源:origin: opencast/opencast
/** Convert an <code>Opt</code> into an <code>Option</code>. */
public static <A> Option<A> fromOpt(Opt<A> a) {
for (A x : a) {
return some(x);
}
return none();
}
代码示例来源:origin: opencast/opencast
/**
* Trim a string and return either <code>some</code> or <code>none</code> if it's empty. The string may be null.
*/
public static Option<String> trimToNone(String a) {
if (a != null) {
final String trimmed = a.trim();
return trimmed.length() > 0 ? some(trimmed) : NONE;
} else {
return none();
}
}
代码示例来源:origin: opencast/opencast
@Override
public Option<Integer> apply(String s) {
try {
return some(Integer.parseInt(s));
} catch (NumberFormatException e) {
return none();
}
}
};
代码示例来源:origin: opencast/opencast
@Override
public Option<List<MediaPackageElement>> apply(HttpResponse response) {
try {
final String xml = IOUtils.toString(response.getEntity().getContent(), Charset.forName("utf-8"));
List<MediaPackageElement> result = new ArrayList<>(MediaPackageElementParser.getArrayFromXml(xml));
return some(result);
} catch (Exception e) {
logger.error("Error parsing Job from HTTP response", e);
return none();
}
}
};
代码示例来源:origin: opencast/opencast
/** Get the organization <code>orgId</code>. */
public static Option<Organization> getOrganization(OrganizationDirectoryService orgDir, String orgId) {
try {
return some(orgDir.getOrganization(orgId));
} catch (NotFoundException e) {
return none();
}
}
代码示例来源:origin: opencast/opencast
@Override
public Option<AclScope> apply(String s) {
try {
return some(AclScope.valueOf(s));
} catch (IllegalArgumentException e) {
return none();
}
}
};
代码示例来源:origin: opencast/opencast
@Override
public Option<A> find(Function<? super A, Boolean> p) {
for (A a : as) {
if (p.apply(a))
return some(a);
}
return 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
@Override
public Option<A> find(Function<? super A, Boolean> p) {
for (A a : forc(as)) {
if (p.apply(a))
return some(a);
}
return none();
}
代码示例来源:origin: opencast/opencast
protected <A> Option<A> runRequest(HttpRequestBase req, Function<HttpResponse, A> f) {
HttpResponse res = null;
try {
res = getResponse(req);
return res != null ? some(f.apply(res)) : Option.<A> none();
} finally {
closeConnection(res);
}
}
代码示例来源: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
@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();
}
内容来源于网络,如有侵权,请联系作者删除!