public MimeType matches(String name) {
        if (name == null) {
            throw new IllegalArgumentException("Name is missing");
        }

        // First, try exact match of the provided resource name
        if (names.containsKey(name)) {
            return names.get(name);
        }

        // Then try "extension" (*.xxx) matching
        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);
            }
        }

        // And finally, try complex regexp matching
        for (Map.Entry<String, MimeType> entry : globs.entrySet()) {
            if (name.matches(entry.getKey())) {
                return entry.getValue();
            }
        }

        return null;
    }
Find the MimeType corresponding to a resource name.
<p>
It applies the recommendations detailed in FreeDesktop Shared MIME-info
Database for guessing MimeType from a resource name: It first tries a
case-sensitive match, then try again with the resource name converted to
lower-case if that fails. If several patterns match then the longest
pattern is used. In particular, files with multiple extensions (such as
Data.tar.gz) match the longest sequence of extensions (eg '*.tar.gz' in
preference to '*.gz'). Literal patterns (eg, 'Makefile') are matched
before all others. Patterns beginning with `*.' and containing no other
special characters (`*?[') are matched before other wildcarded patterns
(since this covers the majority of the patterns).
tika-core/src/main/java/org/apache/tika/mime/Patterns.java