MediaPackageElementFlavor implements Cloneable, Comparable<MediaPackageElementFlavor>, Serializable { public boolean matches(MediaPackageElementFlavor other) { return other != null && typeMatches(type, other.type) && typeMatches(subtype, other.subtype); } 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 testMatches() throws Exception { assertFalse("null should not match any flavor", flavor("a", "b").matches(null)); assertTrue("Equal flavors should match", flavor("a", "b").matches(flavor("a", "b"))); assertFalse("Unequal flavors should not match", flavor("a", "b").matches(flavor("b", "a"))); assertTrue("Wildcard type did not match", flavor("*", "b").matches(flavor("a", "b"))); assertTrue("Match with wildcard type should be commutative", flavor("a", "b").matches(flavor("*", "b")) && flavor("*", "b").matches(flavor("a", "b"))); assertTrue("Wildcard subtype did not match", flavor("a", "*").matches(flavor("a", "b"))); assertTrue("Match with wildcard subtype should be commutative", flavor("a", "b").matches(flavor("a", "*")) && flavor("a", "*").matches(flavor("a", "b"))); assertTrue("Wildcard in both type and subtype did not match", flavor("*", "*").matches(flavor("a", "b"))); assertTrue("Match with wildcards in both type and subtype should be commutative", flavor("*", "*").matches(flavor("a", "b")) && flavor("a", "b").matches(flavor("*", "*"))); assertTrue("Wildcard matches", flavor("*", "*").matches(flavor("*", "b"))); assertTrue("Match between wildcards should be commutative", flavor("*", "*").matches(flavor("*", "b")) && flavor("*", "b").matches(flavor("*", "*"))); assertTrue("Wildcard matches", flavor("*", "*").matches(flavor("a", "*"))); assertTrue("Match between wildcards should be commutative", flavor("*", "*").matches(flavor("a", "*")) && flavor("a", "*").matches(flavor("*", "*"))); assertTrue("Wildcard matches", flavor("*", "*").matches(flavor("*", "*"))); }