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:zipkin.autoconfigure.ui.ZipkinUiProperties.java

public void setLogsUrl(String logsUrl) {
    if (!StringUtils.isEmpty(logsUrl)) {
        this.logsUrl = logsUrl;
    }
}

From source file:fi.hsl.parkandride.core.domain.StrictIsoDateTimeDeserializer.java

public boolean isValid(String str) {
    return StringUtils.isEmpty(str) || PATTERN.matcher(str).matches();
}

From source file:org.obiba.mica.micaConfig.service.DataAccessFormService.java

public Optional<DataAccessForm> find() {
    DataAccessForm form = dataAccessFormRepository.findOne(DataAccessForm.DEFAULT_ID);
    if (form == null) {
        createOrUpdate(createDefaultDataAccessForm());
        form = dataAccessFormRepository.findOne(DataAccessForm.DEFAULT_ID);
    }//w ww . j  a  v a2s .c  o m
    if (StringUtils.isEmpty(form.getCsvExportFormat())) {
        form.setCsvExportFormat(getDefaultDataAccessFormResourceAsString("export-csv-schema.json"));
        form = createOrUpdate(form);
    }

    return Optional.ofNullable(form);
}

From source file:tools.datasync.db2db.net.SyncMessageType.java

public static SyncMessageType get(String message) {
    SyncMessageType result = UNKNOWN;

    if (StringUtils.isEmpty(message)) {
        return result;
    }//from w w w . ja  v  a2s .c  o  m

    if (BEGIN_SYNC.messageType.equalsIgnoreCase(message)) {
        result = BEGIN_SYNC;
    } else if (SYNC_OVER.messageType.equalsIgnoreCase(message)) {
        result = SYNC_OVER;
    } else if (ACK.messageType.equalsIgnoreCase(message)) {
        result = ACK;
    } else if (NACK.messageType.equalsIgnoreCase(message)) {
        result = NACK;
    } else if (BEGIN_SEED.messageType.equalsIgnoreCase(message)) {
        result = BEGIN_SEED;
    } else if (SEED.messageType.equalsIgnoreCase(message)) {
        result = SEED;
    } else if (SEED_OVER_INIT.messageType.equalsIgnoreCase(message)) {
        result = SEED_OVER_INIT;
    } else if (SEED_OVER_FOLLOW.messageType.equalsIgnoreCase(message)) {
        result = SEED_OVER_FOLLOW;
    } else if (ANALYSIS_STARTED.messageType.equalsIgnoreCase(message)) {
        result = ANALYSIS_STARTED;
    } else if (ANALYSIS_OVER.messageType.equalsIgnoreCase(message)) {
        result = ANALYSIS_OVER;
    } else if (CONFLICT_RESOLUTION.messageType.equalsIgnoreCase(message)) {
        result = CONFLICT_RESOLUTION;
    } else if (APPLY_CHANGES.messageType.equalsIgnoreCase(message)) {
        result = APPLY_CHANGES;
    } else if (APPLY_CHANGES_OVER.messageType.equalsIgnoreCase(message)) {
        result = APPLY_CHANGES_OVER;
    } else if (UNKNOWN.messageType.equalsIgnoreCase(message)) {
        result = UNKNOWN;
    } else {
        result = UNKNOWN;
    }
    return result;
}

From source file:gov.nyc.doitt.gis.geoclient.parser.test.ChunkSpecParser.java

public ChunkSpec parse(String id, String expectationText) throws TestConfigurationException {
    if (StringUtils.isEmpty(id)) {
        throw new TestConfigurationException("Parameter 'id' cannot be null or empty.");
    }/*from w ww .  ja  v a2  s .  c  o  m*/
    if (StringUtils.isEmpty(expectationText)) {
        throw new TestConfigurationException("Parameter 'unparsedString' cannot be null or empty.");
    }
    String[] splits = expectationText.split("=");

    if (splits.length == 1) {
        return createDefaultChunkSpec(id, splits[0]);
    }

    if (splits.length != 2) {
        throw new TestConfigurationException(String.format(
                "Parameter 'unparsedString(\"%s\")' cannot be split into exactly two strings on token '='.",
                expectationText));
    }
    List<MutableToken> untypedTokens = parseBracketValues(splits[0]);
    ChunkSpec chunkSpec = new ChunkSpec(id, splits[0], parseChunkSpec(splits[1], splits[0], untypedTokens));
    return chunkSpec;
}

From source file:com.mengka.diamond.server.service.NotifyService.java

Properties getNodeProperties() {
    ConfigInfo info = configService.findConfigInfo(DiamondConstants.SERVER_ADDRESS_AND_IP,
            DiamondConstants.DIAMOND_ADMIN_GROUP_ID);
    Properties nodeProperties = new Properties();
    if (info != null && !StringUtils.isEmpty(info.getContent())) {
        try {/*from   w  ww.j  ava2  s . com*/
            nodeProperties.load(new StringReader(info.getContent()));
        } catch (IOException e) {
            log.error("?", e);
            new RuntimeException("?", e);
        }
    } else {
        log.error(String.format("?,?dataid:%s,groupid:%s ?",
                DiamondConstants.DIAMOND_ADMIN_DATA_ID, DiamondConstants.DIAMOND_ADMIN_GROUP_ID));
    }
    log.info(":" + nodeProperties);
    return nodeProperties;
}

From source file:com.jiwhiz.mail.sendgrid.EmailServiceImpl.java

/**
 * Sends email asynchronously through Sendgrid. 
 *//* w  w  w  .j  a v  a 2  s  .  c  o  m*/
@Override
@Async
public void sendEmail(final EmailMessage message) {
    if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) {
        return;
    }

    SendGrid sendgrid = new SendGrid(username, password);
    sendgrid.setFrom(message.getFromEmail());
    sendgrid.setFromName(message.getFromName());
    sendgrid.addTo(message.getToEmail());
    sendgrid.addToName(message.getToName());
    sendgrid.setReplyTo(message.getReplyTo());
    sendgrid.setSubject(message.getSubject());
    sendgrid.setText(message.getBody());

    try {
        LOGGER.info("Try to send email to {}, message is: {}", message.getToEmail(), message.getBody());
        String response = sendgrid.send();
        LOGGER.info("Sent email successfully, response from SendGrid is: {}", response);
    } catch (Exception ex) {
        LOGGER.debug("Exception:", ex);
        LOGGER.error("Got exception when sending email through sendgrid: {}", ex.getMessage());
    }

}

From source file:be.roots.taconic.pricingguide.util.GreekAlphabet.java

public static String replaceGreekHtmlCodesWithUnicode(String text) {
    if (!StringUtils.isEmpty(text)) {
        for (String[] greekLetter : getAlphabet()) {
            text = text.replaceAll(greekLetter[0], greekLetter[2]);
        }//from   w  w  w.  j a v a 2  s . c o  m
    }
    return text;
}

From source file:nz.gate5a.schoolstories.importer.NceaQualificationCreator.java

private String trimmed(String value) {
    if (StringUtils.isEmpty(value)) {
        return "";
    }
    return value.trim();
}

From source file:management.limbr.ui.projects.ProjectsPresenter.java

@Override
public BeanItemContainer<Project> listEntities(String filter) {
    if (StringUtils.isEmpty(filter)) {
        return new BeanItemContainer<>(Project.class, repository.findAll());
    } else {//from   w w  w . jav  a  2  s . c o  m
        return new BeanItemContainer<>(Project.class, repository.findByNameStartsWithIgnoreCase(filter));
    }
}