package com.bbn.nlp.corpora.ere;

import com.google.common.base.Objects;

import static com.google.common.base.Preconditions.checkNotNull;

public final class ERESpan {
  public final int start;
  public final int end;
  public final String text;

  private ERESpan(final int start, final int end, final String text) {
    this.start = start;
    this.end = end;
    this.text = checkNotNull(text);
  }

  public static ERESpan from(final int start, final int end, final String text) {
    return new ERESpan(start, end, text);
  }

  public int getStart() {
    return start;
  }

  public int getEnd() {
    return end;
  }

  public String getText() {
    return text;
  }

  @Override
  public String toString() {
    return "ERESpan{" +
        "start=" + start +
        ", end=" + end +
        ", text='" + text + '\'' +
        '}';
  }

  @Override
  public int hashCode() {
    return Objects.hashCode(start, end, text);
  }

  @Override
  public boolean equals(Object obj) {
    if (this == obj) {
      return true;
    }
    if (obj == null) {
      return false;
    }
    if (getClass() != obj.getClass()) {
      return false;
    }

    ERESpan other = (ERESpan) obj;
    return (start==other.start) && (end==other.end) && text.equals(other.text);
  }
}

@@ -27,16 +27,126 @@
 a.ere;%0A%0A
+import com.bbn.bue.common.strings.offsets.CharOffset;%0Aimport com.bbn.bue.common.strings.offsets.OffsetRange;%0A%0A
 import c
@@ -776,24 +776,142 @@
  text;%0A  %7D%0A%0A
+  public OffsetRange%3CCharOffset%3E asCharOffsets() %7B%0A    return OffsetRange.charOffsetRange(getStart(), getEnd());%0A  %7D%0A%0A
   @Override%0A

Access ERESpans as OffsetRange<CharOffset>