-
- All Implemented Interfaces:
-
com.airbnb.mvrx.mocking.printer.TypePrinter
public final class AutoValueTypePrinter implements 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classAutoValueTypePrinter.Companion
-
Constructor Summary
Constructors Constructor Description AutoValueTypePrinter()
-
Method Summary
Modifier and Type Method Description BooleanacceptsObject(Object obj)Return true if obj is a valid object to pass to generateCode. StringgenerateCode(Object instance, Function1<Object, String> generateConstructor)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. List<String>modifyImports(List<String> imports)Optionally modify the import statements that will be added to the generated mock file. -
-
Method Detail
-
acceptsObject
Boolean acceptsObject(Object obj)
Return true if obj is a valid object to pass to generateCode.
-
generateCode
String generateCode(Object instance, Function1<Object, String> generateConstructor)
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.
- Parameters:
generateConstructor- This function can be used to access the default code generation for arbitrary object types.
-
modifyImports
List<String> modifyImports(List<String> imports)
Optionally modify the import statements that will be added to the generated mock file. By default, each processed type is added as an import.
This function can be used if your generated code depends on anything beyond the instance types that are processed.
This will be called once per registered TypePrinter, after all other code has been generated, but only if this instance is actually used to generated code (ie it returned true from acceptsObject at least once).
-
-
-
-