Package org.instancio
Interface TypeToken<T>
-
- Type Parameters:
T
- type being supplied.Required to be present, though not used directly.
- All Superinterfaces:
Supplier<Type>
,TypeTokenSupplier<T>
public interface TypeToken<T> extends TypeTokenSupplier<T>
A supplier that providesType
information. It can be used with generic classes in order to avoid "unchecked assignment" warnings.The following examples both create an instance of @{code Pair} class.
// Generates an "unchecked assignment" warning // which can be suppressed with @SuppressWarnings("unchecked") Pair<Integer, String> pair = Instancio.of(Pair.class) .withTypeParameters(Integer.class, String.class) .create(); // This usage avoids the warning Pair<Integer, String> pair = Instancio.of(new TypeToken<Pair<Integer, String>>() {}).create();
-
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default Type
get()
Returns the type to be created.
-