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:net.jadler.stubbing.server.jdk.JdkHandler.java

public JdkHandler(final RequestManager requestManager) {
    Validate.notNull(requestManager, "requestManager cannot be null");

    this.requestManager = requestManager;
}

From source file:com.opengamma.analytics.financial.schedule.MonthlyScheduleCalculator.java

@Override
public LocalDate[] getSchedule(final LocalDate startDate, final LocalDate endDate, final boolean fromEnd,
        final boolean generateRecursive) {
    Validate.notNull(startDate, "start date");
    Validate.notNull(endDate, "end date");
    Validate.isTrue(startDate.isBefore(endDate) || startDate.equals(endDate));
    if (startDate.equals(endDate)) {
        return new LocalDate[] { startDate };
    }/*w ww. jav a2s  .c  om*/
    final List<LocalDate> dates = new ArrayList<LocalDate>();
    if (fromEnd) {
        LocalDate date = endDate;
        int i = 1;
        while (!date.isBefore(startDate)) {
            dates.add(date);
            date = generateRecursive ? date.minus(Period.ofMonths(1)) : endDate.minus(Period.ofMonths(i++));
        }
        Collections.reverse(dates);
        return dates.toArray(EMPTY_LOCAL_DATE_ARRAY);
    }
    LocalDate date = startDate;
    int i = 1;
    while (!date.isAfter(endDate)) {
        dates.add(date);
        date = generateRecursive ? date.plus(Period.ofMonths(1)) : startDate.plus(Period.ofMonths(i++));
    }
    return dates.toArray(EMPTY_LOCAL_DATE_ARRAY);
}

From source file:com.opengamma.analytics.math.curve.FunctionalCurveShiftFunction.java

/**
 * {@inheritDoc}//from   w ww .  j ava2s . c o m
 */
@Override
public FunctionalDoublesCurve evaluate(final FunctionalDoublesCurve curve, final double shift) {
    Validate.notNull(curve, "curve");
    return evaluate(curve, shift, "PARALLEL_SHIFT_" + curve.getName());
}

From source file:com.opengamma.analytics.financial.schedule.QuarterlyScheduleCalculator.java

@Override
public LocalDate[] getSchedule(final LocalDate startDate, final LocalDate endDate, final boolean fromEnd,
        final boolean generateRecursive) {
    Validate.notNull(startDate, "start date");
    Validate.notNull(endDate, "end date");
    Validate.isTrue(startDate.isBefore(endDate) || startDate.equals(endDate));
    if (startDate.equals(endDate)) {
        return new LocalDate[] { startDate };
    }//w  w  w . j  a  v  a2  s.co  m
    final List<LocalDate> dates = new ArrayList<LocalDate>();
    if (fromEnd) {
        LocalDate date = endDate;
        int i = 3;
        while (!date.isBefore(startDate)) {
            dates.add(date);
            date = generateRecursive ? date.minus(Period.ofMonths(3)) : endDate.minus(Period.ofMonths(i));
            i += 3;
        }
        Collections.reverse(dates);
        return dates.toArray(EMPTY_LOCAL_DATE_ARRAY);
    }
    LocalDate date = startDate;
    int i = 3;
    while (!date.isAfter(endDate)) {
        dates.add(date);
        date = generateRecursive ? date.plus(Period.ofMonths(3)) : startDate.plus(Period.ofMonths(i));
        i += 3;
    }
    return dates.toArray(EMPTY_LOCAL_DATE_ARRAY);
}

From source file:com.opengamma.analytics.financial.schedule.SemiAnnualScheduleCalculator.java

@Override
public LocalDate[] getSchedule(final LocalDate startDate, final LocalDate endDate, final boolean fromEnd,
        final boolean generateRecursive) {
    Validate.notNull(startDate, "start date");
    Validate.notNull(endDate, "end date");
    Validate.isTrue(startDate.isBefore(endDate) || startDate.equals(endDate));
    if (startDate.equals(endDate)) {
        return new LocalDate[] { startDate };
    }//from w w  w .jav  a2 s.c  om
    final List<LocalDate> dates = new ArrayList<LocalDate>();
    if (fromEnd) {
        LocalDate date = endDate;
        int i = 6;
        while (!date.isBefore(startDate)) {
            dates.add(date);
            date = generateRecursive ? date.minus(Period.ofMonths(6)) : endDate.minus(Period.ofMonths(i));
            i += 6;
        }
        Collections.reverse(dates);
        return dates.toArray(EMPTY_LOCAL_DATE_ARRAY);
    }
    LocalDate date = startDate;
    int i = 6;
    while (!date.isAfter(endDate)) {
        dates.add(date);
        date = generateRecursive ? date.plus(Period.ofMonths(6)) : startDate.plus(Period.ofMonths(i));
        i += 6;
    }
    return dates.toArray(EMPTY_LOCAL_DATE_ARRAY);
}

From source file:com.opengamma.analytics.financial.pnl.SensitivityPnLCalculator.java

@Override
public DoubleTimeSeries<?> evaluate(final SensitivityAndReturnDataBundle... data) {
    Validate.notNull(data, "data");
    DoubleTimeSeries<?> result = null;
    DoubleTimeSeries<?> pnl = null;
    for (final SensitivityAndReturnDataBundle bundle : data) {
        final Underlying underlying = bundle.getUnderlying();
        final Map<UnderlyingType, DoubleTimeSeries<?>> underlyingData = bundle.getUnderlyingReturnTS();
        if (result == null) {
            result = TaylorExpansionMultiplierCalculator.getTimeSeries(underlyingData, underlying);
            result = result.multiply(bundle.getValue());
        } else {//from   ww w.ja  v  a  2  s. co  m
            pnl = TaylorExpansionMultiplierCalculator.getTimeSeries(underlyingData, underlying);
            result = result.add(pnl.multiply(bundle.getValue()));
        }
    }
    return result;
}

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

/**
 * //from  w  w w.  j a  v a  2s  .co m
 * @param surface  The time to maturity should be the first coordinate and the strike the second 
 */
public PriceSurface(final Surface<Double, Double, Double> surface) {
    Validate.notNull(surface, "surface");
    _surface = surface;
}

From source file:com.opengamma.analytics.financial.timeseries.util.TimeSeriesPercentageChangeOperator.java

@Override
public DateDoubleTimeSeries<?> evaluate(DateDoubleTimeSeries<?> ts) {
    Validate.notNull(ts, "time series");
    Validate.isTrue(ts.size() > 1, "time series length must be > 1");
    final int[] times = ts.timesArrayFast();
    final double[] values = ts.valuesArrayFast();
    final int n = times.length;
    final int[] resultTimes = new int[n - 1];
    final double[] percentageChanges = new double[n - 1];
    for (int i = 1; i < n; i++) {
        resultTimes[i - 1] = times[i];/*ww w  . j  ava 2 s.  c  o m*/
        percentageChanges[i - 1] = (values[i] - values[i - 1]) / values[i - 1];
    }
    return ImmutableLocalDateDoubleTimeSeries.of(resultTimes, percentageChanges);
}

From source file:com.opengamma.analytics.financial.instrument.index.Generator.java

/**
 * Constructor.
 * @param name The generator name.
 */
public Generator(String name) {
    Validate.notNull(name, "Name");
    _name = name;
}

From source file:com.opengamma.analytics.financial.greeks.MixedOrderUnderlying.java

public MixedOrderUnderlying(final NavigableMap<Integer, UnderlyingType> underlyings) {
    Validate.notNull(underlyings, "underlyings");
    if (underlyings.size() < 2) {
        throw new IllegalArgumentException("Must have at least two underlying types to have mixed order");
    }/*from www. j a v a  2s.c  om*/
    _orders = new ArrayList<>();
    _underlyings = new ArrayList<>();
    int totalOrder = 0;
    UnderlyingType underlying;
    for (final Entry<Integer, UnderlyingType> entry : underlyings.entrySet()) {
        final int key = entry.getKey();
        if (key < 1) {
            throw new IllegalArgumentException("Order must be at least one to have mixed order");
        }
        underlying = entry.getValue();
        _orders.add(new NthOrderUnderlying(key, underlying));
        _underlyings.add(underlying);
        totalOrder += key;
    }
    _totalOrder = totalOrder;
}