/** * Plain-text description. Can be null. Max length is 4000 characters. */ public NewParam setDescription(@Nullable String s) { this.description = StringUtils.defaultIfBlank(s, null); return this; }
/** * Set to <code>null</code> or blank to remove existing note. */ public RuleUpdate setMarkdownNote(@Nullable String s) { this.markdownNote = s == null ? null : StringUtils.defaultIfBlank(s, null); this.changeMarkdownNote = true; return this; }
public NewParam setName(@Nullable String s) { // name must never be null. this.name = StringUtils.defaultIfBlank(s, key); return this; }
public Builder setQuery(@Nullable String s) { this.query = StringUtils.defaultIfBlank(s, null); return this; }
public DefaultUser setEmail(@Nullable String s) { this.email = StringUtils.defaultIfBlank(s, null); return this; }
public Builder memberSearch(@Nullable String s) { this.memberSearch = StringUtils.defaultIfBlank(s, null); return this; }
public Builder searchText(@Nullable String s) { this.searchText = StringUtils.defaultIfBlank(s, null); return this; }
public Builder projectSearch(@Nullable String s) { this.projectSearch = StringUtils.defaultIfBlank(s, null); return this; }
public Builder setSearchQuery(@Nullable String s) { this.searchQuery = defaultIfBlank(s, null); return this; }
public Builder setQuery(@Nullable String s) { this.query = StringUtils.defaultIfBlank(s, null); return this; }
public Builder groupSearch(@Nullable String s) { this.groupSearch = StringUtils.defaultIfBlank(s, null); return this; }
public NewRule setSeverity(@Nullable String severity) { this.severity = StringUtils.defaultIfBlank(severity, DEFAULT_SEVERITY); return this; }
public Builder setSeverity(@Nullable String severity) { this.severity = StringUtils.defaultIfBlank(severity, Severity.defaultSeverity()); return this; }
/** * What is the version the upgrade wizard has run the last time and upgraded to?. * If {@link #getUpdateStateFile()} is missing, presumes the baseline is 1.0 * @return Current baseline. {@code null} if it cannot be retrieved. */ @Restricted(NoExternalUse.class) @CheckForNull public VersionNumber getCurrentLevel() { VersionNumber from = new VersionNumber("1.0"); File state = getUpdateStateFile(); if (state.exists()) { try { from = new VersionNumber(defaultIfBlank(readFileToString(state), "1.0").trim()); } catch (IOException ex) { LOGGER.log(Level.SEVERE, "Cannot read the current version file", ex); return null; } } return from; }
@CheckForNull private String ruleDescription(String repositoryKey, org.sonar.api.rules.Rule rule) { String description = i18n.getDescription(repositoryKey, rule.getKey()); if (StringUtils.isNotBlank(description)) { return description; } return StringUtils.defaultIfBlank(rule.getDescription(), null); }
@CheckForNull private String ruleName(String repositoryKey, org.sonar.api.rules.Rule rule) { String name = i18n.getName(repositoryKey, rule.getKey()); if (StringUtils.isNotBlank(name)) { return name; } return StringUtils.defaultIfBlank(rule.getName(), null); }
private static void setCustomRootAppender(LoggingConfiguration conf) { Logger logger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); String level = StringUtils.defaultIfBlank(conf.getSubstitutionVariables().get(LoggingConfiguration.PROPERTY_ROOT_LOGGER_LEVEL), LoggingConfiguration.LEVEL_ROOT_DEFAULT); if (logger.getAppender(CUSTOM_APPENDER_NAME) == null) { logger.detachAndStopAllAppenders(); logger.addAppender(createAppender(conf.getLogOutput())); } logger.setLevel(Level.toLevel(level)); }
@CheckForNull private String paramDescription(String repositoryKey, String ruleKey, RuleParam param) { String desc = StringUtils.defaultIfEmpty( i18n.getParamDescription(repositoryKey, ruleKey, param.getKey()), param.getDescription()); return StringUtils.defaultIfBlank(desc, null); }
private PropertyDefinitions add(PropertyDefinition definition, String defaultCategory) { if (!definitions.containsKey(definition.key())) { definitions.put(definition.key(), definition); String category = StringUtils.defaultIfBlank(definition.category(), defaultCategory); categories.put(definition.key(), new Category(category)); String subcategory = StringUtils.defaultIfBlank(definition.subCategory(), category); subcategories.put(definition.key(), new SubCategory(subcategory)); if (!StringUtils.isEmpty(definition.deprecatedKey()) && !definition.deprecatedKey().equals(definition.key())) { deprecatedKeys.put(definition.deprecatedKey(), definition.key()); } } return this; }
private String getUserFullName(@Nullable String login) { if (login == null) { return null; } try (DbSession dbSession = dbClient.openSession(false)) { UserDto userDto = dbClient.userDao().selectByLogin(dbSession, login); if (userDto == null || !userDto.isActive()) { // most probably user was deleted return login; } return StringUtils.defaultIfBlank(userDto.getName(), login); } }