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.math.statistics.descriptive.robust.InterquartileRangeCalculator.java

@Override
public Double evaluate(final double[] x) {
    Validate.notNull(x, "x");
    final int n = x.length;
    Validate.isTrue(n > 3, "Need at least four points to calculate IQR");
    final double[] copy = Arrays.copyOf(x, n);
    Arrays.sort(copy);//from   w  w  w  . j av  a 2 s.c om
    double[] lower, upper;
    if (n % 2 == 0) {
        lower = Arrays.copyOfRange(copy, 0, n / 2);
        upper = Arrays.copyOfRange(copy, n / 2, n);
    } else {
        lower = Arrays.copyOfRange(copy, 0, n / 2 + 1);
        upper = Arrays.copyOfRange(copy, n / 2, n);
    }
    return MEDIAN.evaluate(upper) - MEDIAN.evaluate(lower);
}

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

@Override
public DateDoubleTimeSeries<?> evaluate(final 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[] differenceTimes = new int[n - 1];
    final double[] differenceValues = new double[n - 1];
    for (int i = 1; i < n; i++) {
        differenceTimes[i - 1] = times[i];
        differenceValues[i - 1] = values[i] - values[i - 1];
    }//from  www  .ja v  a2 s . co  m
    return ImmutableLocalDateDoubleTimeSeries.of(differenceTimes, differenceValues);
}

From source file:com.opengamma.financial.convention.CHConventions.java

public static synchronized void addFixedIncomeInstrumentConventions(
        final ConventionBundleMaster conventionMaster) {
    Validate.notNull(conventionMaster, "convention master");
    final BusinessDayConvention modified = BusinessDayConventionFactory.INSTANCE
            .getBusinessDayConvention("Modified Following");
    final BusinessDayConvention following = BusinessDayConventionFactory.INSTANCE
            .getBusinessDayConvention("Following");
    final DayCount act360 = DayCountFactory.INSTANCE.getDayCount("Actual/360");
    final DayCount thirty360 = DayCountFactory.INSTANCE.getDayCount("30/360");
    final Frequency quarterly = SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.QUARTERLY_NAME);
    final Frequency semiAnnual = SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.SEMI_ANNUAL_NAME);
    final Frequency annual = SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.ANNUAL_NAME);
    final ExternalId ch = ExternalSchemes.financialRegionId("CH");

    final ConventionBundleMasterUtils utils = new ConventionBundleMasterUtils(conventionMaster);
    //TODO check that it's actually libor that we need
    utils.addConventionBundle(//from   w  w  w .  j  a v a  2 s .  co m
            ExternalIdBundle.of(bloombergTickerSecurityId("SF00O/N Index"),
                    simpleNameSecurityId("CHF LIBOR O/N")),
            "CHF LIBOR O/N", act360, following, Period.ofDays(1), 0, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SF00S/N Index"),
                    simpleNameSecurityId("CHF LIBOR S/N")),
            "CHF LIBOR S/N", act360, following, Period.ofDays(1), 0, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SF00T/N Index"),
                    simpleNameSecurityId("CHF LIBOR T/N")),
            "CHF LIBOR T/N", act360, following, Period.ofDays(1), 0, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SF0001W Index"),
                    simpleNameSecurityId("CHF LIBOR 1w")),
            "CHF LIBOR 1w", act360, following, Period.ofDays(7), 2, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SF0002W Index"),
                    simpleNameSecurityId("CHF LIBOR 2w")),
            "CHF LIBOR 2w", act360, following, Period.ofDays(14), 2, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SF0001M Index"),
                    simpleNameSecurityId("CHF LIBOR 1m")),
            "CHF LIBOR 1m", act360, following, Period.ofMonths(1), 2, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SF0002M Index"),
                    simpleNameSecurityId("CHF LIBOR 2m")),
            "CHF LIBOR 2m", act360, following, Period.ofMonths(2), 2, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SF0003M Index"),
                    simpleNameSecurityId("CHF LIBOR 3m")),
            "CHF LIBOR 3m", act360, following, Period.ofMonths(3), 2, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SF0004M Index"),
                    simpleNameSecurityId("CHF LIBOR 4m")),
            "CHF LIBOR 4m", act360, following, Period.ofMonths(4), 2, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SF0005M Index"),
                    simpleNameSecurityId("CHF LIBOR 5m")),
            "CHF LIBOR 5m", act360, following, Period.ofMonths(5), 2, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SF0006M Index"),
                    simpleNameSecurityId("CHF LIBOR 6m")),
            "CHF LIBOR 6m", act360, following, Period.ofMonths(6), 2, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SF0007M Index"),
                    simpleNameSecurityId("CHF LIBOR 7m")),
            "CHF LIBOR 7m", act360, following, Period.ofMonths(7), 2, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SF0008M Index"),
                    simpleNameSecurityId("CHF LIBOR 8m")),
            "CHF LIBOR 8m", act360, following, Period.ofMonths(8), 2, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SF0009M Index"),
                    simpleNameSecurityId("CHF LIBOR 9m")),
            "CHF LIBOR 9m", act360, following, Period.ofMonths(9), 2, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SF0010M Index"),
                    simpleNameSecurityId("CHF LIBOR 10m")),
            "CHF LIBOR 10m", act360, following, Period.ofMonths(10), 2, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SF0011M Index"),
                    simpleNameSecurityId("CHF LIBOR 11m")),
            "CHF LIBOR 11m", act360, following, Period.ofMonths(11), 2, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SF0012M Index"),
                    simpleNameSecurityId("CHF LIBOR 12m")),
            "CHF LIBOR 12m", act360, following, Period.ofMonths(12), 2, false, ch);

    //TODO need to check that these are right for deposit rates
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SFDR1T Curncy"),
                    simpleNameSecurityId("CHF DEPOSIT 1d")),
            "CHF DEPOSIT 1d", act360, following, Period.ofDays(1), 0, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SFDR2T Curncy"),
                    simpleNameSecurityId("CHF DEPOSIT 2d")),
            "CHF DEPOSIT 2d", act360, following, Period.ofDays(1), 1, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SFDR3T Curncy"),
                    simpleNameSecurityId("CHF DEPOSIT 3d")),
            "CHF DEPOSIT 3d", act360, following, Period.ofDays(1), 2, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SFDR1Z Curncy"),
                    simpleNameSecurityId("CHF DEPOSIT 1w")),
            "CHF DEPOSIT 1w", act360, following, Period.ofDays(7), 2, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SFDR2Z Curncy"),
                    simpleNameSecurityId("CHF DEPOSIT 2w")),
            "CHF DEPOSIT 2w", act360, following, Period.ofDays(14), 2, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SFDR3Z Curncy"),
                    simpleNameSecurityId("CHF DEPOSIT 3w")),
            "CHF DEPOSIT 3w", act360, following, Period.ofDays(21), 2, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SFDRA Curncy"),
                    simpleNameSecurityId("CHF DEPOSIT 1m")),
            "CHF DEPOSIT 1m", act360, following, Period.ofMonths(1), 2, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SFDRB Curncy"),
                    simpleNameSecurityId("CHF DEPOSIT 2m")),
            "CHF DEPOSIT 2m", act360, following, Period.ofMonths(2), 2, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SFDRC Curncy"),
                    simpleNameSecurityId("CHF DEPOSIT 3m")),
            "CHF DEPOSIT 3m", act360, following, Period.ofMonths(3), 2, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SFDRD Curncy"),
                    simpleNameSecurityId("CHF DEPOSIT 4m")),
            "CHF DEPOSIT 4m", act360, following, Period.ofMonths(4), 2, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SFDRE Curncy"),
                    simpleNameSecurityId("CHF DEPOSIT 5m")),
            "CHF DEPOSIT 5m", act360, following, Period.ofMonths(5), 2, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SFDRF Curncy"),
                    simpleNameSecurityId("CHF DEPOSIT 6m")),
            "CHF DEPOSIT 6m", act360, following, Period.ofMonths(6), 2, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SFDRG Curncy"),
                    simpleNameSecurityId("CHF DEPOSIT 7m")),
            "CHF DEPOSIT 7m", act360, following, Period.ofMonths(7), 2, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SFDRH Curncy"),
                    simpleNameSecurityId("CHF DEPOSIT 8m")),
            "CHF DEPOSIT 8m", act360, following, Period.ofMonths(8), 2, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SFDRI Curncy"),
                    simpleNameSecurityId("CHF DEPOSIT 9m")),
            "CHF DEPOSIT 9m", act360, following, Period.ofMonths(9), 2, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SFDRJ Curncy"),
                    simpleNameSecurityId("CHF DEPOSIT 10m")),
            "CHF DEPOSIT 10m", act360, following, Period.ofMonths(10), 2, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SFDRK Curncy"),
                    simpleNameSecurityId("CHF DEPOSIT 11m")),
            "CHF DEPOSIT 11m", act360, following, Period.ofMonths(11), 2, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SFDR1 Curncy"),
                    simpleNameSecurityId("CHF DEPOSIT 1y")),
            "CHF DEPOSIT 1y", act360, following, Period.ofYears(1), 2, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SFDR2 Curncy"),
                    simpleNameSecurityId("CHF DEPOSIT 2y")),
            "CHF DEPOSIT 2y", act360, following, Period.ofYears(2), 2, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SFDR3 Curncy"),
                    simpleNameSecurityId("CHF DEPOSIT 3y")),
            "CHF DEPOSIT 3y", act360, following, Period.ofYears(3), 2, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SFDR4 Curncy"),
                    simpleNameSecurityId("CHF DEPOSIT 4y")),
            "CHF DEPOSIT 4y", act360, following, Period.ofYears(4), 2, false, ch);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SFDR5 Curncy"),
                    simpleNameSecurityId("CHF DEPOSIT 5y")),
            "CHF DEPOSIT 5y", act360, following, Period.ofYears(5), 2, false, ch);

    //TODO check reference rate
    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("CHF_SWAP")), "CHF_SWAP", thirty360,
            modified, annual, 2, ch, act360, modified, semiAnnual, 2, simpleNameSecurityId("CHF LIBOR 6m"), ch,
            true);
    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("CHF_3M_SWAP")), "CHF_3M_SWAP",
            thirty360, modified, annual, 2, ch, act360, modified, quarterly, 2,
            simpleNameSecurityId("CHF LIBOR 3m"), ch, true);
    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("CHF_6M_SWAP")), "CHF_6M_SWAP",
            thirty360, modified, annual, 2, ch, act360, modified, semiAnnual, 2,
            simpleNameSecurityId("CHF LIBOR 6m"), ch, true);

    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("CHF_3M_FRA")), "CHF_3M_FRA", thirty360,
            modified, annual, 2, ch, act360, modified, quarterly, 2, simpleNameSecurityId("CHF LIBOR 3m"), ch,
            true);
    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("CHF_6M_FRA")), "CHF_6M_FRA", thirty360,
            modified, annual, 2, ch, act360, modified, semiAnnual, 2, simpleNameSecurityId("CHF LIBOR 6m"), ch,
            true);

    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId(IndexType.Libor + "_CHF_P3M")),
            IndexType.Libor + "_CHF_P3M", thirty360, modified, null, 2, false, ch);
    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId(IndexType.Libor + "_CHF_P6M")),
            IndexType.Libor + "_CHF_P6M", thirty360, modified, null, 2, false, ch);
    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId(IndexType.Euribor + "_CHF_P3M")),
            IndexType.Euribor + "_CHF_P3M", thirty360, modified, null, 2, false, ch);
    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId(IndexType.Euribor + "_CHF_P6M")),
            IndexType.Euribor + "_CHF_P6M", thirty360, modified, null, 2, false, ch);

    // Overnight Index Swap Convention have additional flag, publicationLag
    final Integer publicationLagON = 0; // TODO CASE PublicationLag CHF - Confirm 0
    // CHF Overnight Index
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("TOISTOIS Index"),
                    simpleNameSecurityId("CHF TOISTOIS")),
            "CHF TOISTOIS", act360, following, Period.ofDays(1), 2, false, ch, publicationLagON);
    // OIS
    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("CHF_OIS_SWAP")), "CHF_OIS_SWAP", act360,
            modified, annual, 2, ch, act360, modified, annual, 2, simpleNameSecurityId("CHF TOISTOIS"), ch,
            true, publicationLagON);

    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("CHF_IBOR_INDEX")), "CHF_IBOR_INDEX",
            act360, following, 2, false);
}

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

public DriftSurface(final Surface<Double, Double, Double> surface) {
    Validate.notNull(surface, "surface");
    _surface = surface;
}

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

@Override
public Double interpolate(final Interpolator1DDataBundle data, final Double value) {
    Validate.notNull(value, "value");
    Validate.notNull(data, "data bundle");
    final Double x1 = data.getLowerBoundKey(value);
    final Double y1 = data.get(x1);
    if (data.getLowerBoundIndex(value) == data.size() - 1) {
        return y1;
    }//from  w  w w. j  a  v a  2 s. c  om
    final Double x2 = data.higherKey(x1);
    final Double y2 = data.get(x2);
    final double xDiff = x2 - x1;
    return Math.pow(y1, value * (x2 - value) / xDiff / x1) * Math.pow(y2, value * (value - x1) / xDiff / x2);
}

From source file:de.xaniox.heavyspleef.commands.base.proxy.ProxyExecution.java

public static ProxyExecution inject(CommandManagerService service, String path) {
    CommandContainer container = service.containerOf(path);
    Validate.notNull(container, "Non-existent command path '" + path + "'");

    CommandExecution execution = container.getExecution();
    if (!(execution instanceof ProxyExecution)) {
        execution = decorate(execution);
    }//from w w  w.j  av  a2  s  .  co m

    container.setExecution(execution);
    return (ProxyExecution) execution;
}

From source file:com.opengamma.analytics.math.function.special.DiracDeltaFunction.java

@Override
public Double evaluate(final Double x) {
    Validate.notNull(x, "x");
    return CompareUtils.closeEquals(x, 0, 1e-16) ? Double.POSITIVE_INFINITY : 0;
}

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

/**
 * {@inheritDoc}/*from  w w  w  .  j  a va  2 s  .  com*/
 */
@Override
public SpreadDoublesCurve evaluate(final SpreadDoublesCurve curve, final double shift) {
    Validate.notNull(curve, "curve");
    return evaluate(curve, shift, "PARALLEL_SHIFT_" + curve.getName());
}

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

/**
 * {@inheritDoc}//from  ww w. jav  a  2  s  .co  m
 */
@Override
public ConstantDoublesCurve evaluate(final ConstantDoublesCurve curve, final double shift) {
    Validate.notNull(curve, "curve");
    return evaluate(curve, shift, "PARALLEL_SHIFT_" + curve.getName());
}

From source file:com.opengamma.analytics.financial.model.volatility.local.ImpliedTreeResult.java

public ImpliedTreeResult(final RecombiningTree<Double> spotPrices,
        final RecombiningTree<Double> localVolatilities) {
    Validate.notNull(spotPrices, "spot price tree");
    Validate.notNull(localVolatilities, "local volatility tree");
    if (spotPrices.getDepth() - 1 != localVolatilities.getDepth()) {
        throw new IllegalArgumentException(
                "Spot price tree must have depth equal to the depth of the local volatility tree plus one; have "
                        + spotPrices.getDepth() + " and " + localVolatilities.getDepth());
    }/*from   w  w  w .  j a va2s .c om*/
    _spotPrices = spotPrices;
    _localVolatilities = localVolatilities;
}