@Override public Option<A> foreach(Function<? super A, Void> f) { f.apply(a); return this; }
@Override public Function<B, C> apply(final A a) { return new Function<B, C>() { @Override public C apply(B b) { return f.apply(a, b); } }; } };
public static <A> Function<A, Boolean> not(Function<A, Boolean> f) { return not.o(f); }
/** * Load the series DublinCore catalog contained in a media package. * * @return the catalog or none if the media package does not contain a series DublinCore */ public static Opt<DublinCoreCatalog> loadSeriesDublinCore(final Workspace ws, MediaPackage mp) { return loadDublinCore(ws, mp, MediaPackageSupport.Filters.isSeriesDublinCore.toFn()); }
/** Delete all entities of BundleInfo of a certain host from the database. */ public static Effect<EntityManager> deleteByHost(String host) { return named.update("BundleInfo.deleteByHost", tuple("host", host)).toEffect(); }
/** * Load the episode DublinCore catalog contained in a media package. * * @return the catalog or none if the media package does not contain an episode DublinCore */ public static Opt<DublinCoreCatalog> loadEpisodeDublinCore(final Workspace ws, MediaPackage mp) { return loadDublinCore(ws, mp, MediaPackageSupport.Filters.isEpisodeDublinCore.toFn()); }
/** Delete a bundle info. */ public static Effect<EntityManager> delete(final String host, final long bundleId) { return named.update("BundleInfo.delete", tuple("host", host), tuple("bundleId", bundleId)).toEffect(); } }
public final Function<A, Either<Exception, B>> either() { return new Function<A, Either<Exception, B>>() { @Override public Either<Exception, B> apply(A a) { try { return right(xapply(a)); } catch (Exception e) { return left(e); } } }; } }
/** * Return the content of the response as a string if its status code equals one of the given statuses. Throw an * exception on an unexpected status. * <p> * Function composition of {@link #getContentFn} and {@link #expect(int...)}. */ public static Function<HttpResponse, String> getContentOn(final int... status) { return getContentFn.o(expect(status)); }
@Override public List<DublinCoreValue> getValuesFlat() { return $(data.values()).bind(Fns.<List<CatalogEntry>>id()).map(toDublinCoreValue.toFn()).toList(); }
@Override public List<BundleInfoJpa> apply(EntityManager em) { final CriteriaBuilder cb = em.getCriteriaBuilder(); final CriteriaQuery<BundleInfoJpa> q = cb.createQuery(BundleInfoJpa.class); final Root<BundleInfoJpa> r = q.from(BundleInfoJpa.class); q.select(r); final Expression<String> symbolicNamePath = r.get("bundleSymbolicName"); final Predicate[] likes = toArray(Predicate.class, mlist(prefixes).map(new Function<String, Predicate>() { @Override public Predicate apply(String prefix) { return cb.like(symbolicNamePath, prefix + "%"); } }).value()); q.where(cb.or(likes)); q.orderBy(cb.asc(r.get("host")), cb.asc(symbolicNamePath)); return em.createQuery(q).getResultList(); } };
/** Create an object. */ public static Obj obj(Prop... ps) { return new Obj(mlist(ps).filter(notZero.o(getVal)).value()); }
@Override public void endElement(String uri, String localName, String name) throws SAXException { super.endElement(uri, localName, name); if ("Type".equals(name)) { type = getContent(); return; } else if ("Description".equals(name)) { description = getContent(); return; } if ("Extensions".equals(name)) { extensions = getContent(); return; } else if ("MimeType".equals(name)) { String[] t = type.split("/"); MimeType mimeType = mimeType(t[0].trim(), t[1].trim(), mlist(extensions.split(",")).bind(Options.<String> asList().o(Strings.trimToNone)).value(), Collections.<MimeType> nil(), option(description), none(""), none("")); registry.add(mimeType); } }
@Override public Boolean apply(A a) { for (Function<A, Boolean> f : fs) { if (!f.apply(a)) return false; } return true; } };
@Override public ListMonadic<A> each(Function<? super A, Void> e) { for (A a : as) e.apply(a); return this; }