class ConsistentApostrophesRule extends TextLevelRule {

  public ConsistentApostrophesRule(ResourceBundle messages) {
    super(messages);
    setDefaultTempOff(); // TODO
    setUrl(Tools.getUrl("https://languagetool.org/insights/post/punctuation-guide/#what-is-an-apostrophe"));
    addExamplePair(Example.wrong("It's nice, but it <marker>doesn’t</marker> work."),
                   Example.fixed("It's nice, but it <marker>doesn't</marker> work."));
  }

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

  @Override
  public String getDescription() {
    return "Checks if the two types of apostrophes (' and ’) are used consistently in a text.";
  }

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

  private boolean hasTwoApostropheTypes(List<AnalyzedSentence> sentences) {
    boolean hasTypewriterStyle = false;
    boolean hasTypographicStyle = false;
    for (AnalyzedSentence sentence : sentences) {
      AnalyzedTokenReadings[] tokens = sentence.getTokens();
      for (AnalyzedTokenReadings token : tokens) {
        if (token != null && token.getToken().contains("'") && !token.hasTypographicApostrophe()) {
          hasTypewriterStyle = true;
        } else if (token != null && token.getToken().contains("'") && token.hasTypographicApostrophe()) {
          hasTypographicStyle = true;
        }
        if (hasTypewriterStyle && hasTypographicStyle) {
          return true;
        }
      }
    }
    return false;
  }

  @Override
  public int minToCheckParagraph() {
    return -1;
  }

}

    List<RuleMatch> matches = new ArrayList<>();
    int pos = 0;
    boolean hasTwoTypes = hasTwoApostropheTypes(sentences);
    if (!hasTwoTypes) {
      return toRuleMatchArray(matches);
    }
    for (AnalyzedSentence sentence : sentences) {
      AnalyzedTokenReadings[] tokens = sentence.getTokens();
      for (AnalyzedTokenReadings token : tokens) {
        String message = null;
        String repl = null;
        if (token != null && token.getToken().contains("'") && !token.hasTypographicApostrophe()) {
          message = "You used a typewriter-style apostrophe here, but a typographic apostrophe elsewhere in this text.";
          repl = token.getToken().replace('\'', '’');
        } else if (token != null && token.getToken().contains("'") && token.hasTypographicApostrophe()) {
          message = "You used a typographic apostrophe here, but a typewriter-style apostrophe elsewhere in this text.";
          repl = token.getToken();
        }
        if (message != null) {
          RuleMatch match = new RuleMatch(this, sentence, pos + token.getStartPos(), pos + token.getEndPos(),
                              message + " Both are correct, but consider using the same type everywhere in your text.");
          match.setSuggestedReplacement(repl);
          matches.add(match);
        }
      }
      pos += sentence.getCorrectedTextLength();
    }
    return toRuleMatchArray(matches);
  
<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>