class RemoteRequest {}

  /**
   * run local preprocessing steps (or just store sentences)
   * @param sentences text to process
   * @param textSessionId session ID for caching, partial rollout, A/B testing
   * @return parameter for executeRequest/fallbackResults
   */
  protected abstract RemoteRequest prepareRequest(List<AnalyzedSentence> sentences, @Nullable Long textSessionId);

  /**
   * @param request returned by prepareRequest
   * @param timeoutMilliseconds timeout for this operation, &lt;=0 -&gt; unlimited
   * @return callable that sends request, parses and returns result for this remote rule
   * @throws TimeoutException if timeout was exceeded
   */
  protected abstract Callable<RemoteRuleResult> executeRequest(RemoteRequest request, long timeoutMilliseconds) throws TimeoutException;

  /**
   * fallback if executeRequest times out or throws an error
   * @param request returned by prepareRequest
   * @return local results for this rule
   */
  protected abstract RemoteRuleResult fallbackResults(RemoteRequest request);

  protected CircuitBreaker createCircuitBreaker(String id) {
    CircuitBreakerConfig config = getCircuitBreakerConfig(serviceConfiguration, id);
    return CircuitBreakers.registry().circuitBreaker("remote-rule-" + id, config);
  }

  @NotNull
  static CircuitBreakerConfig getCircuitBreakerConfig(RemoteRuleConfig c, String id) {
    CircuitBreakerConfig.SlidingWindowType type;
    try {
      type = CircuitBreakerConfig.SlidingWindowType.valueOf(c.getSlidingWindowType());
    } catch (IllegalArgumentException e) {
      type = CircuitBreakerConfig.SlidingWindowType.COUNT_BASED;
      logger.warn("Couldn't parse slidingWindowType value '{}' for rule '{}', use one of {}; defaulting to '{}'", c.getSlidingWindowType(), id, Arrays.asList(CircuitBreakerConfig.SlidingWindowType.values()), type);
    }

    CircuitBreakerConfig config = CircuitBreakerConfig
      .custom()
      .failureRateThreshold(c.getFailureRateThreshold())
      .slidingWindow(
        c.getSlidingWindowSize(), c.getMinimumNumberOfCalls(), type)
      .waitDurationInOpenState(Duration.ofMillis(Math.max(1, c.getDownMilliseconds())))
      .enableAutomaticTransitionFromOpenToHalfOpen()
      .build();
    return config;
  }

  @Override
  public boolean isPremium() {
    return premium;
  }

  /**
   * @param sentences text to check
   * @param textSessionId ID for texts, should stay constant for a user session; used for A/B tests of experimental rules
   * @return Future with result
   */
  public FutureTask<RemoteRuleResult> run(List<AnalyzedSentence> sentences, @Nullable Long textSessionId) {<FILL_FUNCTION_BODY>

    if (sentences.isEmpty()) {
      return new FutureTask<>(() -> new RemoteRuleResult(false, true, Collections.emptyList(), sentences));
    }
    Map<String, String> context = MDC.getCopyOfContextMap();
    return new FutureTask<>(() -> {
      MDC.clear();
      if (context != null) {
        MDC.setContextMap(context);
      }
      long characters = sentences.stream().mapToInt(sentence -> sentence.getText().length()).sum();
      long timeout = getTimeout(characters);
      RemoteRequest req = prepareRequest(sentences, textSessionId);
      RemoteRuleResult result;

      result = executeRequest(req, timeout).call();

      if (fixOffsets) {
        for (AnalyzedSentence sentence : sentences) {
          List<RuleMatch> toFix = result.matchesForSentence(sentence);
          if (toFix != null) {
            fixMatchOffsets(sentence, toFix);
          }
        }
      }

      if (filterMatches) {
        List<RuleMatch> filteredMatches = new ArrayList<>();
        for (AnalyzedSentence sentence : sentences) {
          List<RuleMatch> sentenceMatches = result.matchesForSentence(sentence);
          if (sentenceMatches != null) {
            List<RuleMatch> filteredSentenceMatches = RemoteRuleFilters.filterMatches(
              ruleLanguage, sentence, sentenceMatches);
            filteredMatches.addAll(filteredSentenceMatches);
          }
        }
        result = new RemoteRuleResult(result.isRemote(), result.isSuccess(), filteredMatches, sentences);
      }

      List<RuleMatch> filteredMatches = new ArrayList<>();
      for (AnalyzedSentence sentence : sentences) {
        List<RuleMatch> sentenceMatches = result.matchesForSentence(sentence);
        if (sentenceMatches != null) {
          List<RuleMatch> filteredSentenceMatches = suppressMisspelled(sentenceMatches);
          filteredMatches.addAll(filteredSentenceMatches);
        }
      }
      result = new RemoteRuleResult(result.isRemote(), result.isSuccess(), filteredMatches, sentences);
      return result;
    });
  
<methods>public void <init>() ,public void <init>(java.util.ResourceBundle) ,public void addTags(List<java.lang.String>) ,public void addToneTags(List<java.lang.String>) ,public int estimateContextForSureMatch() ,public List<org.languagetool.tagging.disambiguation.rules.DisambiguationPatternRule> getAntiPatterns() ,public org.languagetool.rules.Category getCategory() ,public java.lang.String getConfigureText() ,public final List<org.languagetool.rules.CorrectExample> getCorrectExamples() ,public int getDefaultValue() ,public abstract java.lang.String getDescription() ,public int getDistanceTokens() ,public final List<org.languagetool.rules.ErrorTriggeringExample> getErrorTriggeringExamples() ,public java.lang.String getFullId() ,public abstract java.lang.String getId() ,public final List<org.languagetool.rules.IncorrectExample> getIncorrectExamples() ,public org.languagetool.rules.ITSIssueType getLocQualityIssueType() ,public int getMaxConfigurableValue() ,public int getMinConfigurableValue() ,public int getMinPrevMatches() ,public int getPriority() ,public java.lang.String getSourceFile() ,public java.lang.String getSubId() ,public List<org.languagetool.Tag> getTags() ,public List<org.languagetool.ToneTag> getToneTags() ,public java.net.URL getUrl() ,public boolean hasConfigurableValue() ,public boolean hasTag(org.languagetool.Tag) ,public boolean hasToneTag(org.languagetool.ToneTag) ,public final boolean isDefaultOff() ,public final boolean isDefaultTempOff() ,public boolean isDictionaryBasedSpellingRule() ,public boolean isGoalSpecific() ,public final boolean isOfficeDefaultOff() ,public final boolean isOfficeDefaultOn() ,public boolean isPremium() ,public abstract org.languagetool.rules.RuleMatch[] match(org.languagetool.AnalyzedSentence) throws java.io.IOException,public final void setCategory(org.languagetool.rules.Category) ,public final void setCorrectExamples(List<org.languagetool.rules.CorrectExample>) ,public final void setDefaultOff() ,public final void setDefaultOn() ,public final void setDefaultTempOff() ,public void setDistanceTokens(int) ,public final void setErrorTriggeringExamples(List<org.languagetool.rules.ErrorTriggeringExample>) ,public void setGoalSpecific(boolean) ,public final void setIncorrectExamples(List<org.languagetool.rules.IncorrectExample>) ,public void setLocQualityIssueType(org.languagetool.rules.ITSIssueType) ,public void setMinPrevMatches(int) ,public final void setOfficeDefaultOff() ,public final void setOfficeDefaultOn() ,public void setPremium(boolean) ,public void setPriority(int) ,public void setTags(List<org.languagetool.Tag>) ,public void setToneTags(List<org.languagetool.ToneTag>) ,public void setUrl(java.net.URL) ,public boolean supportsLanguage(org.languagetool.Language) ,public boolean useInOffice() <variables>private static final org.languagetool.rules.Category MISC,private org.languagetool.rules.Category category,private List<org.languagetool.rules.CorrectExample> correctExamples,private boolean defaultOff,private boolean defaultTempOff,private int distanceTokens,private List<org.languagetool.rules.ErrorTriggeringExample> errorTriggeringExamples,private List<org.languagetool.rules.IncorrectExample> incorrectExamples,private boolean isGoalSpecific,private boolean isPremium,private org.languagetool.rules.ITSIssueType locQualityIssueType,protected final non-sealed java.util.ResourceBundle messages,private int minPrevMatches,private boolean officeDefaultOff,private boolean officeDefaultOn,private int priority,private List<org.languagetool.Tag> tags,private List<org.languagetool.ToneTag> toneTags,private java.net.URL url