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.minimization.MinimumBracketer.java

protected void checkInputs(final Function1D<Double, Double> f, final double xLower, final double xUpper) {
    Validate.notNull(f, "function");
    if (CompareUtils.closeEquals(xLower, xUpper, ZERO)) {
        throw new IllegalArgumentException("Lower and upper values were not distinct");
    }/*from   ww  w .j  ava2s. c om*/
}

From source file:me.st28.flexseries.flexcore.util.PlayerUtils.java

/**
 * @return the name for the given UUID./*from w  ww .  j a  v a 2 s . co m*/
 */
public static String getName(UUID uuid) {
    Validate.notNull(uuid, "UUID cannot be null.");
    return new PlayerProfile(uuid).getName();
}

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

public BasisFunctionAggregation(List<Function1D<T, Double>> functions, double[] weights) {
    Validate.notEmpty(functions, "no functions");
    Validate.notNull(weights, "no weights");
    Validate.isTrue(functions.size() == weights.length);
    _f = functions;/* w ww . j  a va2s .  co m*/
    _w = weights;
}

From source file:com.bibisco.manager.RichTextEditorSettingsManager.java

public static void save(RichTextEditorSettings pRichTextEditorSettings) {

    mLog.debug("Start save()");

    Validate.notNull(pRichTextEditorSettings, "RichTextEditorSettings cannot be null");
    Validate.notEmpty(pRichTextEditorSettings.getFont(), "RichTextEditorSettings.font cannot be empty");
    Validate.notEmpty(pRichTextEditorSettings.getSize(), "RichTextEditorSettings.size cannot be empty");
    Validate.isTrue(/*from   w w w .  j  a  va  2s .  co m*/
            pRichTextEditorSettings.getFont().equals("courier")
                    || pRichTextEditorSettings.getFont().equals("times")
                    || pRichTextEditorSettings.getFont().equals("arial"),
            "RichTextEditorSettings.size can be courier, times, arial");
    Validate.isTrue(
            pRichTextEditorSettings.getSize().equals("small")
                    || pRichTextEditorSettings.getSize().equals("medium")
                    || pRichTextEditorSettings.getSize().equals("big"),
            "RichTextEditorSettings.size can be small, medium, big");

    Map<String, String> lMapProperties = new HashMap<String, String>();
    lMapProperties.put("font", pRichTextEditorSettings.getFont());
    lMapProperties.put("font-size", pRichTextEditorSettings.getSize());
    lMapProperties.put("spellCheckEnabled", String.valueOf(pRichTextEditorSettings.isSpellCheckEnabled()));
    PropertiesManager.getInstance().updateProperties(lMapProperties);

    mLog.debug("End save()");
}

From source file:com.training.utils.EmbeddedDataSourceFactory.java

public static JdbcDataSource getJdbcDataSource(String initScriptLocation) {
    Validate.notEmpty(initScriptLocation, "initScriptLocation is empty");

    String mavenRelativePath = "src/main/resources/" + initScriptLocation;
    String mavenRootRelativePath = "camel-cookbook-transactions/" + mavenRelativePath;

    // check that we can load the init script
    FileLocator locator = new FileLocator().with(initScriptLocation).with(mavenRelativePath)
            .with(mavenRootRelativePath);
    File file = locator.find();//w ww.j  a va2s.  com
    Validate.notNull(file, locator.getErrorMessage());
    FileSystemResource script = new FileSystemResource(file);

    JdbcDataSource dataSource = new JdbcDataSource();
    dataSource.setURL("jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1");
    dataSource.setUser("sa");
    dataSource.setPassword("");

    DataSourceInitializer.initializeDataSource(dataSource, script);

    return dataSource;
}

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

/**
 * {@inheritDoc}/*from  ww w. ja va2 s .  c om*/
 */
@Override
public FunctionalDoublesSurface evaluate(final FunctionalDoublesSurface surface, final double percentage) {
    Validate.notNull(surface, "surface");
    return evaluate(surface, percentage, "CONSTANT_MULTIPLIER_" + surface.getName());
}

From source file:com.opengamma.analytics.financial.model.option.pricing.analytic.formula.BlackFunctionData.java

public static BlackFunctionData fromDataBundle(final BlackOptionDataBundle bundle,
        final EuropeanVanillaOptionDefinition definition) {
    Validate.notNull(bundle, "bundle");
    Validate.notNull(definition, "definition");
    final double t = definition.getTimeToExpiry(bundle.getDate());
    final double k = definition.getStrike();
    return new BlackFunctionData(bundle.getForward(), bundle.getDiscountFactor(t), bundle.getVolatility(t, k));
}

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

public SimpleFutureDataBundle(final YieldAndDiscountCurve yieldCurve, final double spot,
        final double costOfCarry) {
    Validate.notNull(yieldCurve, "yield curve");
    _yieldCurve = yieldCurve;//from   www  .j  a  v  a2s  .  c  o m
    _spot = spot;
    _costOfCarry = costOfCarry;
}

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

public AutoregressiveTimeSeriesModel(final ProbabilityDistribution<Double> random) {
    Validate.notNull(random, "random");
    _random = random;
}

From source file:com.opengamma.analytics.financial.schedule.AnnualScheduleCalculator.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.  j a va  2 s .  c o  m*/
    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.ofYears(1)) : endDate.minus(Period.ofYears(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.ofYears(1)) : startDate.plus(Period.ofYears(i++));
    }
    return dates.toArray(EMPTY_LOCAL_DATE_ARRAY);
}