public final String getName(boolean useKeyIfEmpty) { if (useKeyIfEmpty) { return StringUtils.defaultIfEmpty(name, key); } return name; }
/** * Get Zeppelin Git latest commit timestamp * * @return Latest Zeppelin commit timestamp */ public static String getGitTimestamp() { return StringUtils.defaultIfEmpty(gitProperties.getProperty(GIT_PROPERTIES_COMMIT_TS_KEY), StringUtils.EMPTY); } }
/** * Get Zeppelin Git latest commit id * * @return Latest Zeppelin commit id */ public static String getGitCommitId() { return StringUtils.defaultIfEmpty(gitProperties.getProperty(GIT_PROPERTIES_COMMIT_ID_KEY), StringUtils.EMPTY); }
/** * Get Zeppelin version * * @return Current Zeppelin version */ public static String getVersion() { return StringUtils.defaultIfEmpty(projectProperties.getProperty(PROJECT_PROPERTIES_VERSION_KEY), StringUtils.EMPTY); }
/** * Empty default value will be converted to null. Max length is 4000 characters. */ public NewParam setDefaultValue(@Nullable String s) { this.defaultValue = defaultIfEmpty(s, null); return this; } }
/** * Empty default value will be converted to null. Max length is 4000 characters. */ public NewOverriddenParam setOverriddenValue(@Nullable String s) { this.overriddenValue = defaultIfEmpty(s, null); return this; } }
public Credentials(String login, @Nullable String password) { checkArgument(login != null && !login.isEmpty(), "login must not be null nor empty"); this.login = login; this.password = defaultIfEmpty(password, null); }
private String effectiveRegistryName(DockerImageName dockerImageName) { return StringUtils.defaultIfEmpty(dockerImageName.getRegistry(), DEFAULT_REGISTRY_NAME); }
private static String annotatedEngineKey(Object annotatedClassOrObject) { String key = null; org.sonar.check.Rule ruleAnnotation = AnnotationUtils.getAnnotation(annotatedClassOrObject, org.sonar.check.Rule.class); if (ruleAnnotation != null) { key = ruleAnnotation.key(); } Class clazz = annotatedClassOrObject.getClass(); if (annotatedClassOrObject instanceof Class) { clazz = (Class) annotatedClassOrObject; } return StringUtils.defaultIfEmpty(key, clazz.getCanonicalName()); }
public static String getRuleKey(Class annotatedClass) { String key = null; org.sonar.check.Rule ruleAnnotation = AnnotationUtils.getAnnotation(annotatedClass, org.sonar.check.Rule.class); if (ruleAnnotation != null) { key = ruleAnnotation.key(); } return StringUtils.defaultIfEmpty(key, annotatedClass.getCanonicalName()); } }
@CheckForNull public String getDefaultValue(String key) { PropertyDefinition def = get(key); if (def == null) { return null; } return StringUtils.defaultIfEmpty(def.defaultValue(), null); }
public String getDeprecatedKey(String key) { PropertyDefinition def = get(key); if (def == null) { return null; } return StringUtils.defaultIfEmpty(def.deprecatedKey(), null); } }
@Override protected List<ComponentDto> doKeepAuthorizedComponents(String permission, Collection<ComponentDto> components) { try (DbSession dbSession = dbClient.openSession(false)) { Set<String> projectUuids = components.stream() .map(c -> defaultIfEmpty(c.getMainBranchProjectUuid(), c.projectUuid())) .collect(MoreCollectors.toSet(components.size())); Set<String> authorizedProjectUuids = dbClient.authorizationDao().keepAuthorizedProjectUuids(dbSession, projectUuids, getUserId(), permission); return components.stream() .filter(c -> authorizedProjectUuids.contains(c.projectUuid()) || authorizedProjectUuids.contains(c.getMainBranchProjectUuid())) .collect(MoreCollectors.toList(components.size())); } }
@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 static void readDebt(Request request, RuleUpdate update) { String value = defaultIfEmpty(request.param(PARAM_REMEDIATION_FN_TYPE), request.param(DEPRECATED_PARAM_REMEDIATION_FN_TYPE)); if (value != null) { if (StringUtils.isBlank(value)) { update.setDebtRemediationFunction(null); } else { DebtRemediationFunction fn = new DefaultDebtRemediationFunction( DebtRemediationFunction.Type.valueOf(value), defaultIfEmpty(request.param(PARAM_REMEDIATION_FN_GAP_MULTIPLIER), request.param(DEPRECATED_PARAM_REMEDIATION_FN_COEFF)), defaultIfEmpty(request.param(PARAM_REMEDIATION_FN_BASE_EFFORT), request.param(DEPRECATED_PARAM_REMEDIATION_FN_OFFSET))); update.setDebtRemediationFunction(fn); } } }
@Override protected void doAfterStart() { installPlugins(); loadCoreExtensions(); long startTime = System.currentTimeMillis(); String taskKey = StringUtils.defaultIfEmpty(scannerProperties.get(CoreProperties.TASK), CoreProperties.SCAN_TASK); if (taskKey.equals("views")) { throw MessageException.of("The task 'views' was removed with SonarQube 7.1. " + "You can safely remove this call since portfolios and applications are automatically re-calculated."); } else if (!taskKey.equals(CoreProperties.SCAN_TASK)) { throw MessageException.of("Tasks support was removed in SonarQube 7.6."); } new ProjectScanContainer(this).execute(); LOG.info("Analysis total time: {}", formatTime(System.currentTimeMillis() - startTime)); }
private static String componentIdOf(DefaultIssue issue, DbIssues.Location location) { if (location.hasComponentId()) { return StringUtils.defaultIfEmpty(location.getComponentId(), issue.componentUuid()); } return issue.componentUuid(); } }
private static void loadParameters(RulesDefinition.NewRule rule, Field field) { org.sonar.check.RuleProperty propertyAnnotation = field.getAnnotation(org.sonar.check.RuleProperty.class); if (propertyAnnotation != null) { String fieldKey = StringUtils.defaultIfEmpty(propertyAnnotation.key(), field.getName()); RulesDefinition.NewParam param = rule.createParam(fieldKey) .setDescription(propertyAnnotation.description()) .setDefaultValue(propertyAnnotation.defaultValue()); if (!StringUtils.isBlank(propertyAnnotation.type())) { try { param.setType(RuleParamType.parse(propertyAnnotation.type().trim())); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Invalid property type [" + propertyAnnotation.type() + "]", e); } } else { param.setType(guessType(field.getType())); } } }
private static Rule toRule(String repositoryKey, Class clazz, org.sonar.check.Rule ruleAnnotation) { String ruleKey = StringUtils.defaultIfEmpty(ruleAnnotation.key(), clazz.getCanonicalName()); String ruleName = StringUtils.defaultIfEmpty(ruleAnnotation.name(), null); String description = StringUtils.defaultIfEmpty(ruleAnnotation.description(), null); Rule rule = Rule.create(repositoryKey, ruleKey, ruleName); rule.setDescription(description); rule.setSeverity(RulePriority.fromCheckPriority(ruleAnnotation.priority())); rule.setCardinality(ruleAnnotation.cardinality()); rule.setStatus(ruleAnnotation.status()); rule.setTags(ruleAnnotation.tags()); List<Field> fields = FieldUtils2.getFields(clazz, true); for (Field field : fields) { addRuleProperty(rule, field); } return rule; }
private static RulesDefinition.NewRule loadRule(RulesDefinition.NewExtendedRepository repo, Class clazz, org.sonar.check.Rule ruleAnnotation) { String ruleKey = StringUtils.defaultIfEmpty(ruleAnnotation.key(), clazz.getCanonicalName()); String ruleName = StringUtils.defaultIfEmpty(ruleAnnotation.name(), null); String description = StringUtils.defaultIfEmpty(ruleAnnotation.description(), null); RulesDefinition.NewRule rule = repo.createRule(ruleKey); rule.setName(ruleName).setHtmlDescription(description); rule.setSeverity(ruleAnnotation.priority().name()); rule.setTemplate(ruleAnnotation.cardinality() == Cardinality.MULTIPLE); rule.setStatus(RuleStatus.valueOf(ruleAnnotation.status())); rule.setTags(ruleAnnotation.tags()); List<Field> fields = FieldUtils2.getFields(clazz, true); for (Field field : fields) { loadParameters(rule, field); } return rule; }