private <E> Optional<Iterable<E>> getLines(DbSession dbSession, String fileUuid, int from, int toInclusive, Function<DbFileSources.Line, E> function) { verifyLine(from); checkArgument(toInclusive >= from, String.format("Line number must greater than or equal to %d, got %d", from, toInclusive)); FileSourceDto dto = dbClient.fileSourceDao().selectByFileUuid(dbSession, fileUuid); if (dto == null) { return Optional.empty(); } return Optional.of(dto.getSourceData().getLinesList().stream() .filter(line -> line.hasLine() && line.getLine() >= from) .limit((toInclusive - from) + 1L) .map(function) .collect(MoreCollectors.toList())); }
private <E> Optional<Iterable<E>> getLines(DbSession dbSession, String fileUuid, int from, int toInclusive, Function<DbFileSources.Line, E> function) { verifyLine(from); checkArgument(toInclusive >= from, String.format("Line number must greater than or equal to %d, got %d", from, toInclusive)); FileSourceDto dto = dbClient.fileSourceDao().selectSourceByFileUuid(dbSession, fileUuid); if (dto == null) { return Optional.empty(); } return Optional.of(dto.getSourceData().getLinesList().stream() .filter(line -> line.hasLine() && line.getLine() >= from) .limit((toInclusive - from) + 1L) .map(function) .collect(MoreCollectors.toList())); }
public Builder mergeFrom(org.sonar.db.protobuf.DbFileSources.Line other) { if (other == org.sonar.db.protobuf.DbFileSources.Line.getDefaultInstance()) return this; if (other.hasLine()) { setLine(other.getLine());