class StyleRepeatedVeryShortSentences extends TextLevelRule {
  
  private final Language lang;

  public StyleRepeatedVeryShortSentences(ResourceBundle messages, Language lang) {
    super(messages);
    super.setCategory(new Category(new CategoryId("CREATIVE_WRITING"), 
        messages.getString("category_creative_writing"), Location.INTERNAL, false));
    this.lang = lang;
    setDefaultOff();
    setLocQualityIssueType(ITSIssueType.Style);
    addExamplePair(Example.wrong("Das Auto kam <marker>näher.</marker> Der Hund <marker>schlief.</marker> Die Reifen <marker>quietschten.</marker>"),
                   Example.fixed("Das Auto kam näher. Tief und fest schlief der Hund. Die Reifen quietschten."));
  }

  private final static int MIN_REPEATED = 3;
  private final static int MIN_WORDS = 4;

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

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

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

  @Override
  public String getDescription() {
    return "Stakkato-Sätze";
  }

}

    List<RuleMatch> ruleMatches = new ArrayList<>();
    if (sentences.size() < MIN_REPEATED) {
      return toRuleMatchArray(ruleMatches);
    }
    int pos = 0;
    int nRepeated = 0;
    List<Integer> startPos = new ArrayList<>();
    List<Integer> endPos = new ArrayList<>();
    List<AnalyzedSentence> repeatedSentences = new ArrayList<>();
    AnalyzedTokenReadings[] tokens = null;
    int n = -1;
    int nPara  = -1;
    for (AnalyzedSentence sentence : sentences) {
      n++;
      nPara++;
      tokens = sentence.getTokensWithoutWhitespace();
      boolean paragraphEnd = Tools.isParagraphEnd(sentences, n, lang);
      if ((!paragraphEnd || nPara > 0) && tokens.length > 2 && tokens.length <= MIN_WORDS + 2) {  // MIN_WORDS + SENT_START + punctuation mark
        repeatedSentences.add(sentence);
        startPos.add(tokens[tokens.length - 2].getStartPos() + pos);
        endPos.add(tokens[tokens.length - 1].getEndPos() + pos);
        nRepeated++;
      } else {
        if (nRepeated >= MIN_REPEATED) {
          for (int i = 0; i < repeatedSentences.size(); i++) {
            RuleMatch ruleMatch = new RuleMatch(this, repeatedSentences.get(i), startPos.get(i), endPos.get(i), getDescription());
            ruleMatches.add(ruleMatch);
          }
        }
        repeatedSentences.clear();
        startPos.clear();
        endPos.clear();
        nRepeated = 0;
      }
      pos += sentence.getCorrectedTextLength();
      if (paragraphEnd) {
        nPara = -1;
      }
    }
    if (nRepeated >= MIN_REPEATED) {
      for (int i = 0; i < repeatedSentences.size(); i++) {
        RuleMatch ruleMatch = new RuleMatch(this, repeatedSentences.get(i), startPos.get(i), endPos.get(i), getDescription());
        ruleMatches.add(ruleMatch);
      }
    }
    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>