@Override public BasedSequence nullIfEmpty() { return isEmpty() ? BasedSequence.NULL : this; }
/** * @return the first character of the sequence or '\0' if empty */ @Override public char firstChar() { return isEmpty() ? '\0' : charAt(0); }
/** * @return the last character of the sequence or '\0' if empty */ @Override public char lastChar() { return isEmpty() ? '\0' : charAt(length() - 1); }
@Override public boolean isBlank() { return isEmpty() || countChars(WHITESPACE_CHARS, 0, length()) == length(); }
@Override public BasedSequence spliceAtEnd(BasedSequence other) { if (other.isEmpty()) { return this; } else if (isEmpty()) { return other; } assert isContinuedBy(other) : "sequence[" + getStartOffset() + ", " + getEndOffset() + "] is not continued by other[" + other.getStartOffset() + ", " + other.getEndOffset() + "]"; return baseSubSequence(getStartOffset(), other.getEndOffset()); }
@Override public BasedSequence nullIfEmpty() { return isEmpty() ? BasedSequence.NULL : this; }
/** * @return the first character of the sequence or '\0' if empty */ @Override public char firstChar() { return isEmpty() ? '\0' : charAt(0); }
/** * @return the last character of the sequence or '\0' if empty */ @Override public char lastChar() { return isEmpty() ? '\0' : charAt(length() - 1); }
@Override public boolean isBlank() { return isEmpty() || countChars(WHITESPACE_CHARS, 0, length()) == length(); }
@Override public BasedSequence spliceAtEnd(BasedSequence other) { if (other.isEmpty()) { return this; } else if (isEmpty()) { return other; } assert isContinuedBy(other) : "sequence[" + getStartOffset() + ", " + getEndOffset() + "] is not continued by other[" + other.getStartOffset() + ", " + other.getEndOffset() + "]"; return baseSubSequence(getStartOffset(), other.getEndOffset()); }