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.volatility.curve.FXVannaVolgaVolatilityCurveDataBundle.java

public FXVannaVolgaVolatilityCurveDataBundle(final double delta, final double riskReversal, final double atm,
        final double vegaWeightedButterfly, final ZonedDateTime maturity) {
    ArgumentChecker.notNegative(atm, "atm");
    Validate.notNull(maturity, "maturity");
    _delta = delta;//from  w  ww .  j  a  v  a 2  s  .c o  m
    _riskReversal = riskReversal;
    _atm = atm;
    _vegaWeightedButterfly = vegaWeightedButterfly;
    _maturity = maturity;
}

From source file:com.opengamma.analytics.math.minimization.LineSearch.java

public double minimise(final Function1D<DoubleMatrix1D, Double> function, final DoubleMatrix1D direction,
        final DoubleMatrix1D x) {
    Validate.notNull(function, "function");
    Validate.notNull(direction, "direction");
    Validate.notNull(x, "x");
    final LineSearchFunction f = new LineSearchFunction(function, direction, x);

    final double[] bracketPoints = _bracketer.getBracketedPoints(f, 0, 1);
    if (bracketPoints[2] < bracketPoints[0]) {
        final double temp = bracketPoints[0];
        bracketPoints[0] = bracketPoints[2];
        bracketPoints[2] = temp;/*w w  w.jav  a  2 s .co m*/
    }
    return _minimizer.minimize(f, bracketPoints[1], bracketPoints[0], bracketPoints[2]);
}

From source file:com.opengamma.analytics.financial.model.volatility.smile.function.SVIVolatilityFunction.java

@Override
public Function1D<SVIFormulaData, Double> getVolatilityFunction(final EuropeanVanillaOption option,
        final double forward) {
    Validate.notNull(option, "option");
    Validate.isTrue(forward > 0, "Need forward >= 0");
    final double strike = option.getStrike();
    Validate.isTrue(strike > 0, "Need strike >= 0");
    final double kappa = Math.log(strike / forward);

    return new Function1D<SVIFormulaData, Double>() {
        @SuppressWarnings("synthetic-access")
        @Override/*from  w w  w .j  a  v  a 2  s .c  o m*/
        public Double evaluate(final SVIFormulaData data) {
            return getVolatility(kappa, data);
        }
    };
}

From source file:me.st28.flexseries.flexcore.util.MapUtils.java

/**
 * Retrieves an entry from a map with a given index. Intended for maps that preserve ordering (ex. LinkedHashMap)
 *
 * @param map The map to retrieve the entry from.
 * @param index The index of the entry in the map.
 * @return The entry at the given index in the given map.
 *//*w  ww .j a  v  a  2 s  .  c  om*/
public static <K, V> Entry<K, V> getEntryByIndex(Map<K, V> map, int index) {
    Validate.notNull(map, "Map cannot be null.");
    int mapSize = map.size();

    int curIndex = 0;
    Iterator<Entry<K, V>> iterator = map.entrySet().iterator();
    while (iterator.hasNext() && curIndex < mapSize) {
        if (curIndex++ == index) {
            return iterator.next();
        }
    }
    throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + mapSize);
}

From source file:com.opengamma.analytics.math.statistics.estimation.NormalDistributionMomentEstimator.java

@Override
public ProbabilityDistribution<Double> evaluate(final double[] x) {
    Validate.notNull(x, "x");
    ArgumentChecker.notEmpty(x, "x");
    final double m1 = _first.evaluate(x);
    return new NormalDistribution(m1, Math.sqrt(_second.evaluate(x) - m1 * m1));
}

From source file:com.opengamma.analytics.math.surface.ConstantSurfaceAdditiveShiftFunction.java

/**
 * {@inheritDoc}/*from  w  w w .  ja  v  a 2  s .  c o  m*/
 */
@Override
public ConstantDoublesSurface evaluate(final ConstantDoublesSurface surface, final double shift,
        final String newName) {
    Validate.notNull(surface, "surface");
    final double z = surface.getZValue(0., 0.);
    return ConstantDoublesSurface.from(z + shift, newName);
}

From source file:com.fusesource.examples.horo.db.HoroscopeUtils.java

public HoroscopeUtils(DataSource dataSource) {
    Validate.notNull(dataSource, "dataSource is null");
    this.jdbcTemplate = new JdbcTemplate(dataSource);
}

From source file:com.opengamma.analytics.math.statistics.estimation.GammaDistributionMomentEstimator.java

@Override
public ProbabilityDistribution<Double> evaluate(final double[] x) {
    Validate.notNull(x, "x");
    ArgumentChecker.notEmpty(x, "x");
    final double m1 = _first.evaluate(x);
    final double m2 = _second.evaluate(x);
    final double m1Sq = m1 * m1;
    final double k = m1Sq / (m2 - m1Sq);
    final double theta = m1 / k;
    return new GammaDistribution(k, theta);
}

From source file:io.cloudslang.worker.management.services.RetryTemplate.java

public void retry(int maxRetries, long sleepBetweenRetries, RetryCallback callback) {
    Validate.notNull(callback, "Callback is null");

    boolean infinity = (maxRetries == INFINITELY);
    for (int i = 0; infinity || i < maxRetries - 1; i++) {
        try {//from w  w  w.j av  a  2 s .  com
            callback.tryOnce();
            return;
        } catch (Exception ex) {
            logger.error("Try #" + (i + 1) + " failed on: ", ex);
            if (sleepBetweenRetries > 0)
                try {
                    Thread.sleep(sleepBetweenRetries);
                } catch (InterruptedException iex) {
                    /* do nothing*/}
        }
    }
    callback.tryOnce();
}

From source file:com.opengamma.analytics.math.matrix.ColtMatrixAlgebra.java

/**
 * {@inheritDoc}/*  w  w w .j  a  v a2  s. c o m*/
 */
@Override
public double getCondition(final Matrix<?> m) {
    Validate.notNull(m, "m");
    if (m instanceof DoubleMatrix2D) {
        return ALGEBRA.cond(DoubleFactory2D.dense.make(((DoubleMatrix2D) m).getData()));
    }
    throw new IllegalArgumentException("Can only find condition of DoubleMatrix2D; have " + m.getClass());
}