From 581b474f4b194731eb9cb22cdde7330a1ec81c3b Mon Sep 17 00:00:00 2001 From: Gilles Date: Mon, 28 Dec 2015 17:05:13 +0100 Subject: [PATCH] MATH-1309 Not calling public "setSeed" from a constructor. --- .../commons/math4/random/AbstractWell.java | 34 ++++++++++++++----- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/apache/commons/math4/random/AbstractWell.java b/src/main/java/org/apache/commons/math4/random/AbstractWell.java index b2d61a389..88cb2bbee 100644 --- a/src/main/java/org/apache/commons/math4/random/AbstractWell.java +++ b/src/main/java/org/apache/commons/math4/random/AbstractWell.java @@ -79,7 +79,7 @@ public abstract class AbstractWell index = 0; // Initialize the pool content. - setSeed(seed); + setSeedInternal(seed); } /** @@ -92,6 +92,25 @@ public abstract class AbstractWell this(k, new int[] { (int) (seed >>> 32), (int) (seed & 0xffffffffl) }); } + + /** {@inheritDoc} */ + @Override + public void setSeed(int seed) { + setSeedInternal(seed); + } + + /** {@inheritDoc} */ + @Override + public void setSeed(int[] seed) { + setSeedInternal(seed); + } + + /** {@inheritDoc} */ + @Override + public void setSeed(long seed) { + setSeedInternal(seed); + } + /** * Reinitialize the generator as if just built with the given int seed. * @@ -100,9 +119,8 @@ public abstract class AbstractWell * * @param seed Seed (32 bits integer). */ - @Override - public void setSeed(final int seed) { - setSeed(new int[] { seed }); + private void setSeedInternal(final int seed) { + setSeedInternal(new int[] { seed }); } /** @@ -114,8 +132,7 @@ public abstract class AbstractWell * @param seed Seed (32 bits integers array). If null the seed of the generator * will be the system time plus the system identity hash code of the instance. */ - @Override - public void setSeed(final int[] seed) { + private void setSeedInternal(final int[] seed) { if (seed == null) { setSeed(System.currentTimeMillis() + System.identityHashCode(this)); return; @@ -142,9 +159,8 @@ public abstract class AbstractWell * * @param seed Seed (64 bits integer). */ - @Override - public void setSeed(final long seed) { - setSeed(new int[] { (int) (seed >>> 32), (int) (seed & 0xffffffffl) }); + private void setSeedInternal(final long seed) { + setSeedInternal(new int[] { (int) (seed >>> 32), (int) (seed & 0xffffffffl) }); } /**