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:net.jadler.Request.java

@SuppressWarnings("unchecked")
private Request(final String method, final URI requestURI, final KeyValues headers, final byte[] body,
        final Charset encoding) {

    Validate.notEmpty(method, "method cannot be empty");
    this.method = method;

    Validate.notNull(requestURI, "requestURI cannot be null");
    this.requestURI = requestURI;

    this.encoding = encoding;

    Validate.notNull(body, "body cannot be null, use an empty array instead");
    this.body = body;

    Validate.notNull(headers, "headers cannot be null");
    this.headers = headers;

    this.parameters = readParameters();
}

From source file:com.evolveum.midpoint.repo.sql.query2.hqm.condition.PropertyCondition.java

protected String createParameterName(String propertyPath) {
    Validate.notEmpty(propertyPath, "propertyPath");
    int i = propertyPath.lastIndexOf('.');
    if (i < 0) {
        return propertyPath;
    } else {//from  w  w w  .  j a v  a2 s  . c o  m
        String name = propertyPath.substring(i + 1);
        if (!name.isEmpty()) {
            return name;
        } else {
            return "param"; // shouldn't occur
        }
    }
}

From source file:ch.algotrader.broker.MarketDataSubscriptionTopicRouter.java

public MarketDataSubscriptionTopicRouter(final String baseTopic) {

    Validate.notEmpty(baseTopic, "Base topic is empty");

    this.baseTopic = baseTopic;
}

From source file:com.fusesource.examples.horo.rssReader.HoroscopeBuilder.java

public Horoscope build(@Header("sign") StarSign starSign, @Header("date") String date,
        @Header("feedName") String feedName, @Body String entry) throws ParseException {
    Validate.notNull(starSign, "starSign is null");
    Validate.notEmpty(date, "date is empty");
    Validate.notEmpty(feedName, "feedName is empty");
    Validate.notEmpty(entry, "entry is empty");

    Feed feed = new Feed();
    feed.setName(feedName);// ww  w  .j a  va2 s  .c  o  m

    Horoscope horoscope = new Horoscope();
    horoscope.setStarSign(starSign);
    horoscope.setFeed(feed);
    horoscope.setEntry(entry);

    SimpleDateFormat format = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy");
    DateTime dateTime = new DateTime(format.parse(date)).toDateTime(DateTimeZone.UTC).toDateMidnight()
            .toDateTime();
    horoscope.setPredictsFor(dateTime);
    return horoscope;
}

From source file:com.opengamma.analytics.financial.model.volatility.smile.fitting.LeastSquareSmileFitter.java

protected void testData(final EuropeanVanillaOption[] options, final BlackFunctionData[] data,
        final double[] errors, final double[] initialFitParameters, final BitSet fixed, final int nParameters) {
    Validate.notEmpty(options, "options");
    final int n = options.length;
    Validate.notNull(data, "data");
    Validate.isTrue(data.length == n, "Black function data array must be the same length as option array");
    if (errors != null) {
        Validate.isTrue(errors.length == n, "Error array length must be the same as the option array length");
    }/* www.  ja va 2  s . co m*/
    Validate.notNull(initialFitParameters, "initial values");
    Validate.isTrue(initialFitParameters.length == nParameters,
            "must have length of initial values array equal to number of parameters");
    Validate.notNull(fixed, "fixed");

    final double t = options[0].getTimeToExpiry();
    final double fwd = data[0].getForward();
    final double df = data[0].getDiscountFactor();

    for (int i = 1; i < n; i++) {
        Validate.isTrue(Double.doubleToLongBits(options[i].getTimeToExpiry()) == Double.doubleToLongBits(t),
                "options not all at same time horizon");
        Validate.isTrue(Double.doubleToLongBits(data[i].getForward()) == Double.doubleToLongBits(fwd),
                "options don't all have same forward");
        Validate.isTrue(Double.doubleToLongBits(data[i].getDiscountFactor()) == Double.doubleToLongBits(df),
                "options don't all have same discount factors");
    }
}

From source file:com.edmunds.zookeeper.election.ZooKeeperElectionNode.java

/**
 * Constructs a ZooKeeperElectionNode from a full path.
 *
 * @param path the path./*from w w w  . j  a  v  a2  s  . c o  m*/
 * @throws IllegalArgumentException if the path is blank or doesn't contain a /
 */
public ZooKeeperElectionNode(String path) throws IllegalArgumentException {
    Validate.notEmpty(path, "path is blank");

    final int lastSlash = path.lastIndexOf("/");
    Validate.isTrue(lastSlash != -1, "path must contain a /");

    this.name = path.substring(lastSlash + 1);
    this.path = path;
}

From source file:ch.algotrader.adapter.ib.IBCustomMessage.java

public IBCustomMessage(final String id, final Type type, final String content) {

    Validate.notEmpty(id, "Message ID is empty");
    Validate.notNull(type, "Message type is null");
    Validate.notEmpty(id, "Message content is empty");

    this.id = id;
    this.type = type;
    this.content = content;
}

From source file:ch.algotrader.vo.LogEventVO.java

public LogEventVO(final String priority, final String eventMessage,
        final Class<? extends Throwable> exceptionClass, final String exceptionMessage) {

    Validate.notEmpty(priority, "Log priority is empty");

    this.priority = priority.toLowerCase(Locale.ROOT);
    this.eventMessage = eventMessage;
    this.exceptionClass = exceptionClass;
    this.exceptionMessage = exceptionMessage;
}

From source file:ch.algotrader.concurrent.BasicThreadFactory.java

public BasicThreadFactory(final String name, final ThreadGroup threadGroup, final Boolean daemon) {

    Validate.notEmpty(name, "Session name is null");
    this.name = name;
    this.threadGroup = threadGroup;
    this.daemon = daemon;
}

From source file:com.edmunds.etm.common.api.RuleSetDeploymentEvent.java

public RuleSetDeploymentEvent(Date eventDate, String ruleSetDigest, RuleSetDeploymentResult result) {
    Validate.notNull(eventDate, "Event date is null");
    Validate.notEmpty(ruleSetDigest, "Rule set digest is empty");
    Validate.notNull(result, "Result is null");
    this.eventDate = eventDate;
    this.ruleSetDigest = ruleSetDigest;
    this.result = result;
}