List of usage examples for org.apache.commons.lang StringUtils defaultIfBlank
public static String defaultIfBlank(String str, String defaultStr)
Returns either the passed in String, or if the String is whitespace, empty ("") or null
, the value of defaultStr
.
From source file:org.raml.jaxrs.codegen.core.AbstractGenerator.java
/** * <p>createResourceInterface.</p> * * @param resource a {@link org.raml.model.Resource} object. * @param raml a {@link org.raml.model.Raml} object. * @throws java.lang.Exception if any./*from w w w .ja v a 2 s.c o m*/ */ protected void createResourceInterface(final Resource resource, final Raml raml) throws Exception { final String resourceInterfaceName = Names.buildResourceInterfaceName(resource); final JDefinedClass resourceInterface = context.createResourceInterface(resourceInterfaceName); context.setCurrentResourceInterface(resourceInterface); final String path = strip(resource.getRelativeUri(), "/"); resourceInterface.annotate(Path.class).param(DEFAULT_ANNOTATION_PARAMETER, StringUtils.defaultIfBlank(path, "/")); if (isNotBlank(resource.getDescription())) { resourceInterface.javadoc().add(resource.getDescription()); } addResourceMethods(resource, resourceInterface, path); /* call registered extensions */ for (GeneratorExtension e : extensions) { e.onCreateResourceInterface(resourceInterface, resource); } }
From source file:org.raml.jaxrs.codegen.core.Generator.java
private void createResourceInterface(final Resource resource) throws Exception { final String resourceInterfaceName = Names.buildResourceInterfaceName(resource); final JDefinedClass resourceInterface = context.createResourceInterface(resourceInterfaceName); context.setCurrentResourceInterface(resourceInterface); final String path = strip(resource.getRelativeUri(), "/"); resourceInterface.annotate(Path.class).param(DEFAULT_ANNOTATION_PARAMETER, StringUtils.defaultIfBlank(path, "/")); if (isNotBlank(resource.getDescription())) { resourceInterface.javadoc().add(resource.getDescription()); }//from ww w . j a va 2 s . c o m addResourceMethods(resource, resourceInterface, path); }
From source file:org.raml.jaxrs.codegen.core.support.RamlHelper.java
public static final String getResourceInterfacePath(ResourceInterface resourceInterface) { Resource resource = resourceInterface.getResource(); String path = strip(resource.getRelativeUri(), "/"); path = StringUtils.defaultIfBlank(path, "/"); return path;/*from ww w.ja v a 2 s.c om*/ }
From source file:org.raml.jaxrs.codegen.core.visitors.CodeModelVisitor.java
private String getResourceInterfacePath(ResourceInterface resourceInterface) { Resource resource = resourceInterface.getResource(); String path = strip(resource.getRelativeUri(), "/"); path = StringUtils.defaultIfBlank(path, "/"); return path;//w ww. jav a 2 s. c o m }
From source file:org.sakaiproject.component.app.scheduler.jobs.cm.processor.sis.SectionProcessor.java
public Section addSection(String[] data) { log.debug("Adding Section {}", data[0]); return cmAdmin.createSection(data[0], data[1], data[2], data[3], StringUtils.defaultIfBlank(data[4], null), data[6], data[5]);/*from w w w . j a va 2 s. c o m*/ }
From source file:org.sonar.api.batch.rule.Checks.java
public Checks<C> addAnnotatedChecks(Iterable checkClassesOrObjects) { Map<String, Object> checksByEngineKey = new HashMap<>(); for (Object checkClassesOrObject : checkClassesOrObjects) { String engineKey = annotatedEngineKey(checkClassesOrObject); if (engineKey != null) { checksByEngineKey.put(engineKey, checkClassesOrObject); }//w w w.j a v a2 s . c om } for (ActiveRule activeRule : activeRules.findByRepository(repository)) { String engineKey = StringUtils.defaultIfBlank(activeRule.templateRuleKey(), activeRule.ruleKey().rule()); Object checkClassesOrObject = checksByEngineKey.get(engineKey); if (checkClassesOrObject != null) { Object obj = instantiate(activeRule, checkClassesOrObject); add(activeRule.ruleKey(), (C) obj); } } return this; }
From source file:org.sonar.api.batch.rule.internal.NewActiveRule.java
public NewActiveRule setSeverity(@Nullable String severity) { this.severity = StringUtils.defaultIfBlank(severity, Severity.defaultSeverity()); return this; }
From source file:org.sonar.api.batch.rule.internal.NewRule.java
public NewRule setSeverity(@Nullable String severity) { this.severity = StringUtils.defaultIfBlank(severity, DEFAULT_SEVERITY); return this; }
From source file:org.sonar.api.config.PropertyDefinitions.java
private PropertyDefinitions add(PropertyDefinition definition, String defaultCategory) { if (!definitions.containsKey(definition.getKey())) { definitions.put(definition.getKey(), definition); categories.put(definition.getKey(), StringUtils.defaultIfBlank(definition.getCategory(), defaultCategory)); if (!Strings.isNullOrEmpty(definition.getDeprecatedKey()) && !definition.getDeprecatedKey().equals(definition.getKey())) { deprecatedKeys.put(definition.getDeprecatedKey(), definition.getKey()); }/* www .ja v a 2 s. c o m*/ } return this; }
From source file:org.sonar.batch.bootstrap.GlobalTempFolderProvider.java
public TempFolder provide(GlobalProperties bootstrapProps) { if (tempFolder == null) { String workingPathName = StringUtils.defaultIfBlank( bootstrapProps.property(CoreProperties.GLOBAL_WORKING_DIRECTORY), CoreProperties.GLOBAL_WORKING_DIRECTORY_DEFAULT_VALUE); Path workingPath = Paths.get(workingPathName); if (!workingPath.isAbsolute()) { Path home = findSonarHome(bootstrapProps); workingPath = home.resolve(workingPath).normalize(); }/* w w w. j a va 2s .c o m*/ try { cleanTempFolders(workingPath); } catch (IOException e) { LOG.error(String.format("failed to clean global working directory: %s", workingPath), e); } Path tempDir = createTempFolder(workingPath); tempFolder = new DefaultTempFolder(tempDir.toFile(), true); } return tempFolder; }