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

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

Introduction

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

Prototype

public static String defaultString(final String str) 

Source Link

Document

Returns either the passed in String, or if the String is null , an empty String ("").

 StringUtils.defaultString(null)  = "" StringUtils.defaultString("")    = "" StringUtils.defaultString("bat") = "bat" 

Usage

From source file:com.mirth.connect.donkey.server.queue.DestinationQueue.java

public DestinationQueue(String groupBy, int threadCount, boolean regenerateTemplate, Serializer serializer,
        MessageMaps messageMaps) {/*from   ww  w  .ja  va2s . co m*/
    this.groupBy = StringUtils.defaultString(groupBy);
    this.regenerateTemplate = regenerateTemplate;
    this.serializer = serializer;
    this.messageMaps = messageMaps;

    if (StringUtils.isNotBlank(groupBy)) {
        queueBuckets = threadCount;

        if (queueBuckets > 1) {
            queueThreadIds = new ArrayList<Long>(queueBuckets);
            hashFunction = Hashing.murmur3_32((int) System.currentTimeMillis());
            initialThreadAssignmentMap = new ConcurrentHashMap<String, Integer>(queueBuckets);
        }
    }
}

From source file:de.escalon.hypermedia.affordance.PartialUriTemplateComponents.java

/**
 * Concatenates all components to uri String.
 *
 * @return uri String/*w  w w  .j  av  a  2 s .c o m*/
 */
public String toString() {
    return baseUri + StringUtils.defaultString(getQuery()) + StringUtils.defaultString(fragmentIdentifier);
}

From source file:com.netsteadfast.greenstep.util.UploadSupportUtils.java

public static String getViewMode(String fileShowName) throws Exception {
    String viewMode = YesNo.NO;/*from  w  w w  . j  a v  a  2  s.com*/
    String fileExtensionName = StringUtils.defaultString(getFileExtensionName(fileShowName)).trim()
            .toLowerCase();
    for (int i = 0; VIEW_MODE_FILE_EXTENSION != null && i < VIEW_MODE_FILE_EXTENSION.length; i++) {
        if (VIEW_MODE_FILE_EXTENSION[i].toLowerCase().equals(fileExtensionName)) {
            viewMode = YesNo.YES;
        }
    }
    return viewMode;
}

From source file:models.base.ViewModel.java

@Override
public int hashCode() {
    return StringUtils.defaultString(this.type).hashCode();
}

From source file:ca.uhn.fhir.jpa.dao.FhirSearchDao.java

private void addTextSearch(QueryBuilder theQueryBuilder, BooleanJunction<?> theBoolean,
        List<List<? extends IQueryParameterType>> theTerms, String theFieldName) {
    if (theTerms == null) {
        return;//from  w ww.  jav  a 2 s.  c  o  m
    }
    for (List<? extends IQueryParameterType> nextAnd : theTerms) {
        Set<String> terms = new HashSet<String>();
        for (IQueryParameterType nextOr : nextAnd) {
            StringParam nextOrString = (StringParam) nextOr;
            String nextValueTrimmed = StringUtils.defaultString(nextOrString.getValue()).trim();
            if (isNotBlank(nextValueTrimmed)) {
                terms.add(nextValueTrimmed);
            }
        }
        if (terms.isEmpty() == false) {
            String joinedTerms = StringUtils.join(terms, ' ');
            theBoolean
                    .must(theQueryBuilder.keyword().onField(theFieldName).matching(joinedTerms).createQuery());
        }
    }
}

From source file:net.andydvorak.intellij.lessc.fs.VirtualFileLocationChange.java

@Override
public int hashCode() {
    int result = StringUtils.defaultString(cssRootDir.getPath()).hashCode();
    result = 31 * result + StringUtils.defaultString(oldFile.getPath()).hashCode();
    result = 31 * result + StringUtils.defaultString(newParent.getPath()).hashCode();
    return result;
}

From source file:ca.uhn.fhir.rest.param.TokenParam.java

/**
 * {@inheritDoc}//w  ww. j av  a2 s. com
 */
@Override
String doGetValueAsQueryToken(FhirContext theContext) {
    if (getSystem() != null) {
        return ParameterUtil.escape(StringUtils.defaultString(getSystem())) + '|'
                + ParameterUtil.escape(getValue());
    } else {
        return ParameterUtil.escape(getValue());
    }
}

From source file:ca.uhn.fhir.jpa.dao.FulltextSearchSvcImpl.java

private void addTextSearch(QueryBuilder theQueryBuilder, BooleanJunction<?> theBoolean,
        List<List<? extends IQueryParameterType>> theTerms, String theFieldName, String theFieldNameEdgeNGram,
        String theFieldNameNGram) {
    if (theTerms == null) {
        return;//from  www.ja  v a 2s . co m
    }
    for (List<? extends IQueryParameterType> nextAnd : theTerms) {
        Set<String> terms = new HashSet<String>();
        for (IQueryParameterType nextOr : nextAnd) {
            StringParam nextOrString = (StringParam) nextOr;
            String nextValueTrimmed = StringUtils.defaultString(nextOrString.getValue()).trim();
            if (isNotBlank(nextValueTrimmed)) {
                terms.add(nextValueTrimmed);
            }
        }
        if (terms.isEmpty() == false) {
            if (terms.size() == 1) {
                //@formatter:off
                Query textQuery = theQueryBuilder.phrase().withSlop(2).onField(theFieldName).boostedTo(4.0f)
                        //                  .andField(theFieldNameEdgeNGram).boostedTo(2.0f)
                        //                  .andField(theFieldNameNGram).boostedTo(1.0f)
                        .sentence(terms.iterator().next().toLowerCase()).createQuery();
                //@formatter:on

                theBoolean.must(textQuery);
            } else {
                String joinedTerms = StringUtils.join(terms, ' ');
                theBoolean.must(
                        theQueryBuilder.keyword().onField(theFieldName).matching(joinedTerms).createQuery());
            }
        }
    }
}

From source file:io.wcm.tooling.commons.contentpackagebuilder.PackageMetadata.java

/**
 * @return Variables for placeholder replacement in package metadata.
 *//*  w w w . j  a  v a 2  s .c  o  m*/
public Map<String, Object> getVars() {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(created);
    return ImmutableMap.<String, Object>builder().put("group", StringUtils.defaultString(group))
            .put("name", StringUtils.defaultString(name))
            .put("description", StringUtils.defaultString(description))
            .put("path", "/etc/packages/" + group + "/" + name + ".zip")
            .put("created", ISO8601.format(calendar)).put("createdBy", StringUtils.defaultString(createdBy))
            .put("version", StringUtils.defaultString(version))
            .put("acHandling", acHandling != null ? acHandling.getMode() : "").build();
}

From source file:com.netsteadfast.greenstep.sys.GreenStepBaseFormAuthenticationFilter.java

protected AuthenticationToken createToken(ServletRequest request, ServletResponse response) {
    String username = StringUtils.defaultString(this.getUsername(request));
    String password = StringUtils.defaultString(this.getPassword(request));
    String captcha = StringUtils.defaultString(this.getCaptcha(request));
    //boolean rememberMe = StringUtils.defaultString(isRememberMe(request));
    boolean rememberMe = false;
    String host = StringUtils.defaultString(getHost(request));
    return new GreenStepBaseUsernamePasswordToken(username,
            SimpleUtils.toMD5Hex(SimpleUtils.toB64(password)).toCharArray(), rememberMe, host, captcha);
}