001package de.cuioss.test.generator; 002 003/** 004 * A generator creates instances of type T. 005 * The method {@link #getType()} provides a default implementation using {@link #next()} and reading 006 * the concrete {@link Class} of the returned element. 007 * 008 * @author Oliver Wolff 009 * @param <T> identifying the type of objects to be generated 010 */ 011public interface TypedGenerator<T> { 012 013 /** 014 * @return class information; which type this generator is responsible for. 015 */ 016 @SuppressWarnings("unchecked") // the implicit providing of the type is the actual idea 017 default Class<T> getType() { 018 return (Class<T>) next().getClass(); 019 } 020 021 /** 022 * Generates the next instance. 023 * 024 * @return a newly created instance 025 */ 026 T next(); 027}