55
66import java .util .Random ;
77
8- import static fj .data .Option .none ;
98import static fj .data .Option .some ;
109import static java .lang .Math .max ;
1110import static java .lang .Math .min ;
1817public final class Rand {
1918 private final F <Option <Long >, F <Integer , F <Integer , Integer >>> f ;
2019 private final F <Option <Long >, F <Double , F <Double , Double >>> g ;
21-
22- // TODO Change to F<Long,Rand> when rand(f,g) is removed
23- private final Option <F <Long , Rand >> optOnReseed ;
20+ private final F <Long , Rand > onReseed ;
2421
2522 private Rand (
2623 F <Option <Long >, F <Integer , F <Integer , Integer >>> f ,
2724 F <Option <Long >, F <Double , F <Double , Double >>> g ,
28- Option < F <Long , Rand >> optOnReseed ) {
25+ F <Long , Rand > onReseed ) {
2926
3027 this .f = f ;
3128 this .g = g ;
32- this .optOnReseed = optOnReseed ;
29+ this .onReseed = onReseed ;
3330 }
3431
3532 /**
@@ -88,33 +85,7 @@ public double choose(final double from, final double to) {
8885 * @return A random generator with the given seed.
8986 */
9087 public Rand reseed (long seed ) {
91- return optOnReseed .<Rand >option (
92- () -> {
93- throw new IllegalStateException ("reseed() called on a Rand created with deprecated rand() method" );
94- },
95- onReseed -> onReseed .f (seed ));
96- }
97-
98- /**
99- * Constructs a random generator from the given functions that supply a range to produce a
100- * result.
101- * <p>
102- * Calling {@link #reseed(long)} on an instance returned from this method will
103- * result in an exception being thrown.
104- *
105- * @deprecated As of release 4.6, use {@link #rand(F, F, F)}.
106- *
107- * @param f The integer random generator.
108- * @param g The floating-point random generator.
109- * @return A random generator from the given functions that supply a range to produce a result.
110- */
111- // TODO Change Option<F<Long,Rand>> optOnReseed to F<Long,Road> onReseed when removing this method
112- @ Deprecated
113- public static Rand rand (
114- F <Option <Long >, F <Integer , F <Integer , Integer >>> f ,
115- F <Option <Long >, F <Double , F <Double , Double >>> g ) {
116-
117- return new Rand (f , g , none ());
88+ return onReseed .f (seed );
11889 }
11990
12091 /**
@@ -131,7 +102,7 @@ public static Rand rand(
131102 F <Option <Long >, F <Double , F <Double , Double >>> g ,
132103 F <Long , Rand > onReseed ) {
133104
134- return new Rand (f , g , some ( onReseed ) );
105+ return new Rand (f , g , onReseed );
135106 }
136107
137108 /**
0 commit comments