/** Return the list as is or nil, if <code>as</code> is null. */ public static <A> List<A> nullToNil(List<A> as) { return as != null ? as : Collections.<A> nil(); }
/** * Return the list as is or nil, if <code>as</code> is null. * * @deprecated use {@link #nullToNil(java.util.List)} */ @Deprecated public static <A> List<A> mkList(List<A> as) { return as != null ? as : Collections.<A> nil(); }
/** Return nil if <code>a</code> is null or a list containing <code>a</code> otherwise. */ @SuppressWarnings("unchecked") public static <A> List<A> toList(A a) { return a != null ? list(a) : Collections.<A> nil(); }
@Override public List<A> apply(A[] as) { if (as != null) { return Collections.list(as); } else { return Collections.nil(); } } };
@Override public List<Integer> apply(String s) { try { return list(Integer.parseInt(s)); } catch (NumberFormatException e) { return nil(); } } };
@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); } }
public static MimeType mimeType(String type, String subtype, String suffix) { return new MimeType(type, subtype, list(suffix), Collections.<MimeType>nil(), none(""), none(""), none("")); }