Jackson3ObjectArbitraryIntrospector
Jackson3ObjectArbitraryIntrospector
The Jackson3ObjectArbitraryIntrospector becomes the default introspector when the Jackson3 plugin is added.
It puts the created properties of the given class into a map and deserializes them using Jackson 3's object mapper.
Example Java Class :
@Value
public class Product {
long id;
String productName;
long price;
List<String> options;
Instant createdAt;
}
Using Jackson3ObjectArbitraryIntrospector :
- Java
- Kotlin
@Test
void test() {
FixtureMonkey fixtureMonkey = FixtureMonkey.builder()
.plugin(new Jackson3Plugin())
.build();
Product product = fixtureMonkey.giveMeOne(Product.class);
}
testImplementation("com.navercorp.fixturemonkey:fixture-monkey-starter-kotlin:1.1.16")
testImplementation("tools.jackson.module:jackson-module-kotlin")
@Test
fun test() {
FixtureMonkey fixtureMonkey = FixtureMonkey.builder()
.plugin(KotlinPlugin())
.plugin(Jackson3Plugin())
.build();
val product: Product = fixtureMonkey.giveMeOne()
}
To generate Kotlin classes with Jackson3ObjectArbitraryIntrospector, both Kotlin plugin and Jackson3 plugin need to be added. In addition, jackson-module-kotlin for Jackson 3 should be added to the dependency for serialization/deserialization of Kotlin classes.
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 Jackson3ObjectArbitraryIntrospector.
However, it does have the disadvantage of potentially not performing as efficiently as other introspectors, as deserialization with Jackson can be more time-consuming.