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

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

Introduction

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

Prototype

public static boolean isEmpty(final CharSequence cs) 

Source Link

Document

Checks if a CharSequence is empty ("") or null.

 StringUtils.isEmpty(null)      = true StringUtils.isEmpty("")        = true StringUtils.isEmpty(" ")       = false StringUtils.isEmpty("bob")     = false StringUtils.isEmpty("  bob  ") = false 

NOTE: This method changed in Lang version 2.0.

Usage

From source file:com.haulmont.cuba.web.widgets.CubaTwinColSelect.java

@Override
protected void paintItem(PaintTarget target, Object itemId) throws PaintException {
    super.paintItem(target, itemId);

    if (styleGenerator != null) {
        String style = styleGenerator.generateStyle(this, itemId, isSelected(itemId));
        if (!StringUtils.isEmpty(style)) {
            target.addAttribute("style", style);
        }//from   ww w.  j  a  v  a 2s  .com
    }
}

From source file:com.vilt.minium.app.TestConfiguration.java

@Bean(name = "remoteWebDriverUrl")
public URL remoteWebDriverUrl() throws IOException {
    if (StringUtils.isEmpty(remoteUrl)) {
        service = ChromeDriverService.createDefaultService();
        service.start();//from w w  w . j  a va  2s  .  com
        return service.getUrl();
    } else {
        return new URL(remoteUrl);
    }
}

From source file:com.google.mr4c.config.site.MR4CSite.java

private static URI findSiteConf() {
    String file = MR4CConfig.getDefaultInstance().getCategory(Category.CORE)
            .getProperty(CoreConfig.PROP_SITE_CONF);
    if (StringUtils.isEmpty(file)) {
        file = DEFAULT_SITE_FILE;/*from  ww w .j av a  2 s. c  om*/
    }
    return URI.create(file);
}

From source file:com.assignmentone.snippet.FormSnippet.java

public Renderer setInitValue(String name, String age, String bloodtype, String nameErrMsg, String ageErrMsg) {
    Renderer renderer = new GoThroughRenderer();
    if (!StringUtils.isEmpty(name)) {
        renderer.add("input#name", "value", name);
    }/*from  w w w.j a  v  a 2s.co  m*/
    if (!StringUtils.isEmpty(age)) {
        renderer.add("input#age", "value", age);
    }
    if (!StringUtils.isEmpty(nameErrMsg)) {
        renderer.add("span#nameErrMsg", nameErrMsg);
    }
    if (!StringUtils.isEmpty(ageErrMsg)) {
        renderer.add("span#ageErrMsg", ageErrMsg);
    }
    List<Renderer> options = new ArrayList<>();
    for (BloodType bloodTypeEnum : BloodType.values()) {
        Renderer type = Renderer.create("option", "value", bloodTypeEnum.name());
        type.add("option", bloodTypeEnum.name());
        if (bloodTypeEnum.name().equals(bloodtype)) {
            type.add("option", "selected", "selected");
        }
        options.add(type);
    }
    renderer.add("select#bloodtype > option", options);
    return renderer;
}

From source file:com.l2jfree.util.logging.L2RuntimeLogFormatter.java

@Override
protected final void format0(LogRecord record, TextBuilder tb) {
    tb.append(record.getLevel()).append(" ");

    appendDate(record, tb);/* w ww. ja  v a2s  .c  o  m*/

    if (record.getLevel().intValue() > Level.INFO.intValue() || record.getThrown() != null)
        if (!StringUtils.isEmpty(record.getSourceClassName())
                && !StringUtils.isEmpty(record.getSourceMethodName()))
            tb.append(record.getSourceClassName()).append(".").append(record.getSourceMethodName())
                    .append("(): ");

    appendMessage(record, tb);
    appendThrown(record, tb);
}

From source file:azkaban.crypto.EncryptionTest.java

@Test
public void testInvalidParams() {
    ICrypto crypto = new Crypto();
    String[] args = { "", null, "test" };
    for (Version ver : Version.values()) {
        for (String plaintext : args) {
            for (String passphrase : args) {
                try {
                    if (!StringUtils.isEmpty(plaintext) && !StringUtils.isEmpty(passphrase)) {
                        String cipheredText = crypto.encrypt(plaintext, passphrase, ver);
                        Assert.assertEquals(plaintext, crypto.decrypt(cipheredText, passphrase));
                    } else {
                        crypto.encrypt(plaintext, passphrase, ver);
                        Assert.fail("Encyption should have failed with invalid parameters. plaintext: "
                                + plaintext + " , passphrase: " + passphrase);
                    }/* w w  w.  j av  a2  s .  c o m*/
                } catch (Exception e) {
                    Assert.assertTrue(e instanceof IllegalArgumentException);
                }

            }
        }
    }
}

From source file:com.serphacker.serposcope.di.CaptchaSolverFactoryImpl.java

@Override
public CaptchaSolver get(Config config) {
    if (config == null) {
        return null;
    }/*from  w  w  w. java  2  s  . c  o  m*/

    List<CaptchaSolver> solvers = new ArrayList<>();

    if (!StringUtils.isEmpty(config.getDbcUser()) && !StringUtils.isEmpty(config.getDbcPass())) {
        DeathByCaptchaSolver solver = new DeathByCaptchaSolver(config.getDbcUser(), config.getDbcPass());
        if (init(solver)) {
            solvers.add(solver);
        }
    }

    if (!StringUtils.isEmpty(config.getDecaptcherUser()) && !StringUtils.isEmpty(config.getDecaptcherPass())) {
        DecaptcherSolver solver = new DecaptcherSolver(config.getDecaptcherUser(), config.getDecaptcherPass());
        if (init(solver)) {
            solvers.add(solver);
        }
    }

    if (!StringUtils.isEmpty(config.getAnticaptchaKey())) {
        AntiCaptchaSolver solver = new AntiCaptchaSolver(config.getAnticaptchaKey());
        if (init(solver)) {
            solvers.add(solver);
        }
    }

    if (solvers.isEmpty()) {
        return null;
    }

    Collections.shuffle(solvers);
    return new FailoverCaptchaSolver(solvers);
}

From source file:com.webbfontaine.valuewebb.utils.TTMailService.java

@Asynchronous
public void sendMailForResponseOk(TtGen ttGen, Locale locale) {
    LocaleSelector.instance().setLocale(locale);
    if (!ApplicationProperties.isTestMode() && !StringUtils.isEmpty(ApplicationProperties.getSmtpServer())) {
        TTMailUtils ttMailUtils = new TTMailUtils(ttGen);
        List<String> recepients = ttMailUtils.getMailRecepientsForResponseOk();

        if (recepients == null || recepients.isEmpty()) {
            LOGGER.warn("No mail recipients specified for Sending Response Ok message for TT {0}",
                    ttGen.getId());//from   w  ww.jav a 2 s  .c  o m
        } else {
            TtPrinting ttPrinting = new TtPrinting();

            byte[] report = ttPrinting.prepareFCVRReport(ttGen, false).generateReport();

            try {
                EmailSender.sendMail(ttMailUtils.getResponseOkMailSubject(),
                        ttMailUtils.getResponseOkMailBody(), false,
                        new Attachment(report, "application/pdf", "", ttGen.getFcvrNum() + ".pdf"),
                        ApplicationProperties.getEmailFrom(), ApplicationProperties.getSmtpServer(),
                        ApplicationProperties.getSmtpServerPort(), recepients.toArray());
                LOGGER.info("TT ID: {0}. Sending Mail For ResponseOk to {1} done. Attachment size {2}",
                        ttGen.getId(), recepients, report.length);
            } catch (Exception e) {
                LOGGER.error("TT ID: {0}. Error during sending Mail For ResponseOk to {1}. Attachment size {2}",
                        e, ttGen.getId(), recepients, report.length);
            }
        }
    } else {
        LOGGER.info("Response Ok Mail message sending skipped for TT {0}. Conf: Test Mode {1}, SMTP Server {2}",
                ttGen.getId(), ApplicationProperties.isTestMode(), ApplicationProperties.getSmtpServer());
    }
}

From source file:com.ijuru.kumva.Meaning.java

/**
 * Parses a CSV list of flag names into a bit field
 * @param str the CSV string/*from   www  . jav a2 s. c  om*/
 * @return the bit field
 */
public static int parseFlags(String str) {
    if (StringUtils.isEmpty(str))
        return 0;

    List<String> flagStrs = Utils.parseCSV(str);
    if (flagStrs.size() == 0)
        return 0;

    // Build bit field
    int flags = 0;
    for (int f = 0; f < flagNames.length; f++) {
        String flagName = flagNames[f];
        if (flagStrs.contains(flagName)) {
            flags |= (1 << f);
        }
    }

    return flags;
}

From source file:com.creditcloud.interestbearing.model.HuaAnFundAccountConfig.java

@JsonIgnore
public boolean isPlatformTradingAccountReady() {
    boolean isPlatformTradingAccountReady = !StringUtils.isEmpty(platformTradingAccount);
    return isPlatformTradingAccountReady;
}