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

ConstructorCodeGenerator

class ConstructorCodeGenerator<T : Any>

This utility is used to generate the code need to construct an object. It is useful for printing out a MavericksState instance's constructor code when setting up a test for that state.

It uses recursion to analyze the given object instance and generates code needed to construct another instance of the object containing the same data.

Types

EnclosingClass

data class EnclosingClass

Constructors

<init>

ConstructorCodeGenerator(objectToCopy: T, listTruncationThreshold: Int = 300, stringTruncationThreshold: Int = 3, customTypePrinters: List<TypePrinter<*>> = emptyList())

This utility is used to generate the code need to construct an object. It is useful for printing out a MavericksState instance's constructor code when setting up a test for that state.

Properties

constructorCode

val constructorCode: String

The code needed to reconstruct objectToCopy.

imports

val imports: List<String>

The fully qualified names of all classes and functions that are used in the code.

lazyPropertyToCreateObject

val lazyPropertyToCreateObject: String

Wraps constructorCode in a property that is lazily initialized.