private boolean testWordMatch(String needle, String haystack) {
        int position = haystack.indexOf(needle);
        int haystackLength = haystack.length();
        int needleLength = needle.length();
        if (position == -1) {
            return false;
        } else if (needleLength == haystackLength) {
            return true;
        } else if (position == 0) {
            return haystack.charAt(needleLength) == ' ';
        } else if (position == haystackLength - needleLength) {
            return haystack.charAt(position - 1) == ' ';
        } else {
            return haystack.charAt(position - 1) == ' ' && haystack.charAt(position + needleLength) == ' ';
        }
    }
Returns the first term that the input text matched.
@param text the String within which to search for matches
@return the first match found
smithy-linters/src/main/java/software/amazon/smithy/linters/WordBoundaryMatcher.java