List of usage examples for org.apache.commons.lang StringUtils defaultIfEmpty
public static String defaultIfEmpty(String str, String defaultStr)
Returns either the passed in String, or if the String is empty or null
, the value of defaultStr
.
From source file:com.canoo.webtest.steps.store.BaseStoreStep.java
/** * Stores the property value/*from www . j a v a 2s.c o m*/ * @param value the value to store * @param defaultName the name to use to store the property if no * property name is configured */ protected void storeProperty(final String value, final String defaultName) { fComputedValue = value; final String propertyName = StringUtils.defaultIfEmpty(getProperty(), defaultName); setWebtestProperty(propertyName, value, getPropertyType()); }
From source file:edu.wisc.my.portlets.bookmarks.web.NewFolderFormController.java
/** * @see org.springframework.web.portlet.mvc.SimpleFormController#onSubmitAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse, java.lang.Object, org.springframework.validation.BindException) *//*from w w w.j a v a 2 s . co m*/ @Override protected void onSubmitAction(ActionRequest request, ActionResponse response, Object command, BindException errors) throws Exception { final String targetParentPath = StringUtils.defaultIfEmpty(request.getParameter("folderPath"), null); //User edited bookmark final Folder commandFolder = (Folder) command; //Get the BookmarkSet from the store final BookmarkSet bs = this.bookmarkSetRequestResolver.getBookmarkSet(request); //Ensure the created & modified dates are set correctly commandFolder.setCreated(new Date()); commandFolder.setModified(commandFolder.getCreated()); final Folder targetParent; if (targetParentPath != null) { //Get the target parent folder final IdPathInfo targetParentPathInfo = FolderUtils.getEntryInfo(bs, targetParentPath); if (targetParentPathInfo == null || targetParentPathInfo.getTarget() == null) { throw new IllegalArgumentException("The specified parent Folder does not exist. BaseFolder='" + bs + "' and idPath='" + targetParentPath + "'"); } targetParent = (Folder) targetParentPathInfo.getTarget(); } else { targetParent = bs; } final Map<Long, Entry> targetChildren = targetParent.getChildren(); //Add the new bookmark to the target parent targetChildren.put(commandFolder.getId(), commandFolder); //Persist the changes to the BookmarkSet this.bookmarkStore.storeBookmarkSet(bs); }
From source file:com.adobe.acs.commons.replication.impl.AgentHostsImpl.java
@Override public final List<String> getHosts(final AgentFilter agentFilter) { final List<String> hosts = new ArrayList<String>(); final Map<String, Agent> agents = agentManager.getAgents(); for (final Agent agent : agents.values()) { if (!agentFilter.isIncluded(agent)) { continue; }//w ww. j a va 2s . c o m try { final URI uri = new URI(agent.getConfiguration().getTransportURI()); String tmp = StringUtils.defaultIfEmpty(uri.getScheme(), DEFAULT_SCHEME) + "://" + uri.getHost(); if (uri.getPort() > 0) { tmp += ":" + uri.getPort(); } hosts.add(tmp); } catch (URISyntaxException e) { log.error("Unable to extract a scheme/host/port from Agent transport URI [ {} ]", agent.getConfiguration().getTransportURI()); } } return hosts; }
From source file:com.adobe.acs.commons.analysis.jcrchecksum.impl.options.RequestChecksumGeneratorOptions.java
private static Set<String> getPathsFromQuery(ResourceResolver resourceResolver, String language, String query) { if (StringUtils.isBlank(query)) { return Collections.EMPTY_SET; }//w ww . j a v a 2 s.c o m Set<String> paths = new HashSet<String>(); language = StringUtils.defaultIfEmpty(language, "xpath"); Iterator<Resource> resources = resourceResolver.findResources(query, language); while (resources.hasNext()) { paths.add(resources.next().getPath()); } return paths; }
From source file:edu.wisc.my.portlets.bookmarks.web.NewBookmarkFormController.java
/** * @see org.springframework.web.portlet.mvc.SimpleFormController#onSubmitAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse, java.lang.Object, org.springframework.validation.BindException) *//*w ww .j a va 2 s.c om*/ @Override protected void onSubmitAction(ActionRequest request, ActionResponse response, Object command, BindException errors) throws Exception { final String targetParentPath = StringUtils.defaultIfEmpty(request.getParameter("folderPath"), null); //User edited bookmark final Bookmark commandBookmark = (Bookmark) command; //Get the BookmarkSet from the store final BookmarkSet bs = this.bookmarkSetRequestResolver.getBookmarkSet(request); //Ensure the created & modified dates are set correctly commandBookmark.setCreated(new Date()); commandBookmark.setModified(commandBookmark.getCreated()); final Folder targetParent; if (targetParentPath != null) { //Get the target parent folder final IdPathInfo targetParentPathInfo = FolderUtils.getEntryInfo(bs, targetParentPath); if (targetParentPathInfo == null || targetParentPathInfo.getTarget() == null) { throw new IllegalArgumentException("The specified parent Folder does not exist. BaseFolder='" + bs + "' and idPath='" + targetParentPath + "'"); } targetParent = (Folder) targetParentPathInfo.getTarget(); } else { targetParent = bs; } final Map<Long, Entry> targetChildren = targetParent.getChildren(); //Add the new bookmark to the target parent targetChildren.put(commandBookmark.getId(), commandBookmark); //Persist the changes to the BookmarkSet this.bookmarkStore.storeBookmarkSet(bs); }
From source file:com.gst.portfolio.fund.domain.Fund.java
private Fund(final String fundName, final String externalId) { this.name = StringUtils.defaultIfEmpty(fundName, null); this.externalId = StringUtils.defaultIfEmpty(externalId, null); }
From source file:com.atlassian.plugins.studio.storage.toolkit.impl.DefaultStorageFacadeImpl.java
private String getKey(String key) { return new StringBuilder().append(StringUtils.defaultIfEmpty(instanceId.getKeyPrefix(), "")).append(key) .toString();/*w w w. java2 s. c o m*/ }
From source file:com.homeadvisor.kafdrop.config.ini.IniFileReader.java
public IniFileProperties read(Reader input) throws IOException { final BufferedReader reader = new BufferedReader(input); final IniFileProperties properties = new IniFileProperties(); String currentSection = null; String line;/*from w w w .j av a2s . c o m*/ while ((line = reader.readLine()) != null) { line = line.trim(); if (!isCommentLine(line)) { if (isSectionLine(line)) { currentSection = line.substring(1, line.length() - 1); } else { String key = ""; String value = ""; int index = findSeparator(line); if (index >= 0) { key = line.substring(0, index); value = parseValue(line.substring(index + 1), reader); } else { key = line; } key = StringUtils.defaultIfEmpty(key.trim(), " "); properties.addSectionProperty(currentSection, key, value); } } } return properties; }
From source file:com.predic8.membrane.core.rules.ServiceProxyKey.java
@Override public String toString() { return (host.equals("*") ? "" : host + " ") + (method.equals("*") ? "" : method + " ") + StringUtils.defaultIfEmpty(getPath(), "") + ":" + port; }
From source file:com.appleframework.monitor.model.MetricDogTest.java
public void test_make_alert() throws Exception { assertEquals("", StringUtils.defaultIfEmpty(null, "")); }