Example usage for org.springframework.util StringUtils isEmpty

List of usage examples for org.springframework.util StringUtils isEmpty

Introduction

In this page you can find the example usage for org.springframework.util StringUtils isEmpty.

Prototype

public static boolean isEmpty(@Nullable Object str) 

Source Link

Document

Check whether the given object (possibly a String ) is empty.

Usage

From source file:uk.ac.ebi.ep.parser.parsers.CompoundParser.java

/**
 * Searches a compound name in ChEBI. Please note that if the name does not
 * match <i>exactly</i> any names/synonyms returned by ChEBI, the result
 * will be <code>null</code>.
 *
 * @param moleculeName the compound name.
 * @return an entry with a ChEBI ID, or <code>null</code> if not found.
 *///from  w  ww.  ja  va2s.com
protected EnzymePortalCompound searchMoleculeInChEBI(String moleculeName) {

    EnzymePortalCompound entry = null;
    // Sometimes moleculeName comes as "moleculeName (ACRONYM)"
    // sometimes as "moleculeName (concentration)":
    Matcher m = COMPOUND_NAME_PATTERN.matcher(moleculeName);
    m.matches(); // always
    String[] nameAcronym = { m.group(1), m.group(2) };
    // first name, then acronym (if any):
    nameLoop: for (String name : nameAcronym) {
        if (name == null) {
            continue; // acronym, usually
        }
        try {
            LiteEntityList lites = chebiWsClient.getLiteEntity(name, SearchCategory.ALL_NAMES, 25,
                    StarsCategory.ALL);
            String chebiId = null;

            if (lites != null) {
                liteLoop: for (LiteEntity lite : lites.getListElement()) {
                    Entity completeEntity = chebiWsClient.getCompleteEntity(lite.getChebiId());
                    List<String> synonyms = new ArrayList<>();
                    for (DataItem dataItem : completeEntity.getSynonyms()) {
                        synonyms.add(dataItem.getData().toLowerCase());
                    }
                    List<String> formulae = new ArrayList<>();
                    for (DataItem formula : completeEntity.getFormulae()) {
                        formulae.add(formula.getData());
                    }
                    if (completeEntity.getChebiAsciiName().equalsIgnoreCase(name)
                            || synonyms.contains(name.toLowerCase()) || formulae.contains(name)) {
                        chebiId = completeEntity.getChebiId();
                    }
                    if (chebiId != null) {
                        break;
                    }
                }
            }

            if (chebiId != null && !blackList.contains(name) && !StringUtils.isEmpty(name)) {
                entry = new EnzymePortalCompound();
                entry.setCompoundSource(MmDatabase.ChEBI.name());
                entry.setCompoundId(chebiId);
                entry.setCompoundName(name);
                break;
            }
            //                else {
            //                    LOGGER.warn("Not found in ChEBI: " + name);
            //                }
        } catch (ChebiWebServiceFault_Exception e) {
            LOGGER.error("Searching for " + name, e);
        }
    }
    return entry;
}

From source file:com.biz.report.service.impl.ItemDashBoardServiceImpl.java

@Override
public List<SalesDTO> readByItemName(String itemName, String year, String month) {
    if (!StringUtils.isEmpty(month) && month.contains("[")) {
        month = month.substring(1, month.length() - 1);
    }/*from  w w  w.  j a v a 2  s .co m*/
    if (!StringUtils.isEmpty(itemName) && !itemName.contains("'")) {
        itemName = "'" + itemName + "'";
    }
    List list = itemDashBoardDao.readByItemName(itemName, year, month);
    List<SalesDTO> salesDTOs = new ArrayList<SalesDTO>();
    for (Object object : list) {
        SalesDTO salesDTO = constructorSalesDTO(object);
        salesDTOs.add(salesDTO);
    }
    return salesDTOs;
}

From source file:com.capitalone.dashboard.collector.TeamDataClient.java

/**
 * Retrieves the maximum change date for a given query.
 *
 * @return A list object of the maximum change date
 *///from  w ww .jav a2 s.c  om
@Override
public String getMaxChangeDate() {
    Collector col = featureCollectorRepository.findByName(FeatureCollectorConstants.VERSIONONE);
    if (col == null)
        return "";
    if (StringUtils.isEmpty(getFeatureSettings().getDeltaCollectorItemStartDate()))
        return "";

    List<ScopeOwnerCollectorItem> response = teamRepo.findTopByChangeDateDesc(col.getId(),
            getFeatureSettings().getDeltaCollectorItemStartDate());
    if (!CollectionUtils.isEmpty(response))
        return response.get(0).getChangeDate();
    return "";
}

From source file:de.metas.ui.web.config.WebuiExceptionHandler.java

private void addErrorDetails(final Map<String, Object> errorAttributes,
        final RequestAttributes requestAttributes, final boolean includeStackTrace) {
    Throwable error = getError(requestAttributes);
    if (error != null) {
        while (error instanceof ServletException && error.getCause() != null) {
            error = ((ServletException) error).getCause();
        }/*  w ww . j  a v  a 2s.  c o m*/
        errorAttributes.put(ATTR_Exception, error.getClass().getName());
        addErrorMessage(errorAttributes, error);
        if (includeStackTrace && !isExcludeFromLogging(error)) {
            addStackTrace(errorAttributes, error);
        }
    }

    final Object message = getAttribute(requestAttributes, RequestDispatcher.ERROR_MESSAGE);
    if ((!StringUtils.isEmpty(message) || errorAttributes.get(ATTR_Message) == null)
            && !(error instanceof BindingResult)) {
        errorAttributes.put(ATTR_Message, StringUtils.isEmpty(message) ? "No message available" : message);
    }
}

From source file:com.baidu.rigel.biplatform.tesseract.node.service.impl.IsNodeServiceImpl.java

@Override
public List<Node> getNodeListByClusterName(String clusterName) {
    if (StringUtils.isEmpty(clusterName)) {
        throw new IllegalArgumentException();
    }/* ww  w  .  ja  v a2 s  .c o  m*/
    String storeKey = Md5Util.encode(clusterName);
    List<Node> result = new ArrayList<Node>();
    result = super.getStoreMetaListByStoreKey(Node.getDataStoreName(), storeKey);
    if (result == null) {
        LOGGER.info("Can not find any node for Cluster:[" + clusterName + "]");
    }
    return result;
}

From source file:com.caocao.web.control.DriverManageController.java

private List<String> check(Driver driver) {
    List<String> errors = new ArrayList<String>();
    if (StringUtils.isEmpty(driver.getName())) {
        errors.add("????????");
    }//from w w w . ja  va  2 s . c o m
    return errors;
}

From source file:com.github.hateoas.forms.spring.uber.UberUtils.java

private static String getModelProperty(String href, ActionDescriptor actionDescriptor) {

    PartialUriTemplate uriTemplate = new PartialUriTemplate(href);
    RequestMethod httpMethod = RequestMethod.valueOf(actionDescriptor.getHttpMethod());
    final String model;
    switch (httpMethod) {
    case GET:/*from   ww  w. j a  va 2  s.com*/
    case DELETE: {
        model = buildModel(uriTemplate.getVariableNames(), "{?", ",", "}", "%s");
        break;
    }
    case POST:
    case PUT:
    case PATCH: {
        model = buildModel(uriTemplate.getVariableNames(), "", "&", "", "%s={%s}");
        break;
    }
    default:
        model = null;
    }
    return StringUtils.isEmpty(model) ? null : model;
}

From source file:com.pubkit.platform.messaging.protocol.pkmp.PKMPInBoundEventHandler.java

private void handleSubscribe(PKMPSubscribe subscribe, WebSocketSession session) {
    String topic = subscribe.getTopic();
    if (topic == null || StringUtils.isEmpty(topic)) {
        LOG.error("Client {" + subscribe.getClientId() + "} failed to subscribe topic {" + subscribe.getTopic()
                + "}. Invalid topic");

        PKMPSubsAck errorAck = new PKMPSubsAck(subscribe.getClientId(), topic, PKMPSubsAck.INVALID_TOPIC);
        sendPayload(errorAck, session);/*from  w  w w  .j a v a  2 s .  c o m*/

        return;
    }
    boolean tokenValid = validateAccessToken(subscribe.getClientId(), subscribe.getSessionToken(), session);
    if (!tokenValid) {
        LOG.error("Client {" + subscribe.getClientId() + "} failed to subscribe topic {" + topic
                + "}. Invalid token");
        PKMPSubsAck errorAck = new PKMPSubsAck(subscribe.getClientId(), topic, PKMPSubsAck.INVALID_TOKEN);
        sendPayload(errorAck, session);

        return;
    }

    PKMPConnection pKMPConnection = messageStoreService.getConnection(subscribe.getClientId());
    if (pKMPConnection != null && pKMPConnection.getSessionId().equals(session.getId())) {
        messageStoreService.subscribeTopic(topic, pKMPConnection);
        LOG.debug("Client id {" + subscribe.getClientId() + "} subscribed to topic {" + topic + "}");

        PKMPSubsAck pKMPSubsAck = new PKMPSubsAck(subscribe.getClientId(), topic);
        sendPayload(pKMPSubsAck, session);
    } else {
        LOG.error("Client {" + subscribe.getClientId() + "} failed to subscribe topic {" + topic
                + "}. No connection found so closing connection");

        PKMPSubsAck errorAck = new PKMPSubsAck(subscribe.getClientId(), topic, PKMPSubsAck.CONNECTION_ERROR);
        sendPayload(errorAck, session);
    }
}

From source file:com.biz.report.service.impl.CustomerServiceImpl.java

@Override
public List<ItemDTO> readByCustomerName(String customers, String year, String month) {
    if (!StringUtils.isEmpty(month) && month.contains("[")) {
        month = month.substring(1, month.length() - 1);
    }//from w  w  w.  j  a  v a 2s.  co  m
    if (!StringUtils.isEmpty(customers) && !customers.contains("'")) {
        customers = "'" + customers + "'";
    }
    List list = customerReportDao.readTableData(customers, year, month);
    List<ItemDTO> itemDTOs = new ArrayList<ItemDTO>();
    for (Object object : list) {
        ItemDTO itemDTO = constructItemDTO(object);
        itemDTOs.add(itemDTO);
    }
    return itemDTOs;
}

From source file:com.formkiq.core.util.Strings.java

/**
 * Returns whether String is empty or equals 'null'.
 * @param s {@link String}/*from   w  ww .ja  v  a 2  s  .  com*/
 * @return boolean
 */
public static boolean isEmpty(final String s) {
    return StringUtils.isEmpty(s) || "null".equals(s);
}