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) 

Source Link

Document

Validate an argument, throwing IllegalArgumentException if the argument is null.

 Validate.notNull(myObject); 

The message in the exception is 'The validated object is null'.

Usage

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

/**
 * Convenience method for sublisting a string array into another string array object.
 *
 * @param array The original array.//from  ww  w.  j  a v  a 2s  .  c  om
 * @param startIndex The beginning index to include.
 * @param endIndex The ending index to include.
 * @return The new string array.
 */
public static String[] stringArraySublist(String[] array, int startIndex, int endIndex) {
    Validate.notNull(array);

    List<String> tempList = Arrays.asList(array).subList(startIndex, endIndex);
    return tempList.toArray(new String[tempList.size()]);
}

From source file:com.opengamma.maths.lowlevelapi.functions.iss.IsNaN.java

/**
 * Walks through a vector looking for NaN's if one is found the routine returns TRUE. 
 * @param v the vector (with possible NaN entries)
 * @return a boolean, TRUE if a NaN is found in v, FALSE otherwise
 *//*  w ww.  jav a  2 s .  co m*/
public static boolean any(float[] v) {
    Validate.notNull(v);
    boolean logical = false;
    final int len = v.length;
    for (int i = 0; i < len; i++) {
        if (v[i] != v[i]) {
            logical = true;
            return logical;
        }
    }
    return logical;
}

From source file:com.opengamma.analytics.math.linearalgebra.LUDecompositionCommons.java

/**
 * {@inheritDoc}/*from w w  w.j  av a  2  s . c  o m*/
 */
@Override
public LUDecompositionResult evaluate(final DoubleMatrix2D x) {
    Validate.notNull(x);
    final RealMatrix temp = CommonsMathWrapper.wrap(x);
    final LUDecomposition lu = new LUDecompositionImpl(temp);
    return new LUDecompositionCommonsResult(lu);
}

From source file:com.opengamma.analytics.math.linearalgebra.QRDecompositionCommons.java

/**
 * {@inheritDoc}//from   w  w  w .j  ava 2  s  .  com
 */
@Override
public QRDecompositionResult evaluate(final DoubleMatrix2D x) {
    Validate.notNull(x);
    final RealMatrix temp = CommonsMathWrapper.wrap(x);
    final QRDecomposition qr = new QRDecompositionImpl(temp);
    return new QRDecompositionCommonsResult(qr);
}

From source file:com.opengamma.analytics.math.statistics.descriptive.MedianCalculator.java

/**
 * @param x The array of data, not null or empty
 * @return The median/*from  w  ww. j a v  a2  s  .  c om*/
 */
@Override
public Double evaluate(final double[] x) {
    Validate.notNull(x);
    Validate.isTrue(x.length > 0, "x cannot be empty");
    if (x.length == 1) {
        return x[0];
    }
    final double[] x1 = Arrays.copyOf(x, x.length);
    Arrays.sort(x1);
    final int mid = x1.length / 2;
    if (x1.length % 2 == 1) {
        return x1[mid];
    }
    return (x1[mid] + x1[mid - 1]) / 2.;
}

From source file:com.opengamma.analytics.financial.model.interestrate.definition.StandardDiscountBondModelDataBundle.java

public StandardDiscountBondModelDataBundle(final YieldAndDiscountCurve shortRateCurve,
        final VolatilityCurve shortRateVolatilityCurve, final ZonedDateTime date) {
    Validate.notNull(shortRateCurve);
    Validate.notNull(shortRateVolatilityCurve);
    Validate.notNull(date);//from   w ww  .  j  av a 2 s  .  c o  m
    _shortRateCurve = shortRateCurve;
    _shortRateVolatilityCurve = shortRateVolatilityCurve;
    _date = date;
}

From source file:com.opengamma.analytics.math.util.wrapper.CommonsMathWrapper.java

/**
 * @param f An OG 1-D function mapping doubles onto doubles, not null 
 * @return A Commons univariate real function
 *//* w ww . j  av a2 s . c  o  m*/
public static UnivariateRealFunction wrapUnivariate(final Function1D<Double, Double> f) {
    Validate.notNull(f);
    return new UnivariateRealFunction() {

        @Override
        public double value(final double x) {
            return f.evaluate(x);
        }
    };
}

From source file:com.evolveum.midpoint.schema.xjc.schema.FieldBox.java

public FieldBox(String fieldName, T value) {
    Validate.notEmpty(fieldName, "Field name must not be null or empty.");
    Validate.notNull("QName must not be null.");

    this.fieldName = fieldName;
    this.value = value;
}

From source file:com.prowidesoftware.swift.model.field.AmountResolver.java

/**
 * get the amount of the given field by reading it's components pattern.
 * The first index of 'N', number, is returned as amount.
 * <em>See the returns notes</em>
 *
 * @param f the field where to extract the amount, must not be null
 *
 * @return a BigDecimal with the number found in the first numeric component or <code>null</code> if there is 
 *    no numeric component in the field. It may also return null if Field.getComponent(index,Number.class) fails
 *    for that component//ww  w  .j  a  v a2  s.  c o  m
 * @see Field#getComponentAs(int, Class)
 * @since 7.8
 */
public static BigDecimal amount(final Field f) {
    Validate.notNull(f);
    final int i = StringUtils.indexOf(f.componentsPattern(), 'N');
    if (i >= 0) {
        final Number n = (Number) f.getComponentAs(i + 1, Number.class);
        if (n == null) {
            log.warning("getComponentAs(" + (i + 1) + ", Number.class) returned null for field " + f);
            return null;
        }
        return new BigDecimal(n.toString());
    }
    return null;
}

From source file:com.opengamma.analytics.math.linearalgebra.SVDecompositionCommons.java

/**
 * {@inheritDoc}/*from  w w  w  . j  a  va  2s  .c o m*/
 */
@Override
public SVDecompositionResult evaluate(final DoubleMatrix2D x) {
    Validate.notNull(x);
    MatrixValidate.notNaNOrInfinite(x);
    final RealMatrix commonsMatrix = CommonsMathWrapper.wrap(x);
    final SingularValueDecomposition svd = new SingularValueDecompositionImpl(commonsMatrix);
    return new SVDecompositionCommonsResult(svd);
}