List of usage examples for org.apache.commons.lang3 StringUtils defaultIfBlank
public static <T extends CharSequence> T defaultIfBlank(final T str, final T defaultStr)
Returns either the passed in CharSequence, or if the CharSequence is whitespace, empty ("") or null , the value of defaultStr .
StringUtils.defaultIfBlank(null, "NULL") = "NULL" StringUtils.defaultIfBlank("", "NULL") = "NULL" StringUtils.defaultIfBlank(" ", "NULL") = "NULL" StringUtils.defaultIfBlank("bat", "NULL") = "bat" StringUtils.defaultIfBlank("", null) = null
From source file:com.javacreed.examples.maven.Example.java
public static void main(final String[] args) { final String message = null; System.out.println(StringUtils.defaultIfBlank(message, "Hello :)")); }
From source file:net.eledge.android.toolkit.db.internal.SQLBuilder.java
public static String getFieldName(Field field) { Column column = field.getAnnotation(Column.class); return StringUtils.defaultIfBlank(column.name(), field.getName().toLowerCase(Locale.ENGLISH)); }
From source file:net.eledge.android.toolkit.db.internal.SQLBuilder.java
public static String getFieldName(Field field, Column column) { return StringUtils.defaultIfBlank(column.name(), field.getName().toLowerCase(Locale.ENGLISH)); }
From source file:de.blizzy.documentr.web.util.FacadeHostRequestWrapper.java
public static String buildFacadeUrl(String url, String contextPath, String documentrHost) { contextPath = StringUtils.defaultIfBlank(contextPath, StringUtils.EMPTY); if (contextPath.equals("/")) { //$NON-NLS-1$ contextPath = StringUtils.EMPTY; }//from ww w. ja va 2 s .c o m String newUrl; if (StringUtils.isNotBlank(contextPath)) { int pos = url.indexOf(contextPath); newUrl = documentrHost + url.substring(pos + contextPath.length()); } else { UriComponentsBuilder builder; try { builder = UriComponentsBuilder.fromHttpUrl(url); } catch (IllegalArgumentException e) { builder = UriComponentsBuilder.fromUriString(url); } String path = StringUtils.defaultIfBlank(builder.build().getPath(), StringUtils.EMPTY); if (StringUtils.isNotBlank(path)) { int pos = StringUtils.lastIndexOf(url, path); newUrl = documentrHost + url.substring(pos); } else { newUrl = documentrHost; } } return newUrl; }
From source file:de.blizzy.backup.vfs.ftp.FtpLocation.java
static FtpLocation getLocation(IDialogSettings section, FtpLocationProvider provider) { String login = StringUtils.defaultIfBlank(section.get("login"), null); //$NON-NLS-1$ String password = StringUtils.defaultIfBlank(section.get("password"), null); //$NON-NLS-1$ return new FtpLocation(section.get("host"), Integer.parseInt(section.get("port")), //$NON-NLS-1$ //$NON-NLS-2$ login, password, section.get("folder"), provider); //$NON-NLS-1$ }
From source file:com.github.ferstl.depgraph.dependency.style.Graph.java
void merge(Graph other) { this.rankdir = StringUtils.defaultIfBlank(other.rankdir, this.rankdir); }
From source file:net.eledge.android.toolkit.db.internal.SQLBuilder.java
public static String getTableName(Class<?> clazz) { Entity entity = clazz.getAnnotation(Entity.class); return StringUtils.defaultIfBlank(entity.name(), clazz.getName().toLowerCase(Locale.ENGLISH)); }
From source file:com.github.ferstl.depgraph.dependency.style.Font.java
void merge(Font other) { this.color = StringUtils.defaultIfBlank(other.color, this.color); this.size = other.size != null ? other.size : this.size; this.name = StringUtils.defaultIfBlank(other.name, this.name); }
From source file:kenh.expl.functions.DefaultIfBlank.java
public String process(String str, String defaultStr) { return StringUtils.defaultIfBlank(str, defaultStr); }
From source file:com.github.ferstl.depgraph.dependency.style.Edge.java
void merge(Edge other) { this.style = StringUtils.defaultIfBlank(other.style, this.style); this.color = StringUtils.defaultIfBlank(other.color, this.color); this.font.merge(other.font); }