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:com.opengamma.analytics.math.utilities.Diff.java

/**
 * Finds the numerical difference between value at position (i+1) and (i)
 * returning a vector of what would be needed to be added to the first (n-1) elements of the original vector to get the original vector. 
 * @param v the vector// w  w w. j av  a 2s  .c o  m
 * @return the numerical difference between adjacent elements in v
 */
public static double[] values(final double[] v) {
    Validate.notNull(v);
    final int n = v.length - 1;
    double[] tmp = new double[n];
    for (int i = 0; i < n; i++) {
        tmp[i] = v[i + 1] - v[i];
    }
    return tmp;
}

From source file:com.vmware.identity.util.ExtractionUtil.java

public static final String extractDomainNameFromTokenSpec(SamlTokenSpec spec) {
    Validate.notNull(spec);

    return spec.getAuthenticationData().getPrincipalId().getDomain();
}

From source file:com.opengamma.maths.lowlevelapi.functions.utilities.Abs.java

public static float[] stateless(float[] v) {
    Validate.notNull(v);
    final int n = v.length;
    float[] tmp = new float[n];
    for (int i = 0; i < n; i++) {
        tmp[i] = Math.abs(v[i]);//from www . j  a  va2s .c  o m
    }
    return tmp;
}

From source file:com.opengamma.maths.lowlevelapi.functions.utilities.Reverse.java

/**
 * Reverses a vector in place/*from  ww  w .ja  va 2 s.co m*/
 * @param v1 the vector to be reversed
 */
public static void inPlace(long[] v1) {
    Validate.notNull(v1);
    long tmp;
    final int half = v1.length / 2;
    final int len = v1.length - 1;
    for (int i = 0; i < half; i++) {
        tmp = v1[len - i];
        v1[len - i] = v1[i];
        v1[i] = tmp;
    }
}

From source file:com.opengamma.maths.lowlevelapi.functions.utilities.Unique.java

/**
 * Uniques the data, duplicates are removed based on bitwise comparison of data.
 * @param data int[] the data to unique//from  w w  w . ja va 2  s  .  c  o m
 * @return the int[] uniqued data
 */
public static int[] bitwise(int[] data) {
    Validate.notNull(data);
    int n = data.length;
    int[] sorteddata = Sort.stateless(data);
    int j = 0;
    for (int i = 1; i < n; i++) {
        if (sorteddata[i] != sorteddata[j]) {
            j++;
            sorteddata[j] = sorteddata[i];
        }
    }
    return Arrays.copyOf(sorteddata, j + 1);
}

From source file:com.opengamma.maths.lowlevelapi.functions.utilities.Max.java

/**
 * Returns the index of the maximum value in data
 * @param data the data to search/*w ww  .  j a v  a2 s .  co  m*/
 * @return idx, the index of the maximum value in the data
 */
public static int index(int... data) {
    Validate.notNull(data);
    int max = 0x80000000;
    int idx = -1;
    final int n = data.length;
    for (int i = 0; i < n; i++) {
        if (data[i] > max) {
            max = data[i];
            idx = i;
        }
    }
    return idx;
}

From source file:com.opengamma.maths.lowlevelapi.functions.utilities.Min.java

/**
 * Returns the index of the minimum value in data
 * @param data the data to search// ww  w. j a v a2 s .c  o m
 * @return idx, the index of the minimum value in the data
 */
public static int index(int... data) {
    Validate.notNull(data);
    int min = 0x7fffffff;
    int idx = -1;
    final int n = data.length;
    for (int i = 0; i < n; i++) {
        if (data[i] < min) {
            min = data[i];
            idx = i;
        }
    }
    return idx;
}

From source file:com.opengamma.maths.lowlevelapi.functions.utilities.Negate.java

/**
 * Negates the boolean values in a vector, this is done in place, memory will be changed!
 * @param v a vector of booleans//from  w w w  . j  a  v a 2 s . c om
 */
public static void inPlace(boolean[] v) {
    Validate.notNull(v);
    final int len = v.length;
    for (int i = 0; i < len; i++) {
        if (v[i] == true) {
            v[i] = false;
        } else {
            v[i] = true;
        }
    }
}

From source file:com.vmware.identity.util.ExtractionUtil.java

public static final String extractDomainNameFromSamlToken(ServerValidatableSamlToken token) {
    Validate.notNull(token);

    return ((token.getSubject().subjectUpn() != null) ? token.getSubject().subjectUpn().getDomain() : "");
}

From source file:com.vmware.identity.authz.RoleCheckFactory.java

public static <R extends Enum<R>> RoleCheck<R> createRoleCheck(Map<PrincipalId, R> groupKeyRoleValue,
        PrincipalDiscovery pd) {// w w  w.j  a  v  a  2  s.  co m

    Validate.notEmpty(groupKeyRoleValue);
    Validate.notNull(pd);

    return new RoleCheckBase<R>(groupKeyRoleValue, pd);
}