Example usage for org.apache.commons.lang ObjectUtils defaultIfNull

List of usage examples for org.apache.commons.lang ObjectUtils defaultIfNull

Introduction

In this page you can find the example usage for org.apache.commons.lang ObjectUtils defaultIfNull.

Prototype

public static <T> T defaultIfNull(T object, T defaultValue) 

Source Link

Document

Returns a default value if the object passed is null.

 ObjectUtils.defaultIfNull(null, null)      = null ObjectUtils.defaultIfNull(null, "")        = "" ObjectUtils.defaultIfNull(null, "zz")      = "zz" ObjectUtils.defaultIfNull("abc", *)        = "abc" ObjectUtils.defaultIfNull(Boolean.TRUE, *) = Boolean.TRUE 

Usage

From source file:com.opengamma.id.VersionCorrection.java

/**
 * Gets a string representation of the version as of instant.
 * <p>//  w  w  w  . j ava  2 s .  c  o  m
 * This is either the ISO-8601 representation of the version as of instant,
 * such as {@code 2011-02-01T12:30:40Z}, or {@code LATEST} for null.
 * 
 * @return the string version as of, not null
 */
public String getVersionAsOfString() {
    return ObjectUtils.defaultIfNull(_versionAsOf, "LATEST").toString();
}

From source file:com.opengamma.id.VersionCorrection.java

/**
 * Gets a string representation of the corrected to instant.
 * <p>/* w w w  . j  a  v  a 2s . c  o  m*/
 * This is either the ISO-8601 representation of the corrected to instant,
 * such as {@code 2011-02-01T12:30:40Z}, or {@code LATEST} for null.
 * 
 * @return the string corrected to, not null
 */
public String getCorrectedToString() {
    return ObjectUtils.defaultIfNull(_correctedTo, "LATEST").toString();
}

From source file:com.apdplat.platform.struts.APDPlatPackageBasedActionConfigBuilder.java

protected ClassLoaderInterface getClassLoaderInterface() {
    if (isReloadEnabled())
        return new ClassLoaderInterfaceDelegate(this.reloadingClassLoader);
    else {//from   w w w.  j a va2  s  . co m
        /*
        if there is a ClassLoaderInterface in the context, use it, otherwise
        default to the default ClassLoaderInterface (a wrapper around the current
        thread classloader)
        using this, other plugins (like OSGi) can plugin their own classloader for a while
        and it will be used by Convention (it cannot be a bean, as Convention is likely to be
        called multiple times, and it needs to use the default ClassLoaderInterface during normal startup)
        */
        ClassLoaderInterface classLoaderInterface = null;
        ActionContext ctx = ActionContext.getContext();
        if (ctx != null)
            classLoaderInterface = (ClassLoaderInterface) ctx.get(ClassLoaderInterface.CLASS_LOADER_INTERFACE);

        return (ClassLoaderInterface) ObjectUtils.defaultIfNull(classLoaderInterface,
                new ClassLoaderInterfaceDelegate(getClassLoader()));
    }
}

From source file:edu.duke.cabig.c3pr.webservice.integration.StudyImportExportWebServiceTest.java

/**
 * @param xmlDataSetBaseName//from   w ww  .j  av a 2 s . com
 * @return
 * @throws IOException
 * @throws DataSetException
 */
private IDataSet getExpectedDataSet(final String xmlDataSetBaseName, String appendix)
        throws IOException, DataSetException {
    final String prefix = DBUNIT_DATASET_PREFIX;
    IDataSet expectedDataSet = new FlatXmlDataSet((InputStream) ObjectUtils.defaultIfNull(
            getClass().getResourceAsStream(prefix + xmlDataSetBaseName + appendix + ".xml"),
            getClass().getResourceAsStream(prefix + xmlDataSetBaseName + ".xml")));
    return expectedDataSet;
}

From source file:com.gst.infrastructure.core.api.JsonCommand.java

/**
 * always returns true or false/* w  ww  . j a  v  a 2 s. c om*/
 */
public boolean booleanPrimitiveValueOfParameterNamed(final String parameterName) {
    final Boolean value = this.fromApiJsonHelper.extractBooleanNamed(parameterName, this.parsedCommand);
    return (Boolean) ObjectUtils.defaultIfNull(value, Boolean.FALSE);
}

From source file:com.gst.infrastructure.campaigns.sms.domain.SmsCampaign.java

public LocalDate getSubmittedOnDate() {
    return (LocalDate) ObjectUtils.defaultIfNull(new LocalDate(this.submittedOnDate), null);

}

From source file:com.gst.infrastructure.campaigns.sms.domain.SmsCampaign.java

public LocalDate getClosureDate() {
    return (LocalDate) ObjectUtils.defaultIfNull(new LocalDate(this.closureDate), null);
}

From source file:com.gst.infrastructure.campaigns.sms.domain.SmsCampaign.java

public LocalDate getRecurrenceStartDate() {
    return (LocalDate) ObjectUtils.defaultIfNull(new LocalDate(this.recurrenceStartDate), null);
}

From source file:com.gst.infrastructure.campaigns.sms.domain.SmsCampaign.java

public LocalDateTime getRecurrenceStartDateTime() {
    return (LocalDateTime) ObjectUtils.defaultIfNull(new LocalDateTime(this.recurrenceStartDate), null);
}

From source file:com.gst.infrastructure.campaigns.sms.domain.SmsCampaign.java

public LocalDateTime getNextTriggerDate() {
    return (LocalDateTime) ObjectUtils.defaultIfNull(new LocalDateTime(this.nextTriggerDate), null);

}