@Override public <B> Either<A, B> left(B right) { return Either.right(right); }
@Override public <B> Either<A, B> left(B right) { return Either.left(a); }
return new Either<A, B>() { @Override public <C> C fold(Match<A, B, C> visitor) {
private void waitForResource(final URI uri, final int expectedStatus, final String errorMsg) throws IOException { if (waitForResourceFlag) { HttpUtil.waitForResource(trustedHttpClient, uri, expectedStatus, TIMEOUT, INTERVAL) .fold(Misc.<Exception, Void> chuck(), new Effect.X<Integer>() { @Override public void xrun(Integer status) throws Exception { if (ne(status, expectedStatus)) { final String msg = format(errorMsg, uri.toString()); logger.warn(msg); throw new IOException(msg); } } }); } }
/** * Load the SMIL document identified by <code>mpe</code>. Throws an exception if it does not exist or cannot be loaded * by any reason. * * @return the document */ public static Document loadSmilDocument(InputStream in, MediaPackageElement mpe) { try { Either<Exception, org.w3c.dom.Document> eitherDocument = XmlUtil.parseNs(new InputSource(in)); if (eitherDocument.isRight()) return eitherDocument.right().value(); throw eitherDocument.left().value(); } catch (Exception e) { logger.warn("Unable to load smil document from catalog '{}'", mpe, e); return Misc.chuck(e); } }
@Override public <B> Either<B, A> right(B left) { return Either.right(a); }
@Override public <B> Either<B, A> right(B left) { return Either.left(left); }
return new Either<A, B>() { @Override public <C> C fold(Match<A, B, C> visitor) {
@Override public Option<B> apply(Either<A, B> either) { return either.right().toOption(); } };
/** Create a single access control entry. */ public static Either<AccessControlEntry, List<AccessControlEntry>> entry(String role, String action, boolean allow) { return left(new AccessControlEntry(role, action, allow)); }
@Override public Either<A, B> apply(Either<A, B> e) { return e.right().either(); } });
/** Flatten nested Eithers. */ public static <A, B> Either<A, B> flatten(Either<A, Either<A, B>> e) { return e.right().bind(new Function<Either<A, B>, Either<A, B>>() { @Override public Either<A, B> apply(Either<A, B> e) { return e.right().either(); } }); } }