use of javax.annotation.CheckForNull in project sonarqube by SonarSource.
the class Request method paramAsDateTime.
@CheckForNull
public Date paramAsDateTime(String key) {
String stringDate = param(key);
if (stringDate == null) {
return null;
}
Date date = parseDateTimeQuietly(stringDate);
if (date != null) {
return date;
}
date = parseDateQuietly(stringDate);
checkArgument(date != null, "'%s' cannot be parsed as either a date or date+time", stringDate);
return date;
}
use of javax.annotation.CheckForNull in project sonarqube by SonarSource.
the class DateUtils method parseDateOrDateTime.
/**
* @throws IllegalArgumentException if stringDate is not a correctly formed date or datetime
* @return the datetime, {@code null} if stringDate is null
* @since 6.1
*/
@CheckForNull
public static Date parseDateOrDateTime(@Nullable String stringDate) {
if (stringDate == null) {
return null;
}
Date date = parseDateTimeQuietly(stringDate);
if (date != null) {
return date;
}
date = parseDateQuietly(stringDate);
checkArgument(date != null, "Date '%s' cannot be parsed as either a date or date+time", stringDate);
return date;
}
use of javax.annotation.CheckForNull in project sonarqube by SonarSource.
the class SensorContextTester method referencesForSymbolAt.
/**
* Return list of symbol references ranges for the symbol at a given position in a file.
* @param componentKey Key of the file like 'myProjectKey:src/foo.php'
* @param line Line you want to query
* @param lineOffset Offset you want to query.
* @return List of references for the symbol (potentially empty) or null if there is no symbol at this position.
*/
@CheckForNull
public Collection<TextRange> referencesForSymbolAt(String componentKey, int line, int lineOffset) {
DefaultSymbolTable symbolTable = sensorStorage.symbolsPerComponent.get(componentKey);
if (symbolTable == null) {
return null;
}
DefaultTextPointer location = new DefaultTextPointer(line, lineOffset);
for (Map.Entry<TextRange, Set<TextRange>> symbol : symbolTable.getReferencesBySymbol().entrySet()) {
if (symbol.getKey().start().compareTo(location) <= 0 && symbol.getKey().end().compareTo(location) > 0) {
return symbol.getValue();
}
}
return null;
}
use of javax.annotation.CheckForNull in project sonarqube by SonarSource.
the class InputFileBuilder method create.
@CheckForNull
DefaultInputFile create(Path file, InputFile.Type type, Charset defaultEncoding) {
String relativePath = pathResolver.relativePath(moduleBaseDir, file);
if (relativePath == null) {
LOG.warn("File '{}' is ignored. It is not located in module basedir '{}'.", file.toAbsolutePath(), moduleBaseDir);
return null;
}
DefaultIndexedFile indexedFile = new DefaultIndexedFile(moduleKey, moduleBaseDir, relativePath, type, idGenerator.get());
String language = langDetection.language(indexedFile);
if (language == null && langDetection.forcedLanguage() != null) {
LOG.warn("File '{}' is ignored because it doens't belong to the forced langauge '{}'", file.toAbsolutePath(), langDetection.forcedLanguage());
return null;
}
indexedFile.setLanguage(language);
DefaultInputFile inputFile = new DefaultInputFile(indexedFile, f -> metadataGenerator.setMetadata(f, defaultEncoding));
if (language != null) {
inputFile.setPublish(true);
}
return inputFile;
}
use of javax.annotation.CheckForNull in project sonarqube by SonarSource.
the class ProjectReactorBuilder method initModuleBuildDir.
@CheckForNull
private static File initModuleBuildDir(File moduleBaseDir, Map<String, String> moduleProperties) {
String buildDir = moduleProperties.get(PROPERTY_PROJECT_BUILDDIR);
if (StringUtils.isBlank(buildDir)) {
return null;
}
File customBuildDir = new File(buildDir);
if (customBuildDir.isAbsolute()) {
return customBuildDir;
}
return new File(moduleBaseDir, customBuildDir.getPath());
}
Aggregations