@Test public void withLength() { assertThat(generator.withLength(5), ContainsPattern.matchesPattern(Pattern.compile("[A-Za-z0-9]{5}"))); }
@Override public String withLength(int length) { Character[] patterns = randomGenerators.keySet().toArray(new Character[0]); return IntStream .range(0, length) .map(i -> randomGenerators.get(patterns[i % patterns.length]).get()) .collect(producer(), accumulator(), resultMerger() ).toString(); }
RandomGeneratorFacadeImpl implements RandomGeneratorFacade { @Override public String withLength(int length) { Character[] patterns = randomGenerators.keySet().toArray(new Character[0]); return IntStream .range(0, length) .map(i -> randomGenerators.get(patterns[i % patterns.length]).get()) .collect(producer(), accumulator(), resultMerger() ).toString(); } }
RandomGeneratorFacadeImpl implements RandomGeneratorFacade { @Override public String withLength(int length) { Character[] patterns = randomGenerators.keySet().toArray(new Character[0]); return IntStream .range(0, length) .map(i -> randomGenerators.get(patterns[i % patterns.length]).get()) .collect(producer(), accumulator(), resultMerger() ).toString(); } RandomGeneratorFacadeImpl(); }
RandomGeneratorFacadeImpl implements RandomGeneratorFacade { @Override public String withLength(int length) { Character[] patterns = randomGenerators.keySet().toArray(new Character[0]); return IntStream .range(0, length) .map(i -> randomGenerators.get(patterns[i % patterns.length]).get()) .collect(producer(), accumulator(), resultMerger() ).toString(); } RandomGeneratorFacadeImpl(); @Override String byPattern(String pattern); @Override String withLength(int length); }
RandomGeneratorFacadeImpl implements RandomGeneratorFacade { @Override public String withLength(int length) { Character[] patterns = randomGenerators.keySet().toArray(new Character[0]); return IntStream .range(0, length) .map(i -> randomGenerators.get(patterns[i % patterns.length]).get()) .collect(producer(), accumulator(), resultMerger() ).toString(); } RandomGeneratorFacadeImpl(); @Override String byPattern(String pattern); @Override String withLength(int length);  }