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

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

Introduction

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

Prototype

public static String lowerCase(final String str) 

Source Link

Document

Converts a String to lower case as per String#toLowerCase() .

A null input String returns null .

 StringUtils.lowerCase(null)  = null StringUtils.lowerCase("")    = "" StringUtils.lowerCase("aBc") = "abc" 

Note: As described in the documentation for String#toLowerCase() , the result of this method is affected by the current locale.

Usage

From source file:com.ottogroup.bi.spqr.pipeline.MicroPipelineFactory.java

/**
 * Instantiates, initializes and returns the {@link DelayedResponseOperatorWaitStrategy} configured for the {@link DelayedResponseOperator}
 * whose {@link MicroPipelineComponentConfiguration configuration} is provided when calling this method. 
 * @param delayedResponseOperatorCfg/*from   w w  w  .  ja  v  a 2s.  c o m*/
 * @return
 */
protected DelayedResponseOperatorWaitStrategy getResponseWaitStrategy(
        final MicroPipelineComponentConfiguration delayedResponseOperatorCfg)
        throws RequiredInputMissingException, UnknownWaitStrategyException {

    /////////////////////////////////////////////////////////////////////////////////////
    // validate input
    if (delayedResponseOperatorCfg == null)
        throw new RequiredInputMissingException("Missing required delayed response operator configuration");
    if (delayedResponseOperatorCfg.getSettings() == null)
        throw new RequiredInputMissingException("Missing required delayed response operator settings");
    String strategyName = StringUtils.lowerCase(StringUtils.trim(delayedResponseOperatorCfg.getSettings()
            .getProperty(DelayedResponseOperator.CFG_WAIT_STRATEGY_NAME)));
    if (StringUtils.isBlank(strategyName))
        throw new RequiredInputMissingException(
                "Missing required strategy name expected as part of operator settings ('"
                        + DelayedResponseOperator.CFG_WAIT_STRATEGY_NAME + "')");
    //
    /////////////////////////////////////////////////////////////////////////////////////

    if (logger.isDebugEnabled())
        logger.debug("Settings provided for strategy '" + strategyName + "'");
    Properties strategyProperties = new Properties();
    for (Enumeration<Object> keyEnumerator = delayedResponseOperatorCfg.getSettings().keys(); keyEnumerator
            .hasMoreElements();) {
        String key = (String) keyEnumerator.nextElement();
        if (StringUtils.startsWith(key, DelayedResponseOperator.CFG_WAIT_STRATEGY_SETTINGS_PREFIX)) {
            String waitStrategyCfgKey = StringUtils.substring(key, StringUtils.lastIndexOf(key, ".") + 1);
            if (StringUtils.isNoneBlank(waitStrategyCfgKey)) {
                String waitStrategyCfgValue = delayedResponseOperatorCfg.getSettings().getProperty(key);
                strategyProperties.put(waitStrategyCfgKey, waitStrategyCfgValue);

                if (logger.isDebugEnabled())
                    logger.debug("\t" + waitStrategyCfgKey + ": " + waitStrategyCfgValue);

            }
        }
    }

    if (StringUtils.equalsIgnoreCase(strategyName, MessageCountResponseWaitStrategy.WAIT_STRATEGY_NAME)) {
        MessageCountResponseWaitStrategy strategy = new MessageCountResponseWaitStrategy();
        strategy.initialize(strategyProperties);
        return strategy;
    } else if (StringUtils.equalsIgnoreCase(strategyName, TimerBasedResponseWaitStrategy.WAIT_STRATEGY_NAME)) {
        TimerBasedResponseWaitStrategy strategy = new TimerBasedResponseWaitStrategy();
        strategy.initialize(strategyProperties);
        return strategy;
    } else if (StringUtils.equalsIgnoreCase(strategyName, OperatorTriggeredWaitStrategy.WAIT_STRATEGY_NAME)) {
        OperatorTriggeredWaitStrategy strategy = new OperatorTriggeredWaitStrategy();
        strategy.initialize(strategyProperties);
        return strategy;
    }

    throw new UnknownWaitStrategyException("Unknown wait strategy '" + strategyName + "'");

}

From source file:fr.landel.utils.assertor.AssertorIterableTest.java

/**
 * Check {@link AssertorIterable#allMatch}
 *///from  ww w. j a v  a  2s .  c  om
@Test
public void testAllMatch() {
    List<String> listtu = Arrays.asList("t", "u");
    List<String> listTu = Arrays.asList("T", "u");
    List<String> listTU = Arrays.asList("T", "U");
    List<String> listtNull = Arrays.asList("t", null);

    Predicate<String> predicate = e -> Objects.equals(e, StringUtils.lowerCase(e));

    assertTrue(Assertor.that(listtu).allMatch(predicate).isOK());

    for (EnumAnalysisMode mode : EnumAnalysisMode.values()) {

        assertTrue(Assertor.that(listtu, mode).allMatch(predicate).isOK());
        assertFalse(Assertor.that(listTu, mode).allMatch(predicate).isOK());
        assertFalse(Assertor.that(listTU, mode).allMatch(predicate).isOK());
        assertTrue(Assertor.that(listtNull, mode).allMatch(predicate).isOK());

        assertException(
                () -> Assertor.that(Collections.<String>emptyList(), mode).allMatch(predicate).orElseThrow(),
                IllegalArgumentException.class,
                "the iterable cannot be null or empty and predicate cannot be null");
        assertException(() -> Assertor.that((List<String>) null, mode).allMatch(predicate).orElseThrow(),
                IllegalArgumentException.class,
                "the iterable cannot be null or empty and predicate cannot be null");
        assertException(() -> Assertor.that(listTu, mode).allMatch(null).orElseThrow(),
                IllegalArgumentException.class,
                "the iterable cannot be null or empty and predicate cannot be null");
        assertException(() -> Assertor.that(listTU, mode).allMatch(predicate).orElseThrow(),
                IllegalArgumentException.class,
                "all the iterable elements '[T, U]' should match the predicate");
    }
}

From source file:fr.landel.utils.assertor.predicate.PredicateAssertorMapTest.java

/**
 * Check {@link AssertorMap#anyMatch}/*from w  w w  . ja va 2s.co  m*/
 */
@Test
public void testAnyMatch() {
    Map<String, Integer> maptu = MapUtils2.newHashMap(Pair.of("t", 2), Pair.of("u", 3));
    Map<String, Integer> mapTu = MapUtils2.newHashMap(Pair.of("T", 2), Pair.of("u", 2));
    Map<String, Integer> mapTU = MapUtils2.newHashMap(Pair.of("T", 1), Pair.of("U", 2));
    Map<String, Integer> maptNull = MapUtils2.newHashMap(Pair.of("t", 1), Pair.of(null, null));
    Map<String, Integer> maptUNull = MapUtils2.newHashMap(Pair.of("t", 1), Pair.of("U", null));

    Predicate<Entry<String, Integer>> predicate = e -> Objects.equals(e.getKey(),
            StringUtils.lowerCase(e.getKey())) && e.getValue() > 1;

    assertTrue(Assertor.<String, Integer>ofMap().anyMatch(predicate).that(maptu).isOK());

    for (EnumAnalysisMode mode : EnumAnalysisMode.values()) {

        PredicateAssertorStepMap<String, Integer> predicateAssertor = Assertor.<String, Integer>ofMap(mode);
        PredicateStepMap<String, Integer> predicateStep = predicateAssertor.anyMatch(predicate);

        assertTrue(predicateStep.that(maptu).isOK());
        assertTrue(predicateStep.that(mapTu).isOK());
        assertFalse(predicateStep.that(mapTU).isOK());
        assertFalse(predicateStep.that(maptNull).isOK());
        assertFalse(predicateStep.that(maptUNull).isOK());

        assertException(() -> predicateStep.that(Collections.<String, Integer>emptyMap()).orElseThrow(),
                IllegalArgumentException.class, "the map cannot be null or empty and predicate cannot be null");
        assertException(() -> predicateStep.that((Map<String, Integer>) null).orElseThrow(),
                IllegalArgumentException.class, "the map cannot be null or empty and predicate cannot be null");
        assertException(() -> predicateAssertor.anyMatch(null).that(mapTu).orElseThrow(),
                IllegalArgumentException.class, "the map cannot be null or empty and predicate cannot be null");
        assertException(() -> predicateStep.that(mapTU).orElseThrow(), IllegalArgumentException.class,
                "any map entry '[T=1, U=2]' should match the predicate");
    }
}

From source file:fr.landel.utils.assertor.AssertorMapTest.java

/**
 * Check {@link AssertorMap#anyMatch}/*from   w w w  . jav a  2  s.com*/
 */
@Test
public void testAnyMatch() {
    Map<String, Integer> maptu = MapUtils2.newHashMap(Pair.of("t", 2), Pair.of("u", 3));
    Map<String, Integer> mapTu = MapUtils2.newHashMap(Pair.of("T", 2), Pair.of("u", 2));
    Map<String, Integer> mapTU = MapUtils2.newHashMap(Pair.of("T", 1), Pair.of("U", 2));
    Map<String, Integer> maptNull = MapUtils2.newHashMap(Pair.of("t", 1), Pair.of(null, null));
    Map<String, Integer> maptUNull = MapUtils2.newHashMap(Pair.of("t", 1), Pair.of("U", null));

    Predicate<Entry<String, Integer>> predicate = e -> Objects.equals(e.getKey(),
            StringUtils.lowerCase(e.getKey())) && e.getValue() > 1;

    assertTrue(Assertor.that(maptu).anyMatch(predicate).isOK());

    for (EnumAnalysisMode mode : EnumAnalysisMode.values()) {

        assertTrue(Assertor.that(maptu, mode).anyMatch(predicate).isOK());
        assertTrue(Assertor.that(mapTu, mode).anyMatch(predicate).isOK());
        assertFalse(Assertor.that(mapTU, mode).anyMatch(predicate).isOK());
        assertFalse(Assertor.that(maptNull, mode).anyMatch(predicate).isOK());
        assertFalse(Assertor.that(maptUNull, mode).anyMatch(predicate).isOK());

        assertException(
                () -> Assertor.that(Collections.<String, Integer>emptyMap(), mode).anyMatch(predicate)
                        .orElseThrow(),
                IllegalArgumentException.class, "the map cannot be null or empty and predicate cannot be null");
        assertException(
                () -> Assertor.that((Map<String, Integer>) null, mode).anyMatch(predicate).orElseThrow(),
                IllegalArgumentException.class, "the map cannot be null or empty and predicate cannot be null");
        assertException(() -> Assertor.that(mapTu, mode).anyMatch(null).orElseThrow(),
                IllegalArgumentException.class, "the map cannot be null or empty and predicate cannot be null");
        assertException(() -> Assertor.that(mapTU, mode).anyMatch(predicate).orElseThrow(),
                IllegalArgumentException.class, "any map entry '[T=1, U=2]' should match the predicate");
    }
}

From source file:fr.landel.utils.assertor.predicate.PredicateAssertorMapTest.java

/**
 * Check {@link AssertorMap#allMatch}/*from   w  w  w . j  a va2  s . c  o m*/
 */
@Test
public void testAllMatch() {
    Map<String, Integer> maptu = MapUtils2.newHashMap(Pair.of("t", 2), Pair.of("u", 3));
    Map<String, Integer> mapTu = MapUtils2.newHashMap(Pair.of("T", 2), Pair.of("u", 2));
    Map<String, Integer> mapTU = MapUtils2.newHashMap(Pair.of("T", 1), Pair.of("U", 2));
    Map<String, Integer> maptNull = MapUtils2.newHashMap(Pair.of("t", 1), Pair.of(null, null));
    Map<String, Integer> maptUNull = MapUtils2.newHashMap(Pair.of("t", 1), Pair.of("U", null));

    Predicate<Entry<String, Integer>> predicate = e -> Objects.equals(e.getKey(),
            StringUtils.lowerCase(e.getKey())) && e.getValue() > 1;

    assertTrue(Assertor.<String, Integer>ofMap().allMatch(predicate).that(maptu).isOK());

    for (EnumAnalysisMode mode : EnumAnalysisMode.values()) {

        PredicateAssertorStepMap<String, Integer> predicateAssertor = Assertor.<String, Integer>ofMap(mode);
        PredicateStepMap<String, Integer> predicateStep = predicateAssertor.allMatch(predicate);

        assertTrue(predicateStep.that(maptu).isOK());
        assertFalse(predicateStep.that(mapTu).isOK());
        assertFalse(predicateStep.that(mapTU).isOK());
        assertFalse(predicateStep.that(maptNull).isOK());
        assertFalse(predicateStep.that(maptUNull).isOK());

        assertException(() -> predicateStep.that(Collections.<String, Integer>emptyMap()).orElseThrow(),
                IllegalArgumentException.class, "the map cannot be null or empty and predicate cannot be null");
        assertException(() -> predicateStep.that((Map<String, Integer>) null).orElseThrow(),
                IllegalArgumentException.class, "the map cannot be null or empty and predicate cannot be null");
        assertException(() -> predicateAssertor.allMatch(null).that(mapTu).orElseThrow(),
                IllegalArgumentException.class, "the map cannot be null or empty and predicate cannot be null");
        assertException(() -> predicateStep.that(mapTU).orElseThrow(), IllegalArgumentException.class,
                "all the map entries '[T=1, U=2]' should match the predicate");
    }
}

From source file:fr.landel.utils.assertor.predicate.PredicateAssertorIterableTest.java

/**
 * Check {@link AssertorIterable#anyMatch}
 *//*w  w w . jav  a 2s  .  c om*/
@Test
public void testAnyMatch() {
    List<String> listtu = Arrays.asList("t", "u");
    List<String> listTu = Arrays.asList("T", "u");
    List<String> listTU = Arrays.asList("T", "U");
    List<String> listtNull = Arrays.asList("t", null);

    Predicate<String> predicate = e -> Objects.equals(e, StringUtils.lowerCase(e));

    assertTrue(Assertor.<String>ofList().anyMatch(predicate).that(listtu).isOK());

    for (EnumAnalysisMode mode : EnumAnalysisMode.values()) {

        PredicateAssertorStepIterable<List<String>, String> predicateAssertor = Assertor.<String>ofList(mode);
        PredicateStepIterable<List<String>, String> predicateStep = predicateAssertor.anyMatch(predicate);

        assertTrue(predicateStep.that(listtu).isOK());
        assertTrue(predicateStep.that(listTu).isOK());
        assertFalse(predicateStep.that(listTU).isOK());
        assertTrue(predicateStep.that(listtNull).isOK());

        assertException(() -> predicateStep.that(Collections.<String>emptyList()).orElseThrow(),
                IllegalArgumentException.class,
                "the iterable cannot be null or empty and predicate cannot be null");
        assertException(() -> predicateStep.that((List<String>) null).orElseThrow(),
                IllegalArgumentException.class,
                "the iterable cannot be null or empty and predicate cannot be null");
        assertException(() -> predicateAssertor.anyMatch(null).that(listTu).orElseThrow(),
                IllegalArgumentException.class,
                "the iterable cannot be null or empty and predicate cannot be null");
        assertException(() -> predicateStep.that(listTU).orElseThrow(), IllegalArgumentException.class,
                "any iterable element '[T, U]' should match the predicate");
    }
}

From source file:fr.landel.utils.assertor.AssertorMapTest.java

/**
 * Check {@link AssertorMap#allMatch}//from  w  ww . j a va2  s.  c  om
 */
@Test
public void testAllMatch() {
    Map<String, Integer> maptu = MapUtils2.newHashMap(Pair.of("t", 2), Pair.of("u", 3));
    Map<String, Integer> mapTu = MapUtils2.newHashMap(Pair.of("T", 2), Pair.of("u", 2));
    Map<String, Integer> mapTU = MapUtils2.newHashMap(Pair.of("T", 1), Pair.of("U", 2));
    Map<String, Integer> maptNull = MapUtils2.newHashMap(Pair.of("t", 1), Pair.of(null, null));
    Map<String, Integer> maptUNull = MapUtils2.newHashMap(Pair.of("t", 1), Pair.of("U", null));

    Predicate<Entry<String, Integer>> predicate = e -> Objects.equals(e.getKey(),
            StringUtils.lowerCase(e.getKey())) && e.getValue() > 1;

    assertTrue(Assertor.that(maptu).allMatch(predicate).isOK());

    for (EnumAnalysisMode mode : EnumAnalysisMode.values()) {

        assertTrue(Assertor.that(maptu, mode).allMatch(predicate).isOK());
        assertFalse(Assertor.that(mapTu, mode).allMatch(predicate).isOK());
        assertFalse(Assertor.that(mapTU, mode).allMatch(predicate).isOK());
        assertFalse(Assertor.that(maptNull, mode).allMatch(predicate).isOK());
        assertFalse(Assertor.that(maptUNull, mode).allMatch(predicate).isOK());

        assertException(
                () -> Assertor.that(Collections.<String, Integer>emptyMap(), mode).allMatch(predicate)
                        .orElseThrow(),
                IllegalArgumentException.class, "the map cannot be null or empty and predicate cannot be null");
        assertException(
                () -> Assertor.that((Map<String, Integer>) null, mode).allMatch(predicate).orElseThrow(),
                IllegalArgumentException.class, "the map cannot be null or empty and predicate cannot be null");
        assertException(() -> Assertor.that(mapTu, mode).allMatch(null).orElseThrow(),
                IllegalArgumentException.class, "the map cannot be null or empty and predicate cannot be null");
        assertException(() -> Assertor.that(mapTU, mode).allMatch(predicate).orElseThrow(),
                IllegalArgumentException.class, "all the map entries '[T=1, U=2]' should match the predicate");
    }
}

From source file:fr.landel.utils.assertor.predicate.PredicateAssertorIterableTest.java

/**
 * Check {@link AssertorIterable#allMatch}
 *///  w ww. j a v a  2 s .  c o m
@Test
public void testAllMatch() {
    List<String> listtu = Arrays.asList("t", "u");
    List<String> listTu = Arrays.asList("T", "u");
    List<String> listTU = Arrays.asList("T", "U");
    List<String> listtNull = Arrays.asList("t", null);

    Predicate<String> predicate = e -> Objects.equals(e, StringUtils.lowerCase(e));

    assertTrue(Assertor.<String>ofList().allMatch(predicate).that(listtu).isOK());

    for (EnumAnalysisMode mode : EnumAnalysisMode.values()) {

        PredicateAssertorStepIterable<List<String>, String> predicateAssertor = Assertor.<String>ofList(mode);
        PredicateStepIterable<List<String>, String> predicateStep = predicateAssertor.allMatch(predicate);

        assertTrue(predicateStep.that(listtu).isOK());
        assertFalse(predicateStep.that(listTu).isOK());
        assertFalse(predicateStep.that(listTU).isOK());
        assertTrue(predicateStep.that(listtNull).isOK());

        assertException(() -> predicateStep.that(Collections.<String>emptyList()).orElseThrow(),
                IllegalArgumentException.class,
                "the iterable cannot be null or empty and predicate cannot be null");
        assertException(() -> predicateStep.that((List<String>) null).orElseThrow(),
                IllegalArgumentException.class,
                "the iterable cannot be null or empty and predicate cannot be null");
        assertException(() -> predicateAssertor.allMatch(null).that(listTu).orElseThrow(),
                IllegalArgumentException.class,
                "the iterable cannot be null or empty and predicate cannot be null");
        assertException(() -> predicateStep.that(listTU).orElseThrow(), IllegalArgumentException.class,
                "all the iterable elements '[T, U]' should match the predicate");
    }
}

From source file:com.mirth.connect.donkey.server.data.jdbc.JdbcDao.java

@Override
public void addMetaDataColumn(String channelId, MetaDataColumn metaDataColumn) {
    logger.debug(channelId + ": adding custom meta data column (" + metaDataColumn.getName() + ")");
    Statement statement = null;//from w ww . ja v  a2  s  . c  o  m

    try {
        Map<String, Object> values = new HashMap<String, Object>();
        values.put("localChannelId", getLocalChannelId(channelId));
        values.put("columnName", metaDataColumn.getName());

        String queryName = "addMetaDataColumn"
                + StringUtils.capitalize(StringUtils.lowerCase(metaDataColumn.getType().toString()));

        statement = connection.createStatement();
        statement.executeUpdate(querySource.getQuery(queryName, values));

        if (querySource.queryExists(queryName + "Index")) {
            statement.executeUpdate(querySource.getQuery(queryName + "Index", values));
        }
    } catch (SQLException e) {
        throw new DonkeyDaoException("Failed to add meta-data column", e);
    } finally {
        close(statement);
    }
}

From source file:ch.cyberduck.ui.cocoa.BrowserController.java

private void setBookmarkFilter(final String searchString) {
    if (StringUtils.isBlank(searchString)) {
        searchField.setStringValue(StringUtils.EMPTY);
        bookmarkModel.setFilter(null);//from   w  ww . j  ava  2s . c o  m
    } else {
        bookmarkModel.setFilter(new HostFilter() {
            @Override
            public boolean accept(Host host) {
                return StringUtils.lowerCase(BookmarkNameProvider.toString(host))
                        .contains(searchString.toLowerCase(Locale.ROOT))
                        || ((null != host.getComment()) && StringUtils.lowerCase(host.getComment())
                                .contains(searchString.toLowerCase(Locale.ROOT)))
                        || ((null != host.getCredentials().getUsername())
                                && StringUtils.lowerCase(host.getCredentials().getUsername())
                                        .contains(searchString.toLowerCase(Locale.ROOT)))
                        || StringUtils.lowerCase(host.getHostname())
                                .contains(searchString.toLowerCase(Locale.ROOT));
            }
        });
    }
    this.reloadBookmarks();
}