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.instrument.index.IndexPrice.java

/**
 * Constructor of the price index.//from w  w  w  . j  a v a  2 s  .c o  m
 * @param name The index name. Not null.
 * @param ccy The currency in which the index is computed. Not null.
 */
public IndexPrice(final String name, final Currency ccy) {
    Validate.notNull(name, "Name");
    Validate.notNull(ccy, "Currency");
    _name = name;
    _currency = ccy;
}

From source file:com.opengamma.analytics.financial.simpleinstruments.pricing.SimpleFuturePresentValueCalculator.java

@Override
public Double visit(SimpleInstrument derivative, SimpleFutureDataBundle data) {
    Validate.notNull(derivative, "derivative");
    Validate.notNull(data, "data");
    return derivative.accept(this, data);
}

From source file:com.opengamma.analytics.math.statistics.descriptive.robust.WinsorizedMeanCalculator.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 double[] winsorized = Arrays.copyOf(x, length);
    Arrays.sort(winsorized);/*ww w  . jav  a 2s. c  o m*/
    final int value = (int) Math.round(length * _gamma);
    final double x1 = winsorized[value];
    final double x2 = winsorized[length - value - 1];
    for (int i = 0; i < value; i++) {
        winsorized[i] = x1;
        winsorized[length - 1 - i] = x2;
    }
    return MEAN_CALCULATOR.evaluate(winsorized);
}

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

/**
 * {@inheritDoc}//from  w  w w . ja v  a2  s  .  c  o  m
 */
@Override
public InterpolatedDoublesSurface evaluate(final InterpolatedDoublesSurface surface, final double shift) {
    Validate.notNull(surface, "surface");
    return evaluate(surface, shift, "PARALLEL_SHIFT_" + surface.getName());
}

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

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

From source file:net.camelpe.extension.camel.typeconverter.TypeConverterHolder.java

public static TypeConverterHolder newNonFallbackTypeConverterHolder(final Class<?> fromType,
        final Class<?> toType, final TypeConverter nonFallbackTypeConverter) throws IllegalArgumentException {
    Validate.notNull(fromType, "fromType");
    Validate.notNull(toType, "toType");
    Validate.notNull(nonFallbackTypeConverter, "nonFallbackTypeConverter");

    return new TypeConverterHolder(false, fromType, toType, nonFallbackTypeConverter, false);
}

From source file:com.opengamma.analytics.financial.instrument.annuity.AnnuityCouponCMSDefinition.java

/**
 * CMS annuity (or CMS coupon leg) constructor from standard description. The coupon are fixing in advance and payment in arrears. 
 * The CMS fixing is done at a standard lag before the coupon start.
 * @param settlementDate The settlement date.
 * @param maturityDate The annuity maturity date.
 * @param notional The notional./* w  ww .j ava 2 s .c  o m*/
 * @param index The CMS index.
 * @param paymentPeriod The payment period of the coupons.
 * @param dayCount The day count of the coupons.
 * @param isPayer Payer (true) / receiver (false) flag.
 * @return The CMS coupon leg.
 */
public static AnnuityCouponCMSDefinition from(final ZonedDateTime settlementDate,
        final ZonedDateTime maturityDate, final double notional, final IndexSwap index,
        final Period paymentPeriod, final DayCount dayCount, final boolean isPayer) {
    Validate.notNull(settlementDate, "settlement date");
    Validate.notNull(maturityDate, "maturity date");
    Validate.notNull(index, "index");
    Validate.isTrue(notional > 0, "notional <= 0");
    Validate.notNull(paymentPeriod, "Payment period");
    final ZonedDateTime[] paymentDatesUnadjusted = ScheduleCalculator.getUnadjustedDateSchedule(settlementDate,
            maturityDate, paymentPeriod, true, false);
    final ZonedDateTime[] paymentDates = ScheduleCalculator.getAdjustedDateSchedule(paymentDatesUnadjusted,
            index.getIborIndex().getBusinessDayConvention(), index.getIborIndex().getCalendar(), false);
    final double sign = isPayer ? -1.0 : 1.0;
    final CouponCMSDefinition[] coupons = new CouponCMSDefinition[paymentDates.length];
    coupons[0] = CouponCMSDefinition.from(paymentDates[0], settlementDate, paymentDates[0],
            dayCount.getDayCountFraction(settlementDate, paymentDates[0]), sign * notional, index);
    for (int loopcpn = 1; loopcpn < paymentDates.length; loopcpn++) {
        coupons[loopcpn] = CouponCMSDefinition.from(paymentDates[loopcpn], paymentDates[loopcpn - 1],
                paymentDates[loopcpn],
                dayCount.getDayCountFraction(paymentDates[loopcpn - 1], paymentDates[loopcpn]), sign * notional,
                index);
    }
    return new AnnuityCouponCMSDefinition(coupons);
}

From source file:com.opengamma.financial.analytics.volatility.surface.FuturePriceCurveData.java

public FuturePriceCurveData(final String definitionName, final String specificationName,
        final UniqueIdentifiable target, final X[] xs, final Map<X, Double> values) {
    Validate.notNull(definitionName, "Definition Name");
    Validate.notNull(specificationName, "Specification Name");
    Validate.notNull(target, "Target");
    Validate.notNull(xs, "X axis values");
    Validate.notNull(values, "Volatility Values Map");
    _definitionName = definitionName;/*from w  ww  .j a v a2  s  .  c om*/
    _specificationName = specificationName;
    _target = target;
    _values = new HashMap<X, Double>(values);
    _xs = xs;
}

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

/**
 * @param x The array of data, not null, must contain at least two data points
 * @return The population standard deviation
 *//*from w w w  .  ja va2s.c  o m*/
@Override
public Double evaluate(final double[] x) {
    Validate.notNull(x, "x");
    Validate.isTrue(x.length > 1, "Need at least two points to calculate standard deviation");
    return Math.sqrt(VARIANCE.evaluate(x));
}

From source file:com.opengamma.analytics.financial.timeseries.analysis.RankTestIIDHypothesis.java

@Override
public boolean testIID(final DoubleTimeSeries<?> x) {
    Validate.notNull(x, "x");
    final double[] data = x.valuesArrayFast();
    int t = 0;// w w  w .  j  ava2s.c  o m
    final int n = x.size();
    double val;
    for (int i = 0; i < n - 1; i++) {
        val = data[i];
        for (int j = i + 1; j < n; j++) {
            if (data[j] > val) {
                t++;
            }
        }
    }
    final double mean = n * (n - 1) / 4.;
    final double std = Math.sqrt(n * (n - 1) * (2 * n + 5.) / 72.);
    return Math.abs(t - mean) / std < _criticalValue;
}