class ExtendedSentenceRange implements Comparable<ExtendedSentenceRange> {

  @Getter
  private final int fromPos;
  @Getter
  private final int toPos;
  @Getter
  private final Map<String, Float> languageConfidenceRates; //languageCode;0-1 confidenceRate from LanguageDetectionService

  ExtendedSentenceRange(int fromPos, int toPos, String languageCode) {
    this(fromPos, toPos, Collections.singletonMap(languageCode, 1.0f));
  }

  ExtendedSentenceRange(int fromPos, int toPos, @NotNull Map<String, Float> languageConfidenceRates) {
    this.fromPos = fromPos;
    this.toPos = toPos;
    this.languageConfidenceRates = new LinkedHashMap<>(languageConfidenceRates);
  }

  public void updateLanguageConfidenceRates(@NotNull Map<String, Float> languageConfidenceRates) {
    this.languageConfidenceRates.clear();
    this.languageConfidenceRates.putAll(languageConfidenceRates);
  }

  @Override
  public boolean equals(Object o) {<FILL_FUNCTION_BODY>}

  @Override
  public int hashCode() {
    int result = fromPos;
    result = 31 * result + toPos;
    return result;
  }

  @Override
  public String toString() {
    return fromPos + "-" + toPos + ":" + languageConfidenceRates;
  }

  @Override
  public int compareTo(@NotNull ExtendedSentenceRange o) {
    return Integer.compare(this.fromPos, o.fromPos);
  }
}

    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    ExtendedSentenceRange extendedSentenceRange = (ExtendedSentenceRange) o;
    return fromPos == extendedSentenceRange.fromPos && toPos == extendedSentenceRange.toPos;
  
<no_super_class>