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.equity.AbstractDerivativeVisitor.java

@Override
// Note: If you have built a class that extends this one and ended up here by accident,
// copy this method into your class.
public T visit(final Derivative derivative, final S data) {
    Validate.notNull(derivative, "derivative");
    Validate.notNull(data, "data");
    return derivative.accept(this, data);
}

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

@Override
public Double interpolate(final Interpolator1DDataBundle data, final Double value) {
    Validate.notNull(value, "value");
    Validate.notNull(data, "data bundle");
    Validate.isTrue(data instanceof Interpolator1DMonotonicIncreasingDataBundle);
    final Interpolator1DMonotonicIncreasingDataBundle miData = (Interpolator1DMonotonicIncreasingDataBundle) data;

    final int n = data.size() - 1;
    final double[] xData = data.getKeys();
    final double[] yData = data.getValues();

    double h, dx, a, b;
    if (value < data.firstKey()) {
        h = 0;// w ww  .j a  v a  2 s  .c o m
        dx = value;
        a = miData.getA(0);
        b = miData.getB(0);
    } else if (value > data.lastKey()) {
        h = yData[n];
        dx = value - xData[n];
        a = miData.getA(n + 1);
        b = miData.getB(n + 1);
    } else {
        final int low = data.getLowerBoundIndex(value);
        h = yData[low];
        dx = value - xData[low];
        a = miData.getA(low + 1);
        b = miData.getB(low + 1);
    }
    if (Math.abs(b * dx) < 1e-8) {
        return h + a * (dx + b * dx * dx / 2);
    }
    return h + a / b * (Math.exp(b * dx) - 1);

}

From source file:com.opengamma.analytics.financial.var.parametric.DeltaMeanCalculator.java

@Override
public Double evaluate(final Map<Integer, ParametricVaRDataBundle> data) {
    Validate.notNull(data, "data");
    Validate.isTrue(data.containsKey(1));
    final ParametricVaRDataBundle deltaData = data.get(1);
    final DoubleMatrix1D mean = deltaData.getExpectedReturn();
    final DoubleMatrix1D delta = (DoubleMatrix1D) deltaData.getSensitivities();
    return _algebra.getInnerProduct(delta, mean);
}

From source file:de.xwic.appkit.core.util.CollectionUtil.java

/**
 * @param collection//www  .j  a v a2  s.  c  o  m
 * @param resultClass
 * @return
 */
public static boolean isOf(final Collection<?> collection, final Class<?> resultClass) {
    Validate.notNull(resultClass, "No result class provided.");
    Validate.notNull(collection, "No collection provided.");
    if (collection.isEmpty()) {
        return true;
    }
    for (final Object cal : collection) {
        if (cal != null && !resultClass.isInstance(cal)) {
            return false;
        }
    }
    return true;
}

From source file:com.opengamma.analytics.math.statistics.descriptive.SampleStandardDeviationCalculator.java

/**
 * @param x The array of data, not null, must contain at least two data points
 * @return The sample standard deviation
 *///w w  w. ja va  2  s .com
@Override
public Double evaluate(final double[] x) {
    Validate.notNull(x, "x");
    Validate.isTrue(x.length >= 2, "Need at least two points to calculate standard deviation");
    return Math.sqrt(VARIANCE.evaluate(x));
}

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

public BondTradeConverter(final BondSecurityConverter securityConverter) {
    Validate.notNull(securityConverter, "security converter");
    _securityConverter = securityConverter;
}

From source file:com.opengamma.analytics.math.statistics.descriptive.robust.TrimmedMeanCalculator.java

@Override
public Double evaluate(final double[] x) {
    Validate.notNull(x, "x was null");
    final int length = x.length;
    Validate.isTrue(length > 0, "x was empty");
    final int value = (int) Math.round(length * _gamma);
    final double[] copy = Arrays.copyOf(x, length);
    Arrays.sort(copy);// w w  w  . ja va  2s  . c o m
    final double[] trimmed = new double[length - 2 * value];
    for (int i = 0; i < trimmed.length; i++) {
        trimmed[i] = x[i + value];
    }
    return MEAN_CALCULATOR.evaluate(trimmed);
}

From source file:io.cloudslang.engine.queue.entities.ExecStateIdList.java

public ExecStateIdList(List<Long> list) {
    Validate.notNull(list, "A list is null");
    this.list = list;
}

From source file:com.opengamma.analytics.financial.equity.capm.CAPMExpectedReturnCalculator.java

public CAPMExpectedReturnCalculator(final DoubleTimeSeriesStatisticsCalculator expectedMarketReturnCalculator,
        final DoubleTimeSeriesStatisticsCalculator expectedRiskFreeReturnCalculator) {
    Validate.notNull(expectedMarketReturnCalculator, "expected market return calculator");
    Validate.notNull(expectedRiskFreeReturnCalculator, "expected risk free return calculator");
    _expectedMarketReturnCalculator = expectedMarketReturnCalculator;
    _expectedRiskFreeReturnCalculator = expectedRiskFreeReturnCalculator;
}

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

@Override
public Double interpolate(final Interpolator1DDataBundle data, final Double value) {
    Validate.notNull(data, "data");
    Validate.notNull(value, "value");
    if (value < data.firstKey()) {
        return data.firstValue();
    } else if (value > data.lastKey()) {
        return data.lastValue();
    }/*from w  w  w  .j a v  a 2s. c  o m*/
    throw new IllegalArgumentException("Value " + value + " was within data range");
}