Example usage for org.apache.commons.lang3 StringUtils defaultIfEmpty

List of usage examples for org.apache.commons.lang3 StringUtils defaultIfEmpty

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils defaultIfEmpty.

Prototype

public static <T extends CharSequence> T defaultIfEmpty(final T str, final T defaultStr) 

Source Link

Document

Returns either the passed in CharSequence, or if the CharSequence is empty or null , the value of defaultStr .

 StringUtils.defaultIfEmpty(null, "NULL")  = "NULL" StringUtils.defaultIfEmpty("", "NULL")    = "NULL" StringUtils.defaultIfEmpty(" ", "NULL")   = " " StringUtils.defaultIfEmpty("bat", "NULL") = "bat" StringUtils.defaultIfEmpty("", null)      = null 

Usage

From source file:yoyo.actor.screen.iface.jsf.application.GlobalAction.java

/**
 * default if empty./*w  w  w. j ava2  s  . co  m*/
 * @param aValue value
 * @return default if empty
 */
@SuppressWarnings("static-method")
public String defaultIfEmpty(final String aValue) {
    return StringUtils.defaultIfEmpty(aValue, FacesProfile.VIEW_NULL);
}

From source file:yoyo.actor.screen.iface.jsf.conversation.master.CustomerAction.java

/** {@inheritDoc} */
@Override/* w  w  w.jav  a2 s. co m*/
protected boolean beforeSave() {
    final Customer c = getSelected();
    c.getAddress().setName(StringUtils.defaultIfEmpty(c.getAddress().getName(), c.getOfficialName()));
    c.getContact().setName(StringUtils.defaultIfEmpty(c.getContact().getName(), c.getOfficialName()));
    return super.beforeSave();
}

From source file:yoyo.actor.screen.iface.jsf.conversation.master.PartnerAction.java

/** {@inheritDoc} */
@Override// www.j ava 2  s  .c o m
protected boolean beforeSave() {
    final Partner c = getSelected();
    c.getContact().setName(StringUtils.defaultIfEmpty(c.getContact().getName(), c.getFamilyName()));
    return super.beforeSave();
}

From source file:yoyo.actor.screen.iface.jsf.conversation.master.SupplierAction.java

/** {@inheritDoc} */
@Override/*from  w  w w . j a  v  a 2s.c  o m*/
protected boolean beforeSave() {
    final Supplier c = getSelected();
    c.getAddress().setName(StringUtils.defaultIfEmpty(c.getAddress().getName(), c.getOfficialName()));
    c.getContact().setName(StringUtils.defaultIfEmpty(c.getContact().getName(), c.getOfficialName()));
    return super.beforeSave();
}