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.option.definition.OptionDataBundle.java

public OptionDataBundle(final YieldAndDiscountCurve interestRateCurve,
        final VolatilitySurface volatilitySurface, final ZonedDateTime date) {
    Validate.notNull(date, "date");
    _interestRateCurve = interestRateCurve;
    _volatilitySurface = volatilitySurface;
    _date = date;/*from  w  w  w  .  j av  a2 s .  c  o  m*/
}

From source file:me.st28.flexseries.flexlib.log.LogHelper.java

public static void log(FlexPlugin plugin, String identifier, String suffix, Level level, String message,
        Exception exception) {/*  w  w w. j  av  a2s  .c o m*/
    Validate.notNull(plugin, "Plugin cannot be null.");
    Validate.notNull(level, "Level cannot be null.");
    Validate.notNull(message, "Message cannot be null.");

    StringBuilder prefix = new StringBuilder();

    prefix.append("[");
    prefix.append(plugin.getName());
    if (identifier != null) {
        prefix.append("/").append(identifier);
    }

    if (suffix != null) {
        prefix.append(" ").append(suffix);
    }

    prefix.append("]");

    if (exception == null) {
        Bukkit.getLogger().log(level, prefix.toString() + " " + message);
    } else {
        Bukkit.getLogger().log(level, prefix.toString() + " " + message, exception);
    }
}

From source file:com.opengamma.analytics.financial.riskfactor.GreekToValueGreekConverter.java

@Override
public Map<ValueGreek, Double> evaluate(final GreekDataBundle data) {
    Validate.notNull(data, "data");
    final GreekResultCollection greeks = data.getGreekResults();
    final Map<ValueGreek, Double> riskFactors = new HashMap<ValueGreek, Double>();
    final Map<UnderlyingType, Double> underlyingData = data.getUnderlyingData();
    final OptionTradeData tradeData = data.getOptionTradeData();
    for (final Pair<Greek, Double> entry : greeks) {
        final Greek key = entry.getKey();
        final Double value = entry.getValue();
        riskFactors.put(new ValueGreek(key), getValueGreek(key, value, underlyingData, tradeData));
    }/*w w w.  j  a v  a 2s.com*/
    return riskFactors;
}

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

/**
 * {@inheritDoc}//from   w  ww .j a  v a2  s.  co  m
 */
@Override
public SpreadDoublesCurve evaluate(final SpreadDoublesCurve curve, final double shift, final String newName) {
    Validate.notNull(curve, "curve");
    final int n = curve.getUnderlyingCurves().length;
    final DoublesCurve[] curves = new DoublesCurve[n + 1];
    int i = 0;
    for (final DoublesCurve c : curve.getUnderlyingCurves()) {
        curves[i++] = c;
    }
    curves[n] = ConstantDoublesCurve.from(shift);
    return SpreadDoublesCurve.from(SPREAD_FUNCTION, newName, curves);
}

From source file:com.opengamma.financial.analytics.ircurve.SyntheticIdentifierCurveInstrumentProvider.java

public SyntheticIdentifierCurveInstrumentProvider(final Currency ccy, final StripInstrumentType type,
        final ExternalScheme scheme) {
    Validate.notNull(ccy, "currency");
    Validate.notNull(type, "instrument type");
    Validate.notNull(scheme, "generated identifier scheme");
    _ccy = ccy;/*  w  w w .  ja v  a  2 s.  co  m*/
    _type = type;
    _scheme = scheme;

    switch (type) {
    case SWAP_3M:
    case SWAP_6M:
        _idType = StripInstrumentType.SWAP;
        break;
    case FRA_3M:
    case FRA_6M:
        _idType = StripInstrumentType.FRA;
        break;
    default:
        _idType = type;
        break;
    }
}

From source file:com.edmunds.etm.runtime.api.Application.java

/**
 * Creates an application name from the given maven module.
 *
 * @param mavenModule maven module/* www .j a va2s  .c o m*/
 * @return application name extracted from the maven module
 */
public static String applicationName(MavenModule mavenModule) {
    Validate.notNull(mavenModule, "Maven module is null");
    return mavenModule.getGroupId() + ":" + mavenModule.getArtifactId();
}

From source file:com.opengamma.analytics.math.rootfinding.CubicRealRootFinder.java

@Override
public Double[] getRoots(final RealPolynomialFunction1D function) {
    Validate.notNull(function, "function");
    final double[] coefficients = function.getCoefficients();
    if (coefficients.length != 4) {
        throw new IllegalArgumentException("Function is not a cubic");
    }/*from ww  w . jav  a 2  s.  c  o  m*/
    final ComplexNumber[] result = ROOT_FINDER.getRoots(function);
    final List<Double> reals = new ArrayList<Double>();
    for (final ComplexNumber c : result) {
        if (CompareUtils.closeEquals(c.getImaginary(), 0, 1e-16)) {
            reals.add(c.getReal());
        }
    }
    Validate.isTrue(reals.size() > 0, "Could not find any real roots");
    return reals.toArray(EMPTY_ARRAY);
}

From source file:com.opengamma.analytics.financial.riskfactor.GreekDataBundle.java

public GreekDataBundle(final GreekResultCollection greekValues,
        final Map<UnderlyingType, Double> underlyingData, final OptionTradeData tradeData) {
    Validate.notNull(greekValues, "greek result collection");
    if (greekValues.isEmpty()) {
        throw new IllegalArgumentException("Greek result collection was empty");
    }/*from www  .j ava 2 s  .  c  o m*/
    Validate.notNull(underlyingData, "underlying data");
    Validate.notEmpty(underlyingData, "underlying data");
    Validate.notNull(tradeData, "trade data");
    _greekValues = greekValues;
    _underlyingData = underlyingData;
    _tradeData = tradeData;
}

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

public LocalDate[] getSchedule(final LocalDate startDate, final LocalDate endDate, final boolean fromEnd) {
    Validate.notNull(startDate, "start date");
    Validate.notNull(endDate, "end date");
    final LocalDate[] monthly = EOM_CALCULATOR.getSchedule(startDate, endDate);
    final List<LocalDate> result = new ArrayList<LocalDate>();
    if (fromEnd) {
        for (int i = monthly.length - 1; i >= 0; i -= 12) {
            result.add(monthly[i]);//from w  ww . ja v  a2s .c  o m
        }
        Collections.reverse(result);
        return result.toArray(EMPTY_LOCAL_DATE_ARRAY);
    }
    for (int i = 0; i < monthly.length; i += 12) {
        result.add(monthly[i]);
    }
    return result.toArray(EMPTY_LOCAL_DATE_ARRAY);
}

From source file:com.opengamma.analytics.financial.timeseries.model.MovingAverageTimeSeriesModel.java

public LocalDateDoubleTimeSeries getSeries(final double[] theta, final int q, final LocalDate[] dates) {
    Validate.notNull(theta, "theta");
    if (q < 1) {
        throw new IllegalArgumentException("Order must be greater than zero");
    }//from  w ww. j  a v a 2s . c om
    if (theta.length < q) {
        throw new IllegalArgumentException("Coefficient array must contain at least " + q + " elements");
    }
    Validate.notNull(dates, "dates");
    ArgumentChecker.notEmpty(dates, "dates");
    final int n = dates.length;
    final double[] z = new double[n];
    for (int i = 0; i < n; i++) {
        z[i] = _random.nextRandom();
    }
    final double[] data = new double[n];
    data[0] = theta[0];
    double sum;
    for (int i = 1; i < n; i++) {
        sum = theta[0] + z[i];
        for (int j = 1; j < (i < q ? i : q + 1); j++) {
            sum += z[i - j] * theta[j];
        }
        data[i] = sum;
    }
    return ImmutableLocalDateDoubleTimeSeries.of(dates, data);
}