@CheckForNull private Period findByPreviousVersion() { if (currentVersion == null) { return null; } List<SnapshotDto> snapshotDtos = dbClient.snapshotDao().selectPreviousVersionSnapshots(session, projectUuid, currentVersion); if (snapshotDtos.isEmpty()) { // If no previous version is found, the first analysis is returned return findByFirstAnalysis(); } SnapshotDto snapshotDto = snapshotDtos.get(0); LOG.debug("Compare to previous version ({})", formatDate(snapshotDto.getCreatedAt())); return new Period(LEAK_PERIOD_MODE_PREVIOUS_VERSION, snapshotDto.getVersion(), snapshotDto.getCreatedAt(), snapshotDto.getUuid()); }