code: @Override
    public int compareTo(final Span s) {
      if (getStart() < s.getStart()) {
        return -1;
      } else if (getStart() == s.getStart()) {
        if (getEnd() > s.getEnd()) {
          return -1;
        } else if (getEnd() < s.getEnd()) {
          return 1;
        } else {
          // compare the type
          if (getType() == null && s.getType() == null) {
            return 0;
          } else if (getType() != null && s.getType() != null) {
            // use type lexicography order
            return getType().compareTo(s.getType());
          } else if (getType() != null) {
            return -1;
          }
          return 1;
        }
      } else {
        return 1;
      }
    }
docs: Compares the specified span to the current span.