mvrx-mocking / com.airbnb.mvrx.mocking.printer / AutoValueTypePrinter

AutoValueTypePrinter

class AutoValueTypePrinter : TypePrinter<Any>

This looks for classes generated via AutoValue, indicated by the class prefix GENERATED_PREFIX. When an autovalue class is found, code to reconstruct it is generated by reflectively accessing the Builder and its setter functions.

This relies on the class using the naming pattern of builder() and build() for its functions, as well as Builder for its builder class.

Constructors

<init>

AutoValueTypePrinter()

This looks for classes generated via AutoValue, indicated by the class prefix GENERATED_PREFIX. When an autovalue class is found, code to reconstruct it is generated by reflectively accessing the Builder and its setter functions.

Functions

acceptsObject

fun acceptsObject(obj: Any): Boolean

Return true if obj is a valid object to pass to generateCode.

generateCode

fun generateCode(instance: Any, generateConstructor: (Any?) -> String): String

A function that takes an instance of an object and returns a String representing the Kotlin code that can be used to recreate the instance with the same data.

modifyImports

fun modifyImports(imports: List<String>): List<String>

Optionally modify the import statements that will be added to the generated mock file. By default, each processed type is added as an import.