public ResourcePattern toKafkaResourcePattern() {
        org.apache.kafka.common.resource.ResourceType kafkaType;
        String kafkaName;
        PatternType kafkaPattern = PatternType.LITERAL;

        switch (type) {
            case TOPIC:
                kafkaType = org.apache.kafka.common.resource.ResourceType.TOPIC;
                kafkaName = name;

                if (AclResourcePatternType.PREFIX.equals(pattern))   {
                    kafkaPattern = PatternType.PREFIXED;
                }

                break;
            case GROUP:
                kafkaType = org.apache.kafka.common.resource.ResourceType.GROUP;
                kafkaName = name;

                if (AclResourcePatternType.PREFIX.equals(pattern))   {
                    kafkaPattern = PatternType.PREFIXED;
                }

                break;
            case CLUSTER:
                kafkaType = org.apache.kafka.common.resource.ResourceType.CLUSTER;
                kafkaName = "kafka-cluster";
                break;
            case TRANSACTIONAL_ID:
                kafkaType = org.apache.kafka.common.resource.ResourceType.TRANSACTIONAL_ID;
                kafkaName = name;

                if (AclResourcePatternType.PREFIX.equals(pattern))   {
                    kafkaPattern = PatternType.PREFIXED;
                }

                break;
            default:
                throw new IllegalArgumentException("Invalid Acl resource type: " + type);
        }

        if (kafkaName == null)   {
            throw new IllegalArgumentException("Name is required for resource type: " + type);
        }

        return new ResourcePattern(kafkaType, kafkaName, kafkaPattern);
    }
@Test
    public void testToKafkaResourcePatternForClusterResource()  {
        // Regular cluster
        SimpleAclRuleResource clusterResourceRules = new SimpleAclRuleResource(null, SimpleAclRuleResourceType.CLUSTER, null);
        ResourcePattern expectedKafkaResourcePattern = new ResourcePattern(ResourceType.CLUSTER, "kafka-cluster", PatternType.LITERAL);
        assertThat(clusterResourceRules.toKafkaResourcePattern(), is(expectedKafkaResourcePattern));
    }