use of javax.annotation.CheckForNull in project sonarqube by SonarSource.
the class PeriodResolver method resolve.
@CheckForNull
public Period resolve(Settings settings) {
String propertyValue = getPropertyValue(settings);
if (StringUtils.isBlank(propertyValue)) {
return null;
}
Period period = resolve(propertyValue);
if (period == null && StringUtils.isNotBlank(propertyValue)) {
LOG.debug("Property " + LEAK_PERIOD + " is not valid: " + propertyValue);
}
return period;
}
use of javax.annotation.CheckForNull in project sonarqube by SonarSource.
the class PeriodResolver method findByDays.
@CheckForNull
private Period findByDays(int days) {
List<SnapshotDto> snapshots = dbClient.snapshotDao().selectAnalysesByQuery(session, createCommonQuery(projectUuid).setCreatedBefore(analysisDate).setSort(BY_DATE, ASC));
long targetDate = DateUtils.addDays(new Date(analysisDate), -days).getTime();
SnapshotDto snapshot = findNearestSnapshotToTargetDate(snapshots, targetDate);
if (snapshot == null) {
return null;
}
LOG.debug("Compare over {} days ({}, analysis of {})", String.valueOf(days), formatDate(targetDate), formatDate(snapshot.getCreatedAt()));
return new Period(LEAK_PERIOD_MODE_DAYS, String.valueOf(days), snapshot.getCreatedAt(), snapshot.getUuid());
}
use of javax.annotation.CheckForNull in project sonarqube by SonarSource.
the class PeriodResolver method findByVersion.
@CheckForNull
private Period findByVersion(String version) {
SnapshotDto snapshot = findFirstSnapshot(session, createCommonQuery(projectUuid).setVersion(version).setSort(BY_DATE, DESC));
if (snapshot == null) {
return null;
}
LOG.debug("Compare to version ({}) ({})", version, formatDate(snapshot.getCreatedAt()));
return new Period(LEAK_PERIOD_MODE_VERSION, version, snapshot.getCreatedAt(), snapshot.getUuid());
}
use of javax.annotation.CheckForNull in project sonarqube by SonarSource.
the class ShowAction method findDataFromComponent.
@CheckForNull
private String findDataFromComponent(DbSession dbSession, ComponentDto component) {
MeasureQuery query = MeasureQuery.builder().setComponentUuid(component.uuid()).setMetricKey(CoreMetrics.DUPLICATIONS_DATA_KEY).build();
Optional<MeasureDto> measure = dbClient.measureDao().selectSingle(dbSession, query);
return measure.isPresent() ? measure.get().getData() : null;
}
use of javax.annotation.CheckForNull in project sonarqube by SonarSource.
the class IssueQueryService method buildCreatedAfterFromDates.
@CheckForNull
private Date buildCreatedAfterFromDates(@Nullable Date createdAfter, @Nullable String createdInLast) {
checkArgument(createdAfter == null || createdInLast == null, format("%s and %s cannot be set simultaneously", PARAM_CREATED_AFTER, PARAM_CREATED_IN_LAST));
Date actualCreatedAfter = createdAfter;
if (createdInLast != null) {
actualCreatedAfter = new DateTime(system.now()).minus(ISOPeriodFormat.standard().parsePeriod("P" + createdInLast.toUpperCase(Locale.ENGLISH))).toDate();
}
return actualCreatedAfter;
}
Aggregations