Example usage for org.apache.commons.lang Validate notEmpty

List of usage examples for org.apache.commons.lang Validate notEmpty

Introduction

In this page you can find the example usage for org.apache.commons.lang Validate notEmpty.

Prototype

public static void notEmpty(String string, String message) 

Source Link

Document

Validate an argument, throwing IllegalArgumentException if the argument String is empty (null or zero length).

 Validate.notEmpty(myString, "The string must not be empty"); 

Usage

From source file:ch.algotrader.service.SubscriptionServiceImpl.java

/**
 * {@inheritDoc}// w w w  . j av  a2  s. c  o m
 */
@Override
public void subscribeMarketDataEvent(final String strategyName, final long securityId) {

    Validate.notEmpty(strategyName, "Strategy name is empty");

    this.marketDataService.subscribe(strategyName, securityId);

    initMarketDataEventSubscriptions();

}

From source file:it.gualtierotesta.gdocx.GTbl.java

/**
 * Set the preferred width of the table/*from   w w  w. jav a2s.  co  m*/
 *
 * @param lWidth the value of the preferred width of the table. If omitted,
 * the value is assumed to be zero.
 * @param sType type (unit) of the value Possible values are: auto, dxa,
 * nil, pict
 * @return same GTbl instance
 */
@Nonnull
public GTbl width(final long lWidth, @Nonnull final String sType) {

    Validate.isTrue(0L <= lWidth, "Width value not valid");
    Validate.notEmpty(sType, "Type not valid");

    final TblWidth tblWidth = FACTORY.createTblWidth();
    tblWidth.setType(sType);
    tblWidth.setW(BigInteger.valueOf(lWidth));
    tblPr.setTblW(tblWidth);
    return this;
}

From source file:ch.algotrader.dao.SubscriptionDaoImpl.java

@Override
public Subscription findByStrategySecurityAndFeedType(String strategyName, long securityId, String feedType) {

    Validate.notEmpty(strategyName, "Strategy name is empty");
    Validate.notNull(feedType, "String is null");

    return findUniqueCaching("Subscription.findByStrategySecurityAndFeedType", QueryType.BY_NAME,
            new NamedParam("strategyName", strategyName), new NamedParam("securityId", securityId),
            new NamedParam("feedType", feedType));
}

From source file:fr.ribesg.bukkit.api.chat.Chat.java

/**
 * Broadcasts the provided Mojangson String(s) to
 * {@link Player Players} having the provided permission.
 *
 * @param permission a permission required to receive the message(s)
 * @param mojangsons the message(s) to send
 *
 * @see Server#broadcast(String, String)
 *///from w  w  w. java2 s  .c om
public static void broadcast(final String permission, final String... mojangsons) {
    Validate.notEmpty(permission, "The 'permission' argument should not be null nor empty");
    Validate.notEmpty(mojangsons, "Please provide at least one Mojangson String");
    Validate.noNullElements(mojangsons, "The 'mojangsons' argument should not contain null values");
    for (final String mojangson : mojangsons) {
        for (final Player player : Bukkit.getOnlinePlayers()) {
            if (player.hasPermission(permission)) {
                Bukkit.dispatchCommand(Bukkit.getConsoleSender(),
                        "tellraw " + player.getName() + ' ' + mojangson);
            }
        }
    }
}

From source file:com.alibaba.cobar.client.router.config.CobarInteralRouterXmlFactoryBean.java

@Override
protected void assembleRulesForRouter(CobarClientInternalRouter router, Resource configLocation,
        Set<IRoutingRule<IBatisRoutingFact, List<String>>> sqlActionShardingRules,
        Set<IRoutingRule<IBatisRoutingFact, List<String>>> sqlActionRules,
        Set<IRoutingRule<IBatisRoutingFact, List<String>>> namespaceShardingRules,
        Set<IRoutingRule<IBatisRoutingFact, List<String>>> namespaceRules) throws IOException {
    XStream xstream = new XStream();
    xstream.alias("rules", InternalRules.class);
    xstream.alias("rule", InternalRule.class);
    xstream.addImplicitCollection(InternalRules.class, "rules");
    xstream.useAttributeFor(InternalRule.class, "merger");

    InternalRules internalRules = (InternalRules) xstream.fromXML(configLocation.getInputStream());
    List<InternalRule> rules = internalRules.getRules();
    if (CollectionUtils.isEmpty(rules)) {
        return;//from   w w w .j  a v a  2 s .c o m
    }

    for (InternalRule rule : rules) {
        String namespace = StringUtils.trimToEmpty(rule.getNamespace());
        String sqlAction = StringUtils.trimToEmpty(rule.getSqlmap());
        String shardingExpression = StringUtils.trimToEmpty(rule.getShardingExpression());
        String destinations = StringUtils.trimToEmpty(rule.getShards());

        Validate.notEmpty(destinations, "destination shards must be given explicitly.");

        if (StringUtils.isEmpty(namespace) && StringUtils.isEmpty(sqlAction)) {
            throw new IllegalArgumentException("at least one of 'namespace' or 'sqlAction' must be given.");
        }
        if (StringUtils.isNotEmpty(namespace) && StringUtils.isNotEmpty(sqlAction)) {
            throw new IllegalArgumentException(
                    "'namespace' and 'sqlAction' are alternatives, can't guess which one to use if both of them are provided.");
        }

        if (StringUtils.isNotEmpty(namespace)) {
            if (StringUtils.isEmpty(shardingExpression)) {
                namespaceRules.add(new IBatisNamespaceRule(namespace, destinations));
            } else {
                IBatisNamespaceShardingRule insr = new IBatisNamespaceShardingRule(namespace, destinations,
                        shardingExpression);
                if (MapUtils.isNotEmpty(getFunctionsMap())) {
                    insr.setFunctionMap(getFunctionsMap());
                }
                namespaceShardingRules.add(insr);
            }
        }
        if (StringUtils.isNotEmpty(sqlAction)) {
            if (StringUtils.isEmpty(shardingExpression)) {
                sqlActionRules.add(new IBatisSqlActionRule(sqlAction, destinations));
            } else {
                IBatisSqlActionShardingRule issr = new IBatisSqlActionShardingRule(sqlAction, destinations,
                        shardingExpression);
                if (MapUtils.isNotEmpty(getFunctionsMap())) {
                    issr.setFunctionMap(getFunctionsMap());
                }
                sqlActionShardingRules.add(issr);
            }
        }
    }

}

From source file:com.stealthyone.mcb.stbukkitlib.utils.StringUtils.java

/**
 * Checks if any of the given values are equal to the input string given.
 *
 * @param input Input string.//from  www.ja v a2s . c om
 * @param values List of values to compare to the input string.
 * @return True if any of the values are equal.
 *         False if none of the values are equal.
 */
public static boolean equalsIgnoreCaseMultiple(String input, String... values) {
    Validate.notNull(input, "Input cannot be null.");
    Validate.notNull(values, "Values cannot be null.");
    Validate.notEmpty(values, "Values cannot be empty.");

    for (String string : values) {
        if (input.equalsIgnoreCase(string)) {
            return true;
        }
    }
    return false;
}

From source file:ch.algotrader.dao.strategy.CashBalanceDaoImpl.java

@SuppressWarnings("unchecked")
@Override/*w  ww . j  ava  2 s  .co m*/
public List<Currency> findHeldCurrenciesByStrategy(String strategyName) {

    Validate.notEmpty(strategyName, "Strategy name is empty");

    return (List<Currency>) findObjects(null, "CashBalance.findHeldCurrenciesByStrategy", QueryType.BY_NAME,
            new NamedParam("strategyName", strategyName));
}

From source file:name.richardson.james.bukkit.utilities.command.HelpCommand.java

/**
 * Construct a HelpCommand using the label and commands.
 *
 * @param label    the label that must be prefixed for commands to be valid. This is usually the name of the {@link org.bukkit.command.PluginCommand} that the
 *                 executor is attached to.
 * @param commands the commands that the class should provide help for.
 *///from  ww  w.  j  ava 2s .  c om
public HelpCommand(String label, Set<Command> commands) {
    Validate.notEmpty(label, "Command label can not be empty or null!");
    Validate.notEmpty(commands, "CommandMap can not be empty or null!");
    this.label = label;
    for (Command command : commands) {
        commandMap.put(command.getName(), command);
    }
    this.addMatcher(new StringMatcher(commandMap.keySet()));
}

From source file:com.genericworkflownodes.knime.workflowexporter.ui.wizard.WorkflowExportPage.java

/**
 * @param pageName//from  w  w w  . j  a v  a 2 s. c  o  m
 * @param selection
 */
public WorkflowExportPage(final Collection<KnimeWorkflowExporter> exporters) {
    super("com.genericworkflownodes.knime.ui.wizard.WorkflowExportPage", "Select the destination format",
            ImageRepository.getImageDescriptor(SharedImages.ExportBig));
    Validate.notEmpty(exporters, "exporters cannot be null or empty");
    this.exporters = new ArrayList<KnimeWorkflowExporter>(exporters);
    this.selectedIndex = -1;
}

From source file:gov.nih.nci.caarray.util.EmailUtil.java

private static MimeMessage constructMessage(List<String> mailRecipients, String from, String mailSubject)
        throws MessagingException {
    Validate.notEmpty(mailRecipients, "No email recipients are specified");
    if (StringUtils.isEmpty(mailSubject)) {
        LOG.info("No email subject specified");
    }/*from w  w w .j  a  v  a 2 s.  c o  m*/

    List<Address> addresses = new ArrayList<Address>();
    for (String recipient : mailRecipients) {
        addresses.add(new InternetAddress(recipient));
    }

    MimeMessage message = new MimeMessage(MAILSESSION);
    message.setRecipients(Message.RecipientType.TO, addresses.toArray(new Address[addresses.size()]));
    message.setFrom(new InternetAddress(from));
    message.setSubject(mailSubject);

    return message;
}