@Test public void shouldGenerateTypeThatHasOneArgConstructorAndValueGeneratorAnotherTypeGenerator() { TypeGenerator<WholeAmount, Integer> wholeAmountGenerator = new TypeGenerator<>(WholeAmount.class, ofInstance(13)); TypeGenerator<Salary, WholeAmount> salaryGenerator = new TypeGenerator<>(Salary.class, wholeAmountGenerator); Salary salary = salaryGenerator.next(); Salary expectedSalary = new Salary(new WholeAmount(13)); assertThat(salary, is(expectedSalary)); }
@Override @SuppressWarnings("unchecked") public T next() { V next = valueGenerator.next(); lookupConstructor(typeClass, next.getClass()); try { return (T) constructor.invoke(next); } catch (Throwable throwable) { throw propagate(throwable); } }
TypeGenerator implements Generator<T> { @Override @SuppressWarnings("unchecked") public T next() { V next = valueGenerator.next(); lookupConstructor(typeClass, next.getClass()); try { return (T) constructor.invoke(next); } catch (Throwable throwable) { throw propagate(throwable); } } }
TypeGenerator implements Generator<T> { @Override @SuppressWarnings("unchecked") public T next() { V next = valueGenerator.next(); lookupConstructor(typeClass, next.getClass()); try { return (T) constructor.invoke(next); } catch (Throwable throwable) { throw propagate(throwable); } } TypeGenerator(@Nonnull Class<T> typeClass, @Nonnull Generator<V> valueGenerator); }
TypeGenerator implements Generator<T> { @Override @SuppressWarnings("unchecked") public T next() { V next = valueGenerator.next(); lookupConstructor(typeClass, next.getClass()); try { return (T) constructor.invoke(next); } catch (Throwable throwable) { throw propagate(throwable); } } TypeGenerator(@Nonnull Class<T> typeClass, @Nonnull Generator<V> valueGenerator); @Override @SuppressWarnings("unchecked") T next(); }
TypeGenerator implements Generator<T> { @Override @SuppressWarnings("unchecked") public T next() { V next = valueGenerator.next(); lookupConstructor(typeClass, next.getClass()); try { return (T) constructor.invoke(next); } catch (Throwable throwable) { throw propagate(throwable); } } TypeGenerator(@Nonnull Class<T> typeClass, @Nonnull Generator<V> valueGenerator); @Override @SuppressWarnings("unchecked") T next();  }