use of javax.annotation.CheckForNull in project sonarqube by SonarSource.
the class IssueQueryService method findCreatedAfterFromComponentUuid.
@CheckForNull
private Date findCreatedAfterFromComponentUuid(DbSession dbSession, String uuid) {
ComponentDto component = checkFoundWithOptional(dbClient.componentDao().selectByUuid(dbSession, uuid), "Component with id '%s' not found", uuid);
Optional<SnapshotDto> snapshot = dbClient.snapshotDao().selectLastAnalysisByComponentUuid(dbSession, component.uuid());
if (snapshot.isPresent()) {
return longToDate(snapshot.get().getPeriodDate());
}
return null;
}
use of javax.annotation.CheckForNull in project sonarqube by SonarSource.
the class RuleCreator method validateParam.
@CheckForNull
private void validateParam(RuleParamDto ruleParam, @Nullable String value) {
if (value != null) {
RuleParamType ruleParamType = RuleParamType.parse(ruleParam.getType());
if (ruleParamType.multiple()) {
List<String> values = newArrayList(Splitter.on(",").split(value));
typeValidations.validate(values, ruleParamType.type(), ruleParamType.values());
} else {
typeValidations.validate(value, ruleParamType.type(), ruleParamType.values());
}
}
}
use of javax.annotation.CheckForNull in project sonarqube by SonarSource.
the class UserIndex method getNullableByLogin.
@CheckForNull
public UserDoc getNullableByLogin(String login) {
GetRequestBuilder request = esClient.prepareGet(UserIndexDefinition.INDEX_TYPE_USER, login).setFetchSource(true).setRouting(login);
GetResponse response = request.get();
if (response.isExists()) {
return DOC_CONVERTER.apply(response.getSource());
}
return null;
}
use of javax.annotation.CheckForNull in project sonarqube by SonarSource.
the class DefaultIssue method truncateToSeconds.
@CheckForNull
private static Date truncateToSeconds(@Nullable Date d) {
if (d == null) {
return null;
}
Instant instant = d.toInstant();
instant = instant.truncatedTo(ChronoUnit.SECONDS);
return Date.from(instant);
}
use of javax.annotation.CheckForNull in project sonarqube by SonarSource.
the class PathResolver method relativePath.
/**
* @deprecated since 6.0 was used when component keys were relative to source dirs
*/
@Deprecated
@CheckForNull
public RelativePath relativePath(Collection<File> dirs, File file) {
List<String> stack = new ArrayList<>();
File cursor = file;
while (cursor != null) {
File parentDir = parentDir(dirs, cursor);
if (parentDir != null) {
return new RelativePath(parentDir, Joiner.on("/").join(stack));
}
stack.add(0, cursor.getName());
cursor = cursor.getParentFile();
}
return null;
}
Aggregations