public boolean matches(ResourcePattern pattern) {
        if (!resourceType.equals(ResourceType.ANY) && !resourceType.equals(pattern.resourceType())) {
            return false;
        }

        if (!patternType.equals(PatternType.ANY) && !patternType.equals(PatternType.MATCH) && !patternType.equals(pattern.patternType())) {
            return false;
        }

        if (name == null) {
            return true;
        }

        if (patternType.equals(PatternType.ANY) || patternType.equals(pattern.patternType())) {
            return name.equals(pattern.name());
        }

        switch (pattern.patternType()) {
            case LITERAL:
                return name.equals(pattern.name()) || pattern.name().equals(WILDCARD_RESOURCE);

            case PREFIXED:
                return name.startsWith(pattern.name());

            default:
                throw new IllegalArgumentException("Unsupported PatternType: " + pattern.patternType());
        }
    }
@return {@code true} if this filter matches the given pattern.
clients/src/main/java/org/apache/kafka/common/resource/ResourcePatternFilter.java