VectorGeneratorsFamily implements VectorGenerator { @Override public Vector get() { return family.get(selector.getInt()).get(); } private  VectorGeneratorsFamily(List<VectorGenerator> family, DiscreteRandomProducer selector); @Override Vector get(); VectorWithDistributionId getWithId(); @Override DataStreamGenerator asDataStream();  }
@Test public void testMap() { VectorGeneratorsFamily family = new VectorGeneratorsFamily.Builder() .add(() -> VectorUtils.of(1., 2.)) .map(g -> g.move(VectorUtils.of(1, -1))) .build(0L); assertArrayEquals(new double[] {2., 1.}, family.get().asArray(), 1e-7); }
@Test public void testGet() { VectorGeneratorsFamily family = new VectorGeneratorsFamily.Builder() .add(() -> VectorUtils.of(0.)) .add(() -> VectorUtils.of(1.)) .add(() -> VectorUtils.of(2.)) .build(0L); Set<Double> validValues = DoubleStream.of(0., 1., 2.).boxed().collect(Collectors.toSet()); for (int i = 0; i < 100; i++) { Vector vector = family.get(); assertTrue(validValues.contains(vector.get(0))); } }