public static int countCharOccurrences(final @NonNull String haystack, final char needle) {
        int occurrences = 0;
        for (int i = 0; i < haystack.length(); i++) {
            if (haystack.charAt(i) == needle) {
                occurrences++;
            }
        }
        return occurrences;
    }
Count the occurrences of a character in a string

@param haystack The string to search in
@param needle   The character to count for
@return Number of occurrences
cloud-core/src/main/java/org/incendo/cloud/util/StringUtils.java