JacksonObjectArbitraryIntrospector

JacksonObjectArbitraryIntrospector

The JacksonObjectArbitraryIntrospector becomes the default introspector when the Jackson plugin is added. It puts the created properties of the given class into a map and deserializes them using Jackson’s object mapper.

Example Java Class :

@Value
public class Product {
    long id;

    String productName;

    long price;

    List<String> options;

    Instant createdAt;
}

Using JacksonObjectArbitraryIntrospector :

@Test
void test() {
    FixtureMonkey fixtureMonkey = FixtureMonkey.builder()
        .plugin(new JacksonPlugin())
        .build();

    Product product = fixtureMonkey.giveMeOne(Product.class);
}
testImplementation("com.navercorp.fixturemonkey:fixture-monkey-starter-kotlin:1.0.27")
testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin")

@Test
fun test() {
    FixtureMonkey fixtureMonkey = FixtureMonkey.builder()
        .plugin(KotlinPlugin())
        .plugin(JacksonPlugin())
        .build();

    val product: Product = fixtureMonkey.giveMeOne()
}

It has the advantage of being a general purpose introspector because it relies on the widely used Jackson for object creation. If your production code has both Kotlin and Java classes, it is recommended to use JacksonObjectArbitraryIntrospector.

However, it does have the disadvantage of potentially not performing as efficiently as other introspectors, as deserialization with Jackson can be more time-consuming.