private Set<Integer> createPartitionSet(String partitionsString) throws TerseException {
        Set<Integer> partitions;

        if (partitionsString == null || partitionsString.isEmpty()) {
            partitions = Collections.emptySet();
        } else {
            try {
                partitions = Arrays.stream(partitionsString.split(",")).map(Integer::parseInt).collect(Collectors.toSet());
            } catch (NumberFormatException e) {
                throw new TerseException("--partitions expects a comma separated list of numeric " +
                        "partition ids, but received: " + partitionsString);
            }
        }

        return partitions;
    }
Creates a topic-partition filter based on a topic pattern and a set of partition ids.
tools/src/main/java/org/apache/kafka/tools/GetOffsetShell.java