MediaPackageElementFlavor implements Cloneable, Comparable<MediaPackageElementFlavor>, Serializable { public static MediaPackageElementFlavor parseFlavor(String s) throws IllegalArgumentException { if (s == null) throw new IllegalArgumentException("Unable to create element flavor from 'null'"); String[] parts = s.split(SEPARATOR); if (parts.length != 2) throw new IllegalArgumentException(format("Unable to create element flavor from \"%s\"", s)); return new MediaPackageElementFlavor(parts[0], parts[1]); } private  MediaPackageElementFlavor();  MediaPackageElementFlavor(String type, String subtype); static MediaPackageElementFlavor flavor(String type, String subtype); String getType(); String getSubtype(); MediaPackageElementFlavor applyTo(MediaPackageElementFlavor target); @Override MediaPackageElementFlavor clone(); boolean eq(String flavor); @Override int compareTo(MediaPackageElementFlavor m); @Override String toString(); static MediaPackageElementFlavor parseFlavor(String s); boolean matches(MediaPackageElementFlavor other); @Override int hashCode(); @Override boolean equals(Object other); static final String WILDCARD; static final String SEPARATOR; static final Function<String, MediaPackageElementFlavor> parseFlavor; }
@Test public void testParse() { String[] invalidFlavors = new String[] { null, "", "/", "valid/", "/valid", " \r \n \t /", " \r \n \t /valid", "/ \r \n \t ", "valid/ \r \n \t ", " \r \n \t / \r \n \t ", "too/many/slashes", "/ \r \n \t too \r / \r many / \t \r \n slashes \t" }; for (String invalid : invalidFlavors) { try { MediaPackageElementFlavor.parseFlavor(invalid); } catch (Throwable t) { assertEquals(format("Catched unexpected exception. The message was: %s", t.getMessage()), IllegalArgumentException.class, t.getClass()); continue; } fail(format("Invalid flavor should fail but was parsed without errors: \"%s\"", invalid)); } }