Skip to content

Latest commit

 

History

History

type-resolver-sample

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Instancio - TypeResolver Sample

A TypeResolver allows mapping a type to its subtype.

For example, Instancio does not resolve implementations of abstract types. However, the TypeResolver interface can be implemented to support such functionality.

This sample uses ClassGraph to resolve implementation classes automatically by scanning the classpath. Once implemented, it allows the following use case:

// Given
interface Person { ... }
class PersonImpl implements Person { ... }

// When
Person person = Instancio.create(Person.class);

// Then
assertThat(person).isExactlyInstanceOf(PersonImpl.class);