Hello Sébastien.
> /**
> @@ -66,22 +72,16 @@ public class Incrementor {
> * counter exhaustion.
> *
> * @param max Maximal count.
> - * @param cb Function to be called when the maximal count has been
> reached
> - * (can be {@code null}).
> + * @param cb Function to be called when the maximal count has been
> reached.
> + * @throws NullPointerException if {@code cb} is {@code null}
^^^^^^^^^^^^^^^^^^^^
> */
> public Incrementor(int max,
> MaxCountExceededCallback cb) {
> - maximalCount = max;
> - if (cb != null) {
> - maxCountCallback = cb;
> - } else {
> - maxCountCallback = new MaxCountExceededCallback() {
> - /** {@inheritDoc} */
> - public void trigger(int max) {
> - throw new MaxCountExceededException(max);
> - }
> - };
> + if (cb == null){
> + throw new NullPointerException();
See comment in class "o.a.c.m.NullArgumentException".
> }
> + maximalCount = max;
> + maxCountCallback = cb;
> }
>
> /**
>
> Modified:
> commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/IterationManager.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/IterationManager.java?rev=1353386&r1=1353385&r2=1353386&view=diff
> ==============================================================================
> ---
> commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/IterationManager.java
> (original)
> +++
> commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/IterationManager.java
> Mon Jun 25 05:22:58 2012
> @@ -43,7 +43,8 @@ public class IterationManager {
> * @param maxIterations the maximum number of iterations
> */
> public IterationManager(final int maxIterations) {
> - this(maxIterations, null);
> + this.iterations = new Incrementor(maxIterations);
> + this.listeners = new CopyOnWriteArrayList<IterationListener>();
> }
>
> /**
> @@ -51,10 +52,14 @@ public class IterationManager {
> *
> * @param maxIterations the maximum number of iterations
> * @param callBack the function to be called when the maximum number of
> - * iterations has been reached (can be {@code null})
> + * iterations has been reached
> + * @throws NullPointerException if {@code callBack} is {@code null}
^^^^^^^^^^^^^^^^^^^^
> */
> public IterationManager(final int maxIterations,
> final Incrementor.MaxCountExceededCallback
> callBack) {
> + if (callBack == null) {
> + throw new NullPointerException();
Ditto.
> + }
> this.iterations = new Incrementor(maxIterations, callBack);
> this.listeners = new CopyOnWriteArrayList<IterationListener>();
> }
>
Best,
Gilles
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]