Source:
public NakadiCursor convert(final String eventTypeStr, final Cursor cursor) throws InternalNakadiException, NoSuchEventTypeException, InvalidCursorException { final String[] parts = cursor.getOffset().split("-", 3); if (parts.length != 3) { throw new InvalidCursorException(CursorError.INVALID_OFFSET); } final String versionStr = parts[0]; if (versionStr.length() != CursorConverter.VERSION_LENGTH) { throw new InvalidCursorException(CursorError.INVALID_OFFSET); } final String orderStr = parts[1]; if (orderStr.length() != TIMELINE_ORDER_LENGTH) { throw new InvalidCursorException(CursorError.INVALID_OFFSET); } final String offsetStr = parts[2]; if (offsetStr.isEmpty() || !NUMBERS_ONLY_PATTERN.matcher(offsetStr).matches()) { throw new InvalidCursorException(CursorError.INVALID_OFFSET); } final int order; try { order = Integer.parseInt(orderStr, TIMELINE_ORDER_BASE); } catch (final NumberFormatException ex) { throw new InvalidCursorException(CursorError.INVALID_OFFSET); } final List<Timeline> timelines = timelineService.getActiveTimelinesOrdered(eventTypeStr); if (timelines.isEmpty()) { Preconditions.checkArgument( order == (Timeline.STARTING_ORDER + 1), "Fallback supported only for order next after initial"); final EventType eventType = eventTypeCache.getEventType(eventTypeStr); return new NakadiCursor( timelineService.getFakeTimeline(eventType), cursor.getPartition(), StringUtils.leftPad(offsetStr, VersionZeroConverter.VERSION_ZERO_MIN_OFFSET_LENGTH, '0') ); } final Timeline timeline = timelines.stream() .filter(t -> t.getOrder() == order) .findAny() .orElseThrow(() -> new InvalidCursorException(CursorError.UNAVAILABLE)); return new NakadiCursor( timeline, cursor.getPartition(), offsetStr); }

Target:
public NakadiCursor convert(final String eventTypeStr, final Cursor cursor) throws InternalNakadiException, NoSuchEventTypeException, InvalidCursorException { final String[] parts = cursor.getOffset().split("-", 3); if (parts.length != 3) { throw new InvalidCursorException(CursorError.INVALID_OFFSET); } final String versionStr = parts[0]; if (versionStr.length() != CursorConverter.VERSION_LENGTH) { throw new InvalidCursorException(CursorError.INVALID_OFFSET); } final String orderStr = parts[1]; if (orderStr.length() != TIMELINE_ORDER_LENGTH) { throw new InvalidCursorException(CursorError.INVALID_OFFSET); } final String offsetStr = parts[2]; if (offsetStr.isEmpty() || !NUMBERS_ONLY_PATTERN.matcher(offsetStr).matches()) { throw new InvalidCursorException(CursorError.INVALID_OFFSET); } final int order; try { order = Integer.parseInt(orderStr, TIMELINE_ORDER_BASE); } catch (final NumberFormatException ex) { throw new InvalidCursorException(CursorError.INVALID_OFFSET); } final List<Timeline> timelines = eventTypeCache.getTimelinesOrdered(eventTypeStr); if (timelines.isEmpty()) { Preconditions.checkArgument( order == (Timeline.STARTING_ORDER + 1), "Fallback supported only for order next after initial"); final EventType eventType = eventTypeCache.getEventType(eventTypeStr); return new NakadiCursor( timelineService.getFakeTimeline(eventType), cursor.getPartition(), StringUtils.leftPad(offsetStr, VersionZeroConverter.VERSION_ZERO_MIN_OFFSET_LENGTH, '0') ); } final Timeline timeline = timelines.stream() .filter(t -> t.getOrder() == order) .findAny() .orElseThrow(() -> new InvalidCursorException(CursorError.UNAVAILABLE)); return new NakadiCursor( timeline, cursor.getPartition(), offsetStr); }