class MultipleWhitespaceRule extends TextLevelRule {

  public MultipleWhitespaceRule(ResourceBundle messages, Language language) {
    super(messages);
    super.setCategory(Categories.TYPOGRAPHY.getCategory(messages));
    setLocQualityIssueType(ITSIssueType.Whitespace);
  }

  @Override
  public String getId() {
    return "WHITESPACE_RULE";
  }

  @Override
  public String getDescription() {
    return messages.getString("desc_whitespacerepetition");
  }
  
  // First White space is not a linebreak, function or footnote
  private static boolean isFirstWhite(AnalyzedTokenReadings token) {
    return (token.isWhitespace() || StringTools.isNonBreakingWhitespace(token.getToken())) 
        && !token.isLinebreak()
        && !token.getToken().contains("\u200B") && !token.getToken().contains("\uFEFF") && !token.getToken().contains("\u2060");
  }

  // Removable white space are not linebreaks, tabs, functions or footnotes
  private static boolean isRemovableWhite(AnalyzedTokenReadings token) {
    return (token.isWhitespace() || StringTools.isNonBreakingWhitespace(token.getToken())) 
        && !token.isLinebreak() && !token.getToken().equals("\t")
        // exclude invisible spaces:
        && !token.getToken().contains("\u200B") && !token.getToken().contains("\uFEFF") && !token.getToken().contains("\u2060");
  }

  @Override
  public RuleMatch[] match(List<AnalyzedSentence> sentences) {<FILL_FUNCTION_BODY>}

  @Override
  public int minToCheckParagraph() {
    return 0;
  }

}

    List<RuleMatch> ruleMatches = new ArrayList<>();
    int pos = 0;
    for (AnalyzedSentence sentence : sentences) {
      AnalyzedTokenReadings[] tokens = sentence.getTokens();
      //note: we start from token 1
      //token no. 0 is guaranteed to be SENT_START
      for (int i = 1; i < tokens.length; i++) {
        if(isFirstWhite(tokens[i])) {
          int nFirst = i;
          for (i++; i < tokens.length && isRemovableWhite(tokens[i]); i++);
          i--;
          if (i > nFirst) {
            String message = messages.getString("whitespace_repetition");
            RuleMatch ruleMatch = new RuleMatch(this, sentence, pos + tokens[nFirst].getStartPos(),
                pos + tokens[i].getEndPos(), message);
            ruleMatch.setSuggestedReplacement(tokens[nFirst].getToken());
            ruleMatches.add(ruleMatch);
          }
        } else if (tokens[i].isLinebreak()) {
          for (i++; i < tokens.length && isRemovableWhite(tokens[i]); i++);
        }
      }
      pos += sentence.getCorrectedTextLength();
    }
    return toRuleMatchArray(ruleMatches);
  
<methods>public void <init>() ,public void <init>(java.util.ResourceBundle) ,public int estimateContextForSureMatch() ,public org.languagetool.rules.RuleMatch[] match(List<org.languagetool.AnalyzedSentence>, org.languagetool.markup.AnnotatedText) throws java.io.IOException,public abstract org.languagetool.rules.RuleMatch[] match(List<org.languagetool.AnalyzedSentence>) throws java.io.IOException,public final org.languagetool.rules.RuleMatch[] match(org.languagetool.AnalyzedSentence) throws java.io.IOException,public abstract int minToCheckParagraph() <variables>