static <T> T getWildcardMappedObject(final Map<String, T> mapping, final String query) {
        T value = mapping.get(query);
        if (value == null) {
            for (String key : mapping.keySet()) {
                // Turn the search key into a regex, using all characters but the * as a literal.
                String regex = Arrays.stream(key.split("\\*")) // split in parts that do not have a wildcard in them
                    .map(Pattern::quote) // each part should be used as a literal (not as a regex or partial regex)
                    .collect(Collectors.joining(".*")); // join all literal parts with a regex representation on the wildcard.
                if (key.endsWith("*")) { // the 'split' will have removed any trailing wildcard characters. Correct for that.
                    regex += ".*";
                }
                if (query.matches(regex)) {
                    value = mapping.get(key);
                    break;
                }
            }
        }
        return value;
    }
@Test
    public void testSubdirExactFalse() throws Exception
    {
        // Setup test fixture.
        final Map<String, Object> haystack = Map.of("myplugin/baz/foo", new Object());

        // Execute system under test.
        final Object result = PluginServlet.getWildcardMappedObject(haystack, "myplugin/baz/bar");

        // Verify results.
        assertNull(result);
    }