code: private ReadAvailability checkReadAvailability(long offset, boolean lastOffsetInclusive) {
          // We can only read at a particular offset if:
          // * The offset is not before the Segment's StartOffset
          // AND
          // * The segment is not sealed (we are allowed to do a future read) OR
          // * The segment is sealed and we are not trying to read at or beyond the last offset (based on input).
          if (offset < this.metadata.getStartOffset()) {
              return ReadAvailability.BeforeStartOffset;
          } else if (this.metadata.isSealed()) {
              return offset < (this.metadata.getLength() + (lastOffsetInclusive ? 1 : 0))
                      ? ReadAvailability.Available
                      : ReadAvailability.BeyondLastOffset;
          }
  
          // Offset is in a valid range.
          return ReadAvailability.Available;
      }
docs: Determines the availability of reading at a particular offset, given the state of a segment.
  
  @param offset              The offset to check.
  @param lastOffsetInclusive If true, it will consider the last offset of the segment as a valid offset, otherwise
  it will only validate offsets before the last offset in the segment.
  @return A ReadAvailability based on the Segment's current state and the given offset. This will return Available
  unless the given offset is before the Segment's StartOffset or beyond its Length and the Segment is Sealed.