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:com.seyren.mongo.MongoStore.java

@Override
public SeyrenResponse getChecksByPattern(List<String> checkFields, List<Pattern> patterns, Boolean enabled) {
    Validate.notNull(checkFields, "Fields may not be null.");
    Validate.notNull(patterns, "Patterns may not be null.");
    Validate.notEmpty(checkFields, "Fields may not be empty");
    Validate.notEmpty(patterns, "Patterns may not be empty");
    Validate.isTrue(checkFields.size() == patterns.size(),
            String.format(// w  ww  .  ja va2s.c om
                    "Fields[%s] have same number of elements as patterns[%s].  "
                            + "fieldsSize[%d] != fieldsSize[%d]",
                    checkFields, patterns, checkFields.size(), patterns.size()));

    DBObject query = new BasicDBObject();
    for (int i = 0; i < checkFields.size(); i++) {
        query.put(checkFields.get(i), patterns.get(i));
    }
    if (enabled != null) {
        query.put("enabled", enabled);
    }

    return executeQueryAndCollectResponse(query);
}

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

/**
 * Initializes Agent// w  w  w . j a v  a 2  s. co m
 * 
 * @param simState The simulation state
 */
public void initialize(SimulationState simState, Point2D initialLocation) {
    _simState = simState;

    _initialLocation = new Vector2D(initialLocation.getX(), initialLocation.getY());

    String nearestNeighborCount = _simState.getProperties().getProperty("nearest-neighbor-count");
    Validate.notEmpty(nearestNeighborCount, "Nearest neighbor count may not be empty");
    _nearestNeighborCount = Integer.parseInt(nearestNeighborCount);

    String maxLocationRadius = _simState.getProperties().getProperty("max-location-radius");
    Validate.notEmpty(maxLocationRadius, "Max location raidus may not be empty");
    _maxLocationRadius = Double.parseDouble(maxLocationRadius);

    String canMultipleInitiate = _simState.getProperties().getProperty("can-multiple-initiate");
    Validate.notEmpty(canMultipleInitiate, "Can multiple initiate may not be empty");
    _canMultipleInitiate = Boolean.parseBoolean(canMultipleInitiate);

    String cancellationThreshold = _simState.getProperties().getProperty("cancellation-threshold");
    Validate.notEmpty(cancellationThreshold, "Use cancellation threshold may not be empty");
    _cancellationThreshold = Double.parseDouble(cancellationThreshold);

    String lambda = _simState.getProperties().getProperty("lambda");
    Validate.notEmpty(lambda, "Lambda may not be empty");
    _lambda = Float.parseFloat(lambda);

    String preCalcProbs = _simState.getProperties().getProperty("pre-calculate-probabilities");
    Validate.notEmpty(preCalcProbs, "pre-calculate-probabilities may not be empty");
    _preCalcProbs = Boolean.parseBoolean(preCalcProbs);

    _communicationType = _simState.getCommunicationType();

    _positionHistory = new Reporter(_id.toString() + ".dat", "", false);

    reset();

    _personalityTrait.initialize(this);
}

From source file:ch.algotrader.adapter.fix.DefaultFixAdapter.java

@Override
public void closeSession(String sessionQualifier) throws BrokerAdapterException {

    Validate.notEmpty(sessionQualifier, "Session qualifier is empty");

    this.lock.lock();
    try {/*  w  w w. j  av a  2 s  .co  m*/
        SessionID sessionId = findSessionID(sessionQualifier);
        Session session = Session.lookupSession(sessionId);
        if (session != null) {
            session.close();
        }
    } catch (IOException ex) {
        throw new BrokerAdapterException(ex.getMessage(), ex);
    } finally {
        this.lock.unlock();
    }
}

From source file:com.vmware.identity.idm.RSAAgentConfig.java

/**
 * @param idsName/*  ww w.  j av  a  2 s  . c om*/
 * @param ldapAttr
 */
public void add_idsUserIDAttributeMap(String idsName, String ldapAttr) {
    Validate.notEmpty(idsName, "idsName");
    Validate.notEmpty(ldapAttr, "ldapAttr");

    if (this._idsUserIDAttributeMap == null) {
        this._idsUserIDAttributeMap = new HashMap<String, String>();
    }
    this._idsUserIDAttributeMap.put(idsName, ldapAttr);
}