package org.cnnlp.data.splitter; import org.jetbrains.annotations.NotNull; import java.io.Serializable; import java.util.Objects; public class SubSequence implements Serializable { String text; int startOffset; int endOffset; public SubSequence() { } public SubSequence(String text, int startOffset, int endOffset) { this.text = text; this.startOffset = startOffset; this.endOffset = endOffset; } // @Override // public int compareTo(@NotNull SubSequence o) { // return startOffset - o.startOffset; // } public String getText() { return text; } public void setText(String text) { this.text = text; } public int getStartOffset() { return startOffset; } public void setStartOffset(int startOffset) { this.startOffset = startOffset; } public int getEndOffset() { return endOffset; } public void setEndOffset(int endOffset) { this.endOffset = endOffset; } public void incrementalOffset(int offset) { startOffset = startOffset + offset; endOffset = endOffset + offset; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; SubSequence that = (SubSequence) o; return startOffset == that.startOffset && endOffset == that.endOffset && Objects.equals(text, that.text); } @Override public int hashCode() { return Objects.hash(text, startOffset, endOffset); } @Override public String toString() { return "SubSequence{" + "text='" + text + '\'' + ", startOffset=" + startOffset + ", endOffset=" + endOffset + '}'; } public static SubSequence build(String text, int startOffset, int endOffset) { SubSequence ss = new SubSequence(text, startOffset, endOffset); return ss; } }