Patterns implements Serializable { public MimeType matches(String name) { if (name == null) { throw new IllegalArgumentException("Name is missing"); } if (names.containsKey(name)) { return names.get(name); } int maxLength = Math.min(maxExtensionLength, name.length()); for (int n = maxLength; n >= minExtensionLength; n--) { String extension = name.substring(name.length() - n); if (extensions.containsKey(extension)) { return extensions.get(extension); } } for (Map.Entry<String, MimeType> entry : globs.entrySet()) { if (name.matches(entry.getKey())) { return entry.getValue(); } } return null; } Patterns(MediaTypeRegistry registry); void add(String pattern, MimeType type); void add(String pattern, boolean isJavaRegex, MimeType type); MimeType matches(String name);  }
@Test public void testMatches() { try { patterns.matches(null); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException e) { } }