public static boolean validate(int[] replicas) {
        if (replicas.length == 0) return true;
        int[] sortedReplicas = clone(replicas);
        Arrays.sort(sortedReplicas);
        int prev = sortedReplicas[0];
        if (prev < 0) return false;
        for (int i = 1; i < sortedReplicas.length; i++) {
            int replica = sortedReplicas[i];
            if (prev == replica) return false;
            prev = replica;
        }
        return true;
    }
Check that a replica set is valid.

@param replicas      The replica set.
@return              True if none of the replicas are negative, and there are no
                     duplicates.
metadata/src/main/java/org/apache/kafka/metadata/Replicas.java