You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2015/12/28 18:23:21 UTC

[09/18] [math] MATH-1309

MATH-1309

Not calling public "setSeed" from a constructor.


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/581b474f
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/581b474f
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/581b474f

Branch: refs/heads/master
Commit: 581b474f4b194731eb9cb22cdde7330a1ec81c3b
Parents: e34f50d
Author: Gilles <er...@apache.org>
Authored: Mon Dec 28 17:05:13 2015 +0100
Committer: Gilles <er...@apache.org>
Committed: Mon Dec 28 17:32:34 2015 +0100

----------------------------------------------------------------------
 .../commons/math4/random/AbstractWell.java      | 34 ++++++++++++++------
 1 file changed, 25 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/581b474f/src/main/java/org/apache/commons/math4/random/AbstractWell.java
----------------------------------------------------------------------
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 b2d61a3..88cb2bb 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) });
     }
 
     /**