本文整理了Java中org.broadinstitute.gatk.utils.Utils.nonNull()
方法的一些代码示例,展示了Utils.nonNull()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.nonNull()
方法的具体详情如下:
包路径:org.broadinstitute.gatk.utils.Utils
类名称:Utils
方法名:nonNull
[英]Checks that an Object object is not null and returns the same object or throws an IllegalArgumentException
[中]检查对象是否为null,并返回相同的对象或引发IllegalArgumentException
代码示例来源:origin: broadgsa/gatk
/**
* Checks that an Object {@code object} is not null and returns the same object or throws an {@link IllegalArgumentException}
* @param object any Object
* @return the same object
* @throws IllegalArgumentException if a {@code o == null}
*/
public static <T> T nonNull(final T object) {
return Utils.nonNull(object, "Null object is not allowed here.");
}
代码示例来源:origin: broadgsa/gatk
/**
* Test whether all elements of an int[] array satisfy an int -> boolean predicate
*/
public static boolean allMatch(final int[] array, final IntPredicate pred) {
Utils.nonNull(array, "array may not be null");
Utils.nonNull(pred, "predicate may not be null");
for (final int x : array) {
if (!pred.test(x)) {
return false;
}
}
return true;
}
}
代码示例来源:origin: broadgsa/gatk
/**
* Test whether all elements of a double[] array satisfy a double -> boolean predicate
*/
public static boolean allMatch(final double[] array, final DoublePredicate pred) {
Utils.nonNull(array, "array may not be null");
Utils.nonNull(pred, "predicate may not be null");
for (final double x : array) {
if (!pred.test(x)) {
return false;
}
}
return true;
}
代码示例来源:origin: broadgsa/gatk
/**
* The following method implements Arrays.stream(array).map(func).toArray(), which is concise but performs poorly due
* to the overhead of creating a stream, especially with small arrays. Thus we wrap the wordy but fast array code
* in the following method which permits concise Java 8 code.
*
* The original array is modified in place.
*
* This method has been benchmarked and performs as well as array-only code.
*/
public static double[] applyToArrayInPlace(final double[] array, final DoubleUnaryOperator func) {
Utils.nonNull(array, "array may not be null");
Utils.nonNull(func, "function may not be null");
for (int m = 0; m < array.length; m++) {
array[m] = func.applyAsDouble(array[m]);
}
return array;
}
代码示例来源:origin: broadgsa/gatk
/**
* The following method implements Arrays.stream(array).map(func).toArray(), which is concise but performs poorly due
* to the overhead of creating a stream, especially with small arrays. Thus we wrap the wordy but fast array code
* in the following method which permits concise Java 8 code.
*
* Returns a new array -- the original array in not modified.
*
* This method has been benchmarked and performs as well as array-only code.
*/
public static double[] applyToArray(final double[] array, final DoubleUnaryOperator func) {
Utils.nonNull(func, "function may not be null");
Utils.nonNull(array, "array may not be null");
final double[] result = new double[array.length];
for (int m = 0; m < result.length; m++) {
result[m] = func.applyAsDouble(array[m]);
}
return result;
}
代码示例来源:origin: broadgsa/gatk-protected
/**
* Sums the values of an int -> double function applied to this range
*
* @param lambda the int -> double function
*/
public double sum(final IntToDoubleFunction lambda) {
Utils.nonNull(lambda, "the lambda function cannot be null");
double result = 0;
for (int i = from; i < to; i++) {
result += lambda.applyAsDouble(i);
}
return result;
}
代码示例来源:origin: broadgsa/gatk-protected
/**
* Iterate through all indexes in the range in ascending order to be processed by the
* provided {@link IntConsumer integer consumer} lambda function.
*
* <p>
* Exceptions thrown by the execution of the index consumer {@code lambda}
* will be propagated to the caller immediately thus stopping early and preventing
* further indexes to be processed.
* </p>
* @param lambda the index consumer lambda.
* @throws IllegalArgumentException if {@code lambda} is {@code null}.
* @throws RuntimeException if thrown by {@code lambda} for some index.
* @throws Error if thrown by {@code lambda} for some index.
*/
public void forEach(final IntConsumer lambda) {
Utils.nonNull(lambda, "the lambda function cannot be null");
for (int i = from; i < to; i++) {
lambda.accept(i);
}
}
代码示例来源:origin: broadgsa/gatk-protected
/**
* Find the elements of this range for which an int -> boolean predicate is true
*
* @param predicate the int -> boolean predicate
* @return
*/
public List<Integer> filter(final IntPredicate predicate) {
Utils.nonNull(predicate, "predicate may not be null");
final List<Integer> result = new ArrayList<>();
forEach(i -> {if (predicate.test(i)) result.add(i); } );
return result;
}
代码示例来源:origin: broadgsa/gatk-protected
/**
* Apply an int -> double function to this range, producing a double[]
*
* @param lambda the int -> double function
*/
public double[] mapToDouble(final IntToDoubleFunction lambda) {
Utils.nonNull(lambda, "the lambda function cannot be null");
final double[] result = new double[size()];
for (int i = from; i < to; i++) {
result[i - from] = lambda.applyAsDouble(i);
}
return result;
}
代码示例来源:origin: broadgsa/gatk-protected
/**
* Apply an int -> int function to this range, producing an int[]
*
* @param lambda the int -> int function
*/
public int[] mapToInteger(final IntUnaryOperator lambda) {
Utils.nonNull(lambda, "the lambda function cannot be null");
final int[] result = new int[size()];
for (int i = from; i < to; i++) {
result[i - from] = lambda.applyAsInt(i);
}
return result;
}
代码示例来源:origin: broadgsa/gatk-protected
public Dirichlet(final double... alpha) {
Utils.nonNull(alpha);
Utils.validateArg(alpha.length >= 1, "Dirichlet parameters must have at least one element");
Utils.validateArg(MathUtils.allMatch(alpha, x -> x >= 0), "Dirichlet parameters may not be negative");
Utils.validateArg(MathUtils.allMatch(alpha, Double::isFinite), "Dirichlet parameters must be finite");
this.alpha = alpha.clone();
}
代码示例来源:origin: broadgsa/gatk-protected
Utils.nonNull(vc, "vc is null");
final int numAlleles = vc.getNAlleles();
final List<Allele> alleles = vc.getAlleles();
内容来源于网络,如有侵权,请联系作者删除!