org.bitbucket.dollar.randoms.RandomBooleanWrapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dollar Show documentation
Show all versions of dollar Show documentation
Java API that unifies collections, arrays, iterators/iterable and char sequences (String, StringBuilder, etc).
The newest version!
package org.bitbucket.dollar.randoms;
import java.util.Iterator;
import java.util.Random;
import org.bitbucket.dollar.Dollar.Wrapper;
public class RandomBooleanWrapper extends RandomWrapper {
public RandomBooleanWrapper(Random random, int samples) {
super(random, samples);
}
@Override
public Iterator iterator() {
return new RandomIterator(samples) {
@Override
public Boolean nextRandom() {
return random.nextBoolean();
}
};
}
@Override
public Wrapper copy() {
return new RandomBooleanWrapper(random, samples);
}
@Override
public boolean equals(Object object) {
if (object instanceof RandomBooleanWrapper) {
RandomBooleanWrapper randomBooleanWrapper = (RandomBooleanWrapper) object;
return random == randomBooleanWrapper.random
&& samples == randomBooleanWrapper.samples;
} else {
return false;
}
}
@Override
public int hashCode() {
int hash = 19;
hash *= 79 + random.hashCode();
hash *= 79 + samples;
return hash;
}
}