Fix checkstyle

This commit is contained in:
Trustin Lee 2013-07-07 12:29:11 +09:00
parent 70df5a6f63
commit ff97d1db29

View File

@ -45,8 +45,8 @@ import java.util.Random;
* <p>This class also provides additional commonly used bounded random
* generation methods.
*
* @since 1.7
* @author Doug Lea
* //@since 1.7
* //@author Doug Lea
*/
@SuppressWarnings("all")
public class ThreadLocalRandom extends Random {
@ -83,7 +83,6 @@ public class ThreadLocalRandom extends Random {
}
};
/**
* Constructor called only by localRandom.initialValue.
*/
@ -108,14 +107,15 @@ public class ThreadLocalRandom extends Random {
* @throws UnsupportedOperationException always
*/
public void setSeed(long seed) {
if (initialized)
if (initialized) {
throw new UnsupportedOperationException();
}
rnd = (seed ^ multiplier) & mask;
}
protected int next(int bits) {
rnd = (rnd * multiplier + addend) & mask;
return (int) (rnd >>> (48-bits));
return (int) (rnd >>> (48 - bits));
}
/**
@ -129,8 +129,9 @@ public class ThreadLocalRandom extends Random {
* @return the next value
*/
public int nextInt(int least, int bound) {
if (least >= bound)
if (least >= bound) {
throw new IllegalArgumentException();
}
return nextInt(bound - least) + least;
}
@ -144,8 +145,10 @@ public class ThreadLocalRandom extends Random {
* @throws IllegalArgumentException if n is not positive
*/
public long nextLong(long n) {
if (n <= 0)
if (n <= 0) {
throw new IllegalArgumentException("n must be positive");
}
// Divide n by two until small enough for nextInt. On each
// iteration (at most 31 of them but usually much less),
// randomly choose both whether to include high bit in result
@ -156,8 +159,9 @@ public class ThreadLocalRandom extends Random {
int bits = next(2);
long half = n >>> 1;
long nextn = ((bits & 2) == 0) ? half : n - half;
if ((bits & 1) == 0)
if ((bits & 1) == 0) {
offset += n - nextn;
}
n = nextn;
}
return offset + nextInt((int) n);
@ -174,8 +178,9 @@ public class ThreadLocalRandom extends Random {
* to bound
*/
public long nextLong(long least, long bound) {
if (least >= bound)
if (least >= bound) {
throw new IllegalArgumentException();
}
return nextLong(bound - least) + least;
}
@ -189,8 +194,9 @@ public class ThreadLocalRandom extends Random {
* @throws IllegalArgumentException if n is not positive
*/
public double nextDouble(double n) {
if (n <= 0)
if (n <= 0) {
throw new IllegalArgumentException("n must be positive");
}
return nextDouble() * n;
}
@ -205,8 +211,9 @@ public class ThreadLocalRandom extends Random {
* to bound
*/
public double nextDouble(double least, double bound) {
if (least >= bound)
if (least >= bound) {
throw new IllegalArgumentException();
}
return nextDouble() * (bound - least) + least;
}