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

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

Introduction

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

Prototype

public static void notNull(Object object, String message) 

Source Link

Document

Validate an argument, throwing IllegalArgumentException if the argument is null.

 Validate.notNull(myObject, "The object must not be null"); 

Usage

From source file:com.opengamma.analytics.financial.model.option.definition.Barrier.java

public Barrier(final KnockType knock, final BarrierType barrier, final ObservationType observation,
        final double level) {
    Validate.notNull(knock, "knock type");
    Validate.notNull(barrier, "barrier type");
    Validate.notNull(observation, "observation type");
    Validate.isTrue(level > 0, "barrier level must be > 0");
    _knock = knock;/*w  w  w.  j  a  v a  2s. c  o  m*/
    _barrier = barrier;
    _observation = observation;
    _level = level;
}

From source file:net.daboross.bukkitdev.skywars.events.events.PlayerLeaveQueueInfo.java

public PlayerLeaveQueueInfo(final Player player, boolean minPlayersPresent) {
    this.minPlayersPresent = minPlayersPresent;
    Validate.notNull(player, "Player cannot be null");
    this.player = player;
}

From source file:com.opengamma.analytics.financial.model.option.pricing.fourier.EuropeanCallFourierTransform.java

public EuropeanCallFourierTransform(final MartingaleCharacteristicExponent ce) {
    Validate.notNull(ce, "characteristic exponent");
    _ce = ce;
}

From source file:com.edmunds.etm.web.panel.ZooKeeperConfigurationPanel.java

public ZooKeeperConfigurationPanel(String name, ZooKeeperConfig zooKeeperConfig) {
    super(name);//from w  ww .j av  a2s .  co m
    setTemplate("/panel/zookeeper-configuration-panel.htm");

    Validate.notNull(zooKeeperConfig, "ZooKeeper config is null");
    addModel("hostName", defaultString(zooKeeperConfig.getHostName()));
    addModel("port", zooKeeperConfig.getPort());
    addModel("sessionTimeout", zooKeeperConfig.getSessionTimeout());
    addModel("pathPrefix", defaultString(zooKeeperConfig.getPathPrefix()));
    addModel("dnsRetryCount", zooKeeperConfig.getDnsRetryCount());
}

From source file:com.stealthyone.mcb.mcml.MCMLHoverEventItem.java

MCMLHoverEventItem(MCMLBuilder builder, String rawText) {
    Validate.notNull(rawText, "Raw text cannot be null.");
    if (rawText.length() == 6) {
        throw new IllegalArgumentException("Item hover event must have input.");
    }//from  w  ww  . j  ava  2 s.  co  m
    String key = rawText.substring(5, rawText.length() - 1);
    Object item = builder.getReplacement(key);
    if (item == null || !(item instanceof ItemStack)) {
        throw new IllegalArgumentException("No replacement item found with key '" + key + "'");
    }
    itemStack = (ItemStack) item;
}

From source file:com.opengamma.financial.analytics.conversion.BondTradeConverter.java

public BondFixedTransactionDefinition convert(final Trade trade) {
    Validate.notNull(trade, "trade");
    Validate.isTrue(trade.getSecurity() instanceof BondSecurity,
            "Can only handle trades with security type BondSecurity");
    final BondSecurity security = (BondSecurity) trade.getSecurity();
    final InstrumentDefinition<?> underlying = security.accept(_securityConverter);
    if (!(underlying instanceof BondFixedSecurityDefinition)) {
        throw new OpenGammaRuntimeException("Can only handle fixed coupon bonds");
    }//w  w w  .j a  va 2  s.co m
    final BondFixedSecurityDefinition bond = (BondFixedSecurityDefinition) underlying;
    final int quantity = trade.getQuantity().intValue(); // MH - 9-May-2013: changed from 1. // REVIEW: The quantity mechanism should be reviewed.
    final ZonedDateTime settlementDate = trade.getTradeDate().atTime(trade.getTradeTime())
            .atZoneSameInstant(ZoneOffset.UTC); //TODO get the real time zone
    if (trade.getPremium() == null) {
        throw new OpenGammaRuntimeException("Trade premium should not be null.");
    }
    final double price = trade.getPremium().doubleValue();
    return new BondFixedTransactionDefinition(bond, quantity, settlementDate, price);
}

From source file:com.opengamma.analytics.math.interpolation.BarycentricRationalFunctionInterpolator1D.java

@Override
public Double interpolate(final Interpolator1DDataBundle data, final Double value) {
    Validate.notNull(value, "value");
    Validate.notNull(data, "data bundle");
    if (data.size() < _degree) {
        throw new MathException("Cannot interpolate " + data.size()
                + " data points with rational functions of degree " + _degree);
    }/*w w w .  ja  v  a  2s  .  com*/
    final int m = data.size();
    final double[] x = data.getKeys();
    final double[] y = data.getValues();
    if (data.getLowerBoundIndex(value) == m - 1) {
        return y[m - 1];
    }
    final double[] w = getWeights(x);
    final int n = x.length;
    double delta, temp, num = 0, den = 0;
    for (int i = 0; i < n; i++) {
        delta = value - x[i];
        if (Math.abs(delta) < _eps) {
            return y[i];
        }
        temp = w[i] / delta;
        num += temp * y[i];
        den += temp;
    }
    return num / den;
}

From source file:com.opengamma.analytics.math.interpolation.LinearInterpolator1D.java

@Override
public Double interpolate(final Interpolator1DDataBundle model, final Double value) {
    Validate.notNull(value, "Value to be interpolated must not be null");
    Validate.notNull(model, "Data bundle must not be null");
    final InterpolationBoundedValues boundedValues = model.getBoundedValues(value);
    final double x1 = boundedValues.getLowerBoundKey();
    final double y1 = boundedValues.getLowerBoundValue();
    if (model.getLowerBoundIndex(value) == model.size() - 1) {
        return y1;
    }//from   w w w.j a  v a2s  . c  o  m
    final double x2 = boundedValues.getHigherBoundKey();
    final double y2 = boundedValues.getHigherBoundValue();
    return y1 + (value - x1) / (x2 - x1) * (y2 - y1);
}

From source file:com.opengamma.analytics.financial.simpleinstruments.definition.SimpleFutureDefinition.java

public SimpleFutureDefinition(final ZonedDateTime expiryDate, final ZonedDateTime settlementDate,
        final double referencePrice, final Currency currency, final double unitAmount) {
    Validate.notNull(expiryDate, "expiry date");
    Validate.notNull(settlementDate, "settlement date");
    Validate.notNull(currency, "currency");
    _expiryDate = expiryDate;/*from ww w .  j  a v a2  s  .c o  m*/
    _settlementDate = settlementDate;
    _referencePrice = referencePrice;
    _currency = currency;
    _unitAmount = unitAmount;
}

From source file:com.opengamma.analytics.math.interpolation.RationalFunctionInterpolator1D.java

@Override
public Double interpolate(final Interpolator1DDataBundle data, final Double value) {
    Validate.notNull(value, "value");
    Validate.notNull(data, "data bundle");
    final int m = _degree + 1;
    if (data.size() < m) {
        throw new IllegalArgumentException(
                "Need at least " + (_degree + 1) + " data points to perform this interpolation");
    }//from  w w  w. j  av a 2  s  . c o m
    final double[] xArray = data.getKeys();
    final double[] yArray = data.getValues();
    final int n = data.size() - 1;
    if (data.getLowerBoundIndex(value) == n) {
        return yArray[n];
    }
    double diff = Math.abs(value - xArray[0]);
    if (Math.abs(diff) < _eps) {
        return yArray[0];
    }
    double diff1;
    final double[] c = new double[m];
    final double[] d = new double[m];
    int ns = 0;
    for (int i = 0; i < m; i++) {
        diff1 = Math.abs(value - xArray[i]);
        if (diff < _eps) {
            return yArray[i];
        } else if (diff1 < diff) {
            ns = i;
            diff = diff1;
        }
        c[i] = yArray[i];
        d[i] = yArray[i] + _eps;
    }
    double y = yArray[ns--];
    double w, t, dd;
    for (int i = 1; i < m; i++) {
        for (int j = 0; j < m - i; j++) {
            w = c[j + 1] - d[j];
            diff = xArray[i + j] - value;
            t = (xArray[j] - value) * d[j] / diff;
            dd = t - c[j + 1];
            if (Math.abs(dd) < _eps) {
                throw new MathException("Interpolating function has a pole at x = " + value);
            }
            dd = w / dd;
            d[j] = c[j + 1] * dd;
            c[j] = t * dd;
        }
        y += 2 * (ns + 1) < m - i ? c[ns + 1] : d[ns--];
    }
    return y;
}