public boolean isMatch(Map<String, Pattern> patterns) {
        if (!patterns.isEmpty()) {
            return matchPatterns(patterns);
        }
        // Empty pattern is still considered as a match.
        return true;
    }
@Test
    public void testIsMatchValid() throws UnknownHostException {
        Uuid uuid = Uuid.randomUuid();
        ClientMetricsInstanceMetadata instanceMetadata = new ClientMetricsInstanceMetadata(uuid, ClientMetricsTestUtils.requestContext());
        // We consider empty/missing client matching patterns as valid
        assertTrue(instanceMetadata.isMatch(Collections.emptyMap()));

        assertTrue(instanceMetadata.isMatch(
            Collections.singletonMap(ClientMetricsConfigs.CLIENT_ID, Pattern.compile(".*"))));
        assertTrue(instanceMetadata.isMatch(
            Collections.singletonMap(ClientMetricsConfigs.CLIENT_ID, Pattern.compile("producer-1"))));
        assertTrue(instanceMetadata.isMatch(
            Collections.singletonMap(ClientMetricsConfigs.CLIENT_ID, Pattern.compile("producer.*"))));
        assertTrue(instanceMetadata.isMatch(
            Collections.singletonMap(ClientMetricsConfigs.CLIENT_INSTANCE_ID, Pattern.compile(uuid.toString()))));
        assertTrue(instanceMetadata.isMatch(
            Collections.singletonMap(ClientMetricsConfigs.CLIENT_SOFTWARE_NAME, Pattern.compile("apache-kafka-java"))));
        assertTrue(instanceMetadata.isMatch(
            Collections.singletonMap(ClientMetricsConfigs.CLIENT_SOFTWARE_VERSION, Pattern.compile("3.5.2"))));
        assertTrue(instanceMetadata.isMatch(
            Collections.singletonMap(ClientMetricsConfigs.CLIENT_SOURCE_ADDRESS, Pattern.compile(
                InetAddress.getLocalHost().getHostAddress()))));
        assertTrue(instanceMetadata.isMatch(
            Collections.singletonMap(ClientMetricsConfigs.CLIENT_SOURCE_PORT, Pattern.compile(
                String.valueOf(ClientMetricsTestUtils.CLIENT_PORT)))));
    }