WordTokenizer implements Tokenizer { protected boolean hasWordBreakingCharBeforeExplicitChar(final @NonNull Spanned text, final int cursor) { CharSequence beforeCursor = text.subSequence(0, cursor); int i = cursor - 1; while (i >= 0 && i < beforeCursor.length()) { char c = beforeCursor.charAt(i); if (isExplicitChar(c)) { return i == 0 || isWordBreakingChar(beforeCursor.charAt(i - 1)); } i--; } return false; } WordTokenizer();  WordTokenizer(final @NonNull WordTokenizerConfig config); @Override int findTokenStart(final @NonNull Spanned text, final int cursor); @Override int findTokenEnd(final @NonNull Spanned text, final int cursor); boolean isValidMention(final @NonNull Spanned text, final int start, final int end); @Override @NonNull Spanned terminateToken(final @NonNull Spanned text); boolean isExplicitChar(final char c); boolean isWordBreakingChar(final char c); boolean isExplicit(final @NonNull CharSequence text, final int cursor); char getExplicitChar(final @NonNull CharSequence text, final int cursor); boolean containsExplicitChar(final @NonNull CharSequence input); boolean containsWordBreakingChar(final @NonNull CharSequence input); boolean onlyLettersOrDigits(final @NonNull CharSequence input, final int numCharsToCheck, final int start);  }
@Test public void testHasWordBreakingCharBeforeExplicitChar() { String text = "Hi @John Doe"; hasWordBreakingCharBeforeExplicitCharHelper(text, true); text = "Hi@John Doe"; hasWordBreakingCharBeforeExplicitCharHelper(text, false); text = "John Doe"; hasWordBreakingCharBeforeExplicitCharHelper(text, false); }