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:net.desgrange.pwad.service.UrlUtils.java
public static String getPathElement(final String url, final int elementPosition) { try {// ww w . ja v a 2 s . c om final String[] explodedPath = new URI(url).getPath().split("/"); return StringUtils.defaultIfEmpty(explodedPath[elementPosition + 1], null); } catch (final IndexOutOfBoundsException e) { return null; } catch (final URISyntaxException e) { throw new BadUrlException(e); } catch (final NullPointerException e) { throw new BadUrlException(e); } }
From source file:com.adaptris.mail.SubjectFilter.java
@Override List<String> getHeaders(Message m) throws MessagingException { return Arrays.asList(new String[] { StringUtils.defaultIfEmpty(m.getSubject(), "") }); }
From source file:net.ageto.gyrex.impex.impl.internal.ImpexProcessStepRunEnvironment.java
/** * Process run id generator/* ww w . ja v a 2s .co m*/ * * @param processId * @return */ private String generateProcessRunID(String processId) { return new Date().getTime() + "-" + StringUtils.defaultIfEmpty(processId, "UNKNOWN"); }
From source file:com.qualitesys.sonarqcr4pblplugin.pbl.PblPackage.java
public PblPackage(String key) { super(); setKey(StringUtils.defaultIfEmpty(StringUtils.trim(key), DEFAULT_PACKAGE_NAME)); }
From source file:net.desgrange.pwad.service.UrlUtils.java
public static String parseInvitationLink(final String url) { final String userName = StringUtils.defaultIfEmpty(getParameter(url, "uname"), getPathElement(url, 0)); final String albumName = getPathElement(url, 1); final String targetType = UrlUtils.getParameter(url, "target"); final String targetId = UrlUtils.getParameter(url, "id"); final String authKey = UrlUtils.getParameter(url, "authkey"); if (StringUtils.isBlank(userName)) { throw new BadUrlException("The link provided is not supported."); }// w w w. jav a 2 s .com if (!"ALBUM".equalsIgnoreCase(targetType) && StringUtils.isEmpty(albumName)) { throw new BadUrlException("The link provided is not supported."); } final StringBuilder albumUrl = new StringBuilder("http://picasaweb.google.com/data/feed/api"); albumUrl.append("/user/").append(userName); if (StringUtils.isNotBlank(targetType)) { albumUrl.append("/albumid/").append(targetId); } else { albumUrl.append("/album/").append(albumName); } albumUrl.append("?kind=photo&imgmax=d"); albumUrl.append("&max-results=").append(Short.MAX_VALUE); if (StringUtils.isNotBlank(authKey)) { albumUrl.append("&authkey=").append(authKey); } return albumUrl.toString(); }
From source file:com.predic8.membrane.core.rules.ProxyRule.java
@Override public String getName() { return StringUtils.defaultIfEmpty(name, getKey().toString()); }
From source file:mobile.vo.group.GroupVO.java
public static GroupVO create(vo.GroupVO source) { GroupVO vo = new GroupVO(); vo.id = source.getId();/*w w w. j a v a2 s. co m*/ vo.groupName = source.getGroupName(); vo.countMem = source.getCountMem(); vo.createDate = new DateTime(source.getCreateDate()).toString("yyyy-MM-dd HH:mm:ss"); vo.headUrl = source.getHeadUrl(); vo.industryId = source.getIndustryId(); vo.industryName = source.getIndustryName(); vo.groupInfo = StringUtils.defaultIfEmpty(source.getGroupInfo(), ""); vo.skillsTags = source.getTags(); GroupPriv priv = GroupPriv.getByName(source.getGroupPriv()); if (null != priv) { vo.groupPriv = priv.toString(); } vo.maxMemberNum = source.getMaxMemberNum(); vo.isJoin = source.getIsJoin(); Type tp = Type.getByName(source.getType()); if (null != tp) { vo.type = tp.toString(); } User user = User.getFromSession(Context.current().session()); if (null != user && tp == Type.NORMAL) { vo.isOwner = Objects.equals(user.getId(), source.getOwnerId()); } return vo; }
From source file:de.thischwa.pmcms.model.domain.pojo.Site.java
@Override public String getDecorationString() { String deco = StringUtils.defaultIfEmpty(title, name); return deco; }
From source file:com.adobe.acs.tools.csv_resource_type_updater.impl.Parameters.java
public Parameters(SlingHttpServletRequest request) throws IOException { super(request); final RequestParameter pathParam = request.getRequestParameter("path"); final RequestParameter propertyNameParam = request.getRequestParameter("propertyName"); this.path = DEFAULT_PATH; if (pathParam != null) { this.path = StringUtils.defaultIfEmpty(pathParam.toString(), DEFAULT_PATH); }// ww w .j a v a 2 s .co m this.propertyName = DEFAULT_PROPERTY_NAME; if (propertyNameParam != null) { this.propertyName = StringUtils.defaultIfEmpty(propertyNameParam.toString(), DEFAULT_PROPERTY_NAME); } }
From source file:de.thischwa.pmcms.tool.ToolVersionInfo.java
private static Map<TYPE, String> generateInfo(final Class<?> cls) { Map<TYPE, String> info = new HashMap<TYPE, String>(2); info.put(TYPE.title, StringUtils.defaultIfEmpty(cls.getPackage().getImplementationTitle(), "Unknown")); String version = StringUtils.defaultIfEmpty(cls.getPackage().getImplementationVersion(), cls.getPackage().getSpecificationVersion()); info.put(TYPE.version, StringUtils.defaultIfEmpty(version, "n/n")); return info;/*from ww w. ja v a 2 s.c o m*/ }