This is an automated email from the ASF dual-hosted git repository. erans pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-math.git
The following commit(s) were added to refs/heads/master by this push: new a0cd950 Simplify null checks. a0cd950 is described below commit a0cd950a7caebd2e7e0a271ef235c5dd880c8c0f Author: Gilles Sadowski <gillese...@gmail.com> AuthorDate: Sat Aug 14 16:18:36 2021 +0200 Simplify null checks. --- .../optim/nonlinear/scalar/noderiv/SimplexOptimizer.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/SimplexOptimizer.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/SimplexOptimizer.java index 0d310b9..0373ae4 100644 --- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/SimplexOptimizer.java +++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/SimplexOptimizer.java @@ -21,6 +21,7 @@ import java.util.List; import java.util.ArrayList; import java.util.Comparator; import java.util.Collections; +import java.util.Objects; import java.util.function.UnaryOperator; import java.util.function.IntSupplier; import java.util.concurrent.CopyOnWriteArrayList; @@ -159,9 +160,7 @@ public class SimplexOptimizer extends MultivariateOptimizer { * @param cb Callback. */ public void addObserver(Observer cb) { - if (cb == null) { - throw new NullPointerException("Callback"); - } + Objects.requireNonNull(cb, "Callback"); callbacks.add(cb); } @@ -338,12 +337,9 @@ public class SimplexOptimizer extends MultivariateOptimizer { * was passed to the {@link #optimize(OptimizationData[]) optimize} method. */ private void checkParameters() { - if (updateRule == null) { - throw new NullPointerException("No update rule"); - } - if (initialSimplex == null) { - throw new NullPointerException("No initial simplex"); - } + Objects.requireNonNull(updateRule, "Update rule"); + Objects.requireNonNull(initialSimplex, "Initial simplex"); + if (getLowerBound() != null || getUpperBound() != null) { throw new MathUnsupportedOperationException(LocalizedFormats.CONSTRAINT);