All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bitbucket.dollar.randoms.RandomBooleanWrapper Maven / Gradle / Ivy

Go to download

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;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy