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>
A supplier that provides
Type
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