class StringHelper {

    public static List<Integer> getOccurrenceIndices(String text, String search) {
        if (text == null || search == null || search.isEmpty()) {
            return Collections.emptyList();
        }

        List<Integer> indices = new ArrayList<>();
        int lastPosition = 0;
        int position;
        while ((position = text.indexOf(search, lastPosition)) > -1) {
            indices.add(position);
            lastPosition = position + 1;
        }
        return indices;
    }

    private  StringHelper();

}