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:io.cloudslang.engine.partitions.services.PartitionServiceImpl.java

@Override
@Transactional//from  w  ww.  ja  va2  s. c o m
public void updatePartitionGroup(String groupName, int groupSize, long timeThreshold, long sizeThreshold) {
    Validate.notEmpty(groupName, "Group name is empty or null");
    Validate.isTrue(groupSize >= MIN_GROUP_SIZE, formatMessage2Small("Group size", groupSize, MIN_GROUP_SIZE));

    PartitionGroup partitionGroup = repository.findByName(groupName);

    if (partitionGroup != null) {
        partitionGroup.setName(groupName);
        partitionGroup.setGroupSize(groupSize);
        partitionGroup.setTimeThreshold(timeThreshold);
        partitionGroup.setSizeThreshold(sizeThreshold);
        if (logger.isInfoEnabled())
            logger.info("Partition group [" + groupName + "] was updated, with group size " + groupSize
                    + ", and timeThreshold " + timeThreshold + ", and sizeThreshold " + sizeThreshold);
    }
}

From source file:edu.snu.leader.discrete.simulator.SueurPersonalitySimpleAngularAgentBuilder.java

@Override
public void initialize(SimulationState simState) {
    _simState = simState;/*  w ww  .  j  a  v a 2s. c  om*/

    // get values from properties file
    String numAgents = _simState.getProperties().getProperty("individual-count");
    Validate.notEmpty(numAgents, "Individual count may not be empty");
    _numAgents = Integer.parseInt(numAgents);

    _locationsFile = _simState.getProperties().getProperty("locations-file");
    Validate.notEmpty(_locationsFile, "Locations file may not be empty");

    _destinationsFile = _simState.getProperties().getProperty("destinations-file");
    Validate.notEmpty(_destinationsFile, "Destinations file may not be empty");

    _locations = Utils.readPoints(_locationsFile);
    _destinations = Utils.readPoints(_destinationsFile, _numAgents);

    // add the agent count info to root directory
    _simState.setRootDirectory(Reporter.ROOT_DIRECTORY + "agent-count=" + _numAgents + "_");
}

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

@Override
public Position findBySecurityAndStrategy(long securityId, String strategyName) {

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

    return findUniqueCaching("Position.findBySecurityAndStrategy", QueryType.BY_NAME,
            new NamedParam("securityId", securityId), new NamedParam("strategyName", strategyName));
}

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

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

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

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

From source file:ch.algotrader.dao.trade.OrderDaoImpl.java

@Override
public List<Order> getDailyOrdersByStrategy(String strategyName) {

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

    LocalDate today = LocalDate.now();
    return find("Order.findDailyOrdersByStrategy", QueryType.BY_NAME,
            new NamedParam("curdate", DateTimeLegacy.toLocalDate(today)),
            new NamedParam("strategyName", strategyName));
}

From source file:com.marc.lastweek.extractionengine.extractors.EbayProvinceExtractor.java

private void startWebConversation() {
    try {/* www.  ja v  a 2s. c  o m*/
        log.info("starting web conversation");
        Validate.notEmpty(this.baseUrl, "baseUrl has to be set");
        String provincePageUrl = this.baseUrl + this.provinceUrlSuffix;
        ClientProperties.getDefaultProperties().setIframeSupported(false);
        HttpUnitOptions.setScriptingEnabled(false);
        HttpUnitOptions.setExceptionsThrownOnErrorStatus(false);
        HttpUnitOptions.setExceptionsThrownOnScriptError(false);
        this.AdListWebConversation = new WebConversation();
        log.info("about to access " + provincePageUrl);
        this.AdListWebResponse = this.AdListWebConversation.getResponse(provincePageUrl);
        log.info("web conversation started");
    } catch (Exception e) {
        this.doProcess = false;
        log.error(e);
    }
}

From source file:edu.snu.leader.spatial.builder.AbstractAgentBuilder.java

/**
 * Initializes the agent builder/*w  w w.j a  v a  2 s.co m*/
 *
 * @param simState The simulation's state
 * @see edu.snu.leader.spatial.AgentBuilder#initialize(edu.snu.leader.spatial.SimulationState)
 */
@Override
public void initialize(SimulationState simState) {
    _LOG.trace("Entering initialize( simState )");

    // Validate and store the simulation state
    Validate.notNull(simState, "Simulation state may not be null");
    _simState = simState;

    // Get the simulation properties
    Properties props = simState.getProperties();

    // Ensure that a file detailing the locations was supplied
    String locationsFileStr = props.getProperty(_LOCATIONS_FILE_KEY);
    Validate.notEmpty(locationsFileStr, "Locations file (key=[" + _LOCATIONS_FILE_KEY + "] may not be empty");
    loadLocations(locationsFileStr);

    _LOG.trace("Leaving initialize( simState )");
}

From source file:edu.snu.leader.discrete.simulator.Simulator.java

public void initialize(Properties properties) {
    _LOG.trace("Entering initialize()");

    // Load the properties
    _props = properties;/*from   w  w w.  jav  a  2  s  .c  om*/

    _props.put("random-seed-override", String.valueOf(_randomSeedOverride));

    // Initialize the simulation state
    _simState.initialize(_props);

    String adhesionTimeLimit = _simState.getProperties().getProperty("adhesion-time-limit");
    Validate.notEmpty(adhesionTimeLimit, "Adhesion time limit may not be empty");
    _adhesionTimeLimit = Integer.parseInt(adhesionTimeLimit);

    // Load and instantiate the agent builder
    String agentBuilderClassName = _props.getProperty(_AGENT_BUILDER_CLASS);
    Validate.notEmpty(agentBuilderClassName,
            "Agent builder class name (key=" + _AGENT_BUILDER_CLASS + ") may not be empty");
    _agentBuilder = (AgentBuilder) MiscUtils.loadAndInstantiate(agentBuilderClassName,
            "Agent builder class name");

    _agentBuilder.initialize(_simState);

    // Build the agents
    buildAgents();

    // create the predator
    Predator predator = new Predator("P-D");
    predator.initialize(_simState);
    _simState.setPredator(predator);

    _LOG.trace("Exiting initialize()");
}

From source file:edu.snu.leader.hierarchy.simple.DefaultReporter.java

/**
 * Initializes this reporter/*w  ww .  j a  v  a  2  s . c  o m*/
 *
 * @param simState The simulation state
 * @see edu.snu.leader.hierarchy.simple.Reporter#initialize(edu.snu.leader.hierarchy.simple.SimulationState)
 */
@Override
public void initialize(SimulationState simState) {
    _LOG.trace("Entering initialize( state )");

    // Store the simulatino state
    _simState = simState;

    // Grab the properties
    Properties props = simState.getProps();

    // Load the statistics filename
    String statsFile = props.getProperty(_STATS_FILE_KEY);
    Validate.notEmpty(statsFile, "Statistics file may not be empty");

    // Create the statistics writer
    try {
        _writer = new PrintWriter(new BufferedWriter(new FileWriter(statsFile)));
    } catch (IOException ioe) {
        _LOG.error("Unable to open stats file [" + statsFile + "]", ioe);
        throw new RuntimeException("Unable to open stats file [" + statsFile + "]", ioe);
    }

    // Log the system properties to the stats file for future reference
    _writer.println("# Started: " + (new Date()));
    _writer.println(_STATS_SPACER);
    _writer.println("# Simulation properties");
    _writer.println(_STATS_SPACER);
    List<String> keyList = new ArrayList<String>(props.stringPropertyNames());
    Collections.sort(keyList);
    Iterator<String> iter = keyList.iterator();
    while (iter.hasNext()) {
        String key = iter.next();
        String value = props.getProperty(key);

        _writer.println("# " + key + " = " + value);
    }
    _writer.println(_STATS_SPACER);
    _writer.println();

    _LOG.trace("Leaving initialize( state )");
}

From source file:ch.algotrader.esper.EngineManagerImpl.java

@Override
public Engine lookup(String engineName) {

    Validate.notEmpty(engineName, "Engine name is empty");
    return this.engineMap.get(engineName);
}