Example usage for org.apache.commons.lang Validate isTrue

List of usage examples for org.apache.commons.lang Validate isTrue

Introduction

In this page you can find the example usage for org.apache.commons.lang Validate isTrue.

Prototype

public static void isTrue(boolean expression, String message) 

Source Link

Document

Validate an argument, throwing IllegalArgumentException if the test result is false.

This is used when validating according to an arbitrary boolean expression, such as validating a primitive number or using your own custom validation expression.

 Validate.isTrue( (i > 0), "The value must be greater than zero"); Validate.isTrue( myObject.isOk(), "The object is not OK"); 

For performance reasons, the message string should not involve a string append, instead use the #isTrue(boolean,String,Object) method.

Usage

From source file:com.opengamma.analytics.financial.model.option.pricing.fourier.GaussianCharacteristicExponent.java

@Override
public ComplexNumber getValue(ComplexNumber u, double t) {
    Validate.isTrue(t > 0.0, "t > 0");
    Validate.notNull(u, "u");
    final ComplexNumber temp = multiply(_sigma, u);
    final ComplexNumber res = add(multiply(u, new ComplexNumber(0, _mu)), multiply(-0.5, multiply(temp, temp)));
    return multiply(t, res);
}

From source file:com.opengamma.analytics.financial.interestrate.inflation.method.CouponInflationZeroCouponMonthlyDiscountingMethod.java

@Override
public CurrencyAmount presentValue(InstrumentDerivative instrument, MarketBundle market) {
    Validate.isTrue(instrument instanceof CouponInflationZeroCouponMonthly,
            "Zero-coupon inflation with start of month reference date.");
    return presentValue((CouponInflationZeroCouponMonthly) instrument, market);
}

From source file:com.opengamma.financial.analytics.LabelledMatrix1D.java

public LabelledMatrix1D(final S[] keys, final Object[] labels, final String labelsTitle, final double[] values,
        final String valuesTitle, final T defaultTolerance) {
    Validate.notNull(keys, "labels");
    Validate.notNull(labels, "label names");
    Validate.notNull(values, "values");
    final int n = keys.length;
    Validate.isTrue(n == labels.length, "length of keys array must match length of label names array");
    Validate.isTrue(n == values.length, "length of keys array must match length of values array");
    _keys = Arrays.copyOf(keys, n);
    _labels = Arrays.copyOf(labels, n);
    _labelsTitle = labelsTitle;/*from  w  w w .j av  a 2 s  .c  o m*/
    _values = Arrays.copyOf(values, n);
    _valuesTitle = valuesTitle;
    _defaultTolerance = defaultTolerance;
    quickSort();
}

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

/**
 * @param x x/*from   w  w w .j av a 2s.  com*/
 * @return the value of the function
 * @throws IllegalArgumentException If $x < 0$ or $x > 1$
 */
@Override
public Double evaluate(final Double x) {
    Validate.isTrue(x >= 0 && x <= 1, "x must be in the range 0 to 1");
    try {
        return Beta.regularizedBeta(x, _a, _b, _eps, _maxIter);
    } catch (final org.apache.commons.math.MathException e) {
        throw new MathException(e);
    }
}

From source file:com.relicum.ipsum.Signs.SignFormat.java

/**
 * Validate line.//from  w w  w .j  a  v  a  2  s.  c  o  m
 *
 * @param line the line to validate
 * @return the string validated
 */
private boolean validateLine(String line) {
    line = ChatColor.translateAlternateColorCodes('&', line);
    Validate.isTrue(line.length() < 16, "The length of a sign line must be below 16 characters");
    return true;

}

From source file:com.opengamma.analytics.financial.model.option.pricing.fourier.CGMYCharacteristicExponent.java

/**
 * The parameters for the CGMY process/*www  .  j a va  2 s  . c om*/
 * @param c C, > 0
 * @param g G, > 0
 * @param m M, > 1
 * @param y Y, < 2
 */
public CGMYCharacteristicExponent(final double c, final double g, final double m, final double y) {
    Validate.isTrue(c > 0, "C > 0");
    Validate.isTrue(g > 0, "G > 0");
    Validate.isTrue(m > 1, "M > 1");
    Validate.isTrue(y < 2, "Y < 2");
    _c = c;
    _g = g;
    _m = m;
    _y = y;
    _minAlpha = -(_g + 1.0);
    _maxAlpha = _m - 1.0;
    _r1 = Math.pow(_m, _y) + Math.pow(_g, _y);
    _r2 = _c * GAMMA_FUNCTION.evaluate(-_y);
    _r3 = (Math.pow(_m - 1, _y) + Math.pow(_g + 1, _y) - _r1);
}

From source file:de.xaniox.heavyspleef.core.event.GlobalEventBus.java

@Override
public void unregister(SpleefListener listener) {
    Validate.isTrue(globalListeners.contains(listener), "Global listener has not been registered");

    globalListeners.remove(listener);//from w  ww.j a va  2 s.  c o  m
    for (EventBus bus : singleInstanceBusMap) {
        bus.unregister(listener);
    }
}

From source file:com.opengamma.analytics.financial.interestrate.inflation.method.CouponInflationZeroCouponInterpolationGearingDiscountingMethod.java

@Override
public CurrencyAmount presentValue(InstrumentDerivative instrument, MarketBundle market) {
    Validate.isTrue(instrument instanceof CouponInflationZeroCouponInterpolationGearing,
            "Zero-coupon inflation with start of month reference date.");
    return presentValue((CouponInflationZeroCouponInterpolationGearing) instrument, market);
}

From source file:fr.xebia.demo.objectgrid.ObjectGridUtils.java

public static void checkJvmPreRequisitesForObjectGrid() {
    float javaVersion = Float.parseFloat(System.getProperty("java.specification.version").substring(0, 3));
    String jvmVendor = System.getProperty("java.vm.vendor");

    Validate.isTrue(jvmVendor.indexOf("IBM") > -1,
            "JVM must be an IBM 5+ JVM, vendor " + jvmVendor + " is not supported");
    Validate.isTrue(javaVersion >= 1.5f,
            "JVM must be an IBM 5+ JVM, version " + javaVersion + " is not supported");
}

From source file:com.mxhero.plugin.cloudstorage.onedrive.api.command.RefreshDaemonCommand.java

/**
 * Instantiates a new command.//from   ww w . ja  va 2s .  co  m
 *
 * @param clientBuilder the client builder
 * @param application the application
 * @param credential the credential
 */
public RefreshDaemonCommand(HttpClientBuilder clientBuilder, Application application, Credential credential) {
    super(clientBuilder, application, credential);
    Validate.isTrue(credential instanceof DaemonCredential, "credential must be of type DaemonCredential");
}