Skip to content

Commit

Permalink
Kotlin client: add volley library support (#10253)
Browse files Browse the repository at this point in the history
* Add basic jvm-volley folder to enable it as a library

* Add JVM_VOLLEY to the KotlinClientCodegen as a library option (using Retrofit2 processing for now)

* Temporary checkin of generated code and kotlinfied version for use in new template

* Added Kotlin-ified api invoker and request objects, update Kotlin client codgen for volley

* Add Android specific build.gradle mustache file to jvm-volley library

* Hardcode SDK version and build tools version in build.gradle template, add extra repository for Android Gradle build tools

* Add Android manifest to generated code

* Add Kotlin dependencies and plugins to build gradle template

* WIP: Create basic API templating for jvm-volley

* Add ApiException and parameter validation, create path variable using ApiInvoker

* Build queryParams and headerParams

* Add VolleyRequest template

* WIP: Injecting context and default API invoker into APIs (non compiling)

* Add DefaultInvoker stub and update API to inject context

* Add request queue generation to the DefaultInvoker

* Fix up compile errors in the invoker

* Cleanup unrequired templates

* Update templates

* Add constructor overloads to inject stack or network into request queue

* Fix compile errors with request queue generation

* Fix compile errors

* Al'll fix it for you.....

* WIP compile fixes

* More compile fixes

* Generate to java directory and kotlin-ify auth code

* More syntax fixes in templates

* Almost left it in a working state, fixing that .... now...

* Switch builder method based on model existence constraints - body and response

* Add coroutine logic to APIs and pass through listeners to the requests, various other fixes.

* Use reflection and type tokens to work around clazz issues on generics

* Add POST, PATCH and PUT to RequestFactory

* More templating magic

* Fix Steve, the human compiler's errors again !

* Add CLI option for generating room models

* Configure the room model package

* Add initial room model templating and generation

* Add room model generation implementation

* Implement toRoom function on models to convert model to room model

* Bug fixes, transformers to and from room models

* Add query parameters to URL generation

* Fix issues with gson type conversion, add type adapters to gson instance

* Fix issues with older API versions and Java8 libraries,

* Add request factory interface

* API template tidy up

* Update IRequestFactory to include companion object, minor tidy ups

* Remove @keep annotations from room templates

* Rename toRoomModel and toApiModel functions

* Add empty companion object to generated room model

* Add ITransformStorage interface to allow polymorphic transforms to room models

* Add content type into GsonRequest

* Move gson serialization of request body into GsonRequest

* Update request factory to take header factories

* Remove the generated comparision code

* Move the generateRoomModels switch into the KotlinClientCodegen class

* Move room model generation out of default generator

* Updates for auth

* Finalise removal of kotlin elements from default generator

* Hoist room model logic out of abstractKotlin into kotlin client codegen

* Revert AbstractKotlinCodegen

* Revert Codegen constants to remove base generator changes out of our new library

* Revert data class template changes, add data class body check to Kotlin Client codegen

* Add sample generation yaml file for jvm-volley library

* Update JVM-Volley readme for generateRoomModels flag

* Remove unused template files, get auth compiling but non functional, clean build of warnings

* Generate sample generated code

* Add not implemented method for oauth

* Add unit test for KotlinClientCodegen generateRoomModel flag

* Remove accidental hard coding of src/main/java source folder

* Push changed generated sample files

* Move and rename IStorable inside the volley library

* Inject retry policy into API definition, re-run sample and doc scripts

* Add generic post processors

* Update samples after generator changes

* Fix some compile errors with the pet store sample

* Fix duplicate auth companion object and import generation

* Reinstate query and form parameter code generation

* Add check for unsupported serialization libraries

* Fix broken unit tests

* Regenerate samples

* AN-233 Update request factory to allow custom gsonadapters

* update `GsonRequest.mustache` and `RequestFactoy.mustache` to use `Map<Type, Any>` instead of `Map<Type, Object>` to better fit kotlin conventions

* Update readme with better examples and design notes

* Update readme with info about gson serializers and adapters for polymorphic types

* Updated samples

* Merge from upstream

* Address review comments

* Update samples

* Samples

* Update docs

* Remove DateAdapter generated file, template and it's inclusion as a supporting file in favour of localDateTime

* Review comment cleanup for initial PR #10253 - cleaner auth key in parameter string handling

* Review comment - add a kotlin version parameter to the build scripts

* Updated samples

* Missing changes from build.mustache

* Regenerate samples for build.gradle changes

* Merge from master and generate samples

* Remove serializer as a supporting file from jvm-volley - it's serialisation is not a singleton and configured differently via gson request and dependency injection

* Remove singleton serializer from jvm-volley generation as it's not used

Co-authored-by: Alister Shipman <alister.shipman@greater.com.au>
Co-authored-by: Steve Telford <steven.telford@greater.com.au>
Co-authored-by: Leigh Cooper <leigh.cooper@greater.com.au>
Co-authored-by: Michael Hewett <y2trooper@gmail.com>
  • Loading branch information
5 people authored Dec 20, 2021
1 parent b72eba9 commit 0de482d
Show file tree
Hide file tree
Showing 75 changed files with 5,591 additions and 6 deletions.
9 changes: 9 additions & 0 deletions bin/configs/kotlin-jvm-volley.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
generatorName: kotlin
outputDir: samples/client/petstore/kotlin-jvm-volley
library: jvm-volley
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/kotlin-client
additionalProperties:
artifactId: kotlin-petstore-jvm-volley
generateRoomModels: "true"
serializationLibrary: "gson"
3 changes: 2 additions & 1 deletion docs/generators/kotlin.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|collectionType|Option. Collection type to use|<dl><dt>**array**</dt><dd>kotlin.Array</dd><dt>**list**</dt><dd>kotlin.collections.List</dd></dl>|list|
|dateLibrary|Option. Date library to use|<dl><dt>**threetenbp-localdatetime**</dt><dd>Threetenbp - Backport of JSR310 (jvm only, for legacy app only)</dd><dt>**string**</dt><dd>String</dd><dt>**java8-localdatetime**</dt><dd>Java 8 native JSR310 (jvm only, for legacy app only)</dd><dt>**java8**</dt><dd>Java 8 native JSR310 (jvm only, preferred for jdk 1.8+)</dd><dt>**threetenbp**</dt><dd>Threetenbp - Backport of JSR310 (jvm only, preferred for jdk &lt; 1.8)</dd></dl>|java8|
|enumPropertyNaming|Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'| |camelCase|
|generateRoomModels|Generate Android Room database models in addition to API models (JVM Volley library only)| |false|
|groupId|Generated artifact package's organization (i.e. maven groupId).| |org.openapitools|
|library|Library template (sub-template) to use|<dl><dt>**jvm-okhttp4**</dt><dd>[DEFAULT] Platform: Java Virtual Machine. HTTP client: OkHttp 4.2.0 (Android 5.0+ and Java 8+). JSON processing: Moshi 1.8.0.</dd><dt>**jvm-okhttp3**</dt><dd>Platform: Java Virtual Machine. HTTP client: OkHttp 3.12.4 (Android 2.3+ and Java 7+). JSON processing: Moshi 1.8.0.</dd><dt>**jvm-retrofit2**</dt><dd>Platform: Java Virtual Machine. HTTP client: Retrofit 2.6.2.</dd><dt>**multiplatform**</dt><dd>Platform: Kotlin multiplatform. HTTP client: Ktor 1.6.0. JSON processing: Kotlinx Serialization: 1.2.1.</dd></dl>|jvm-okhttp4|
|library|Library template (sub-template) to use|<dl><dt>**jvm-okhttp4**</dt><dd>[DEFAULT] Platform: Java Virtual Machine. HTTP client: OkHttp 4.2.0 (Android 5.0+ and Java 8+). JSON processing: Moshi 1.8.0.</dd><dt>**jvm-okhttp3**</dt><dd>Platform: Java Virtual Machine. HTTP client: OkHttp 3.12.4 (Android 2.3+ and Java 7+). JSON processing: Moshi 1.8.0.</dd><dt>**jvm-retrofit2**</dt><dd>Platform: Java Virtual Machine. HTTP client: Retrofit 2.6.2.</dd><dt>**multiplatform**</dt><dd>Platform: Kotlin multiplatform. HTTP client: Ktor 1.6.0. JSON processing: Kotlinx Serialization: 1.2.1.</dd><dt>**jvm-volley**</dt><dd>Platform: JVM for Android. HTTP client: Volley 1.2.1. JSON processing: gson 2.8.9</dd></dl>|jvm-okhttp4|
|modelMutable|Create mutable models| |false|
|moshiCodeGen|Whether to enable codegen with the Moshi library. Refer to the [official Moshi doc](https://github.com/square/moshi#codegen) for more info.| |false|
|omitGradlePluginVersions|Whether to declare Gradle plugin versions in build files.| |false|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,15 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
protected static final String JVM_OKHTTP3 = "jvm-okhttp3";
protected static final String JVM_RETROFIT2 = "jvm-retrofit2";
protected static final String MULTIPLATFORM = "multiplatform";
protected static final String JVM_VOLLEY = "jvm-volley";

public static final String USE_RX_JAVA = "useRxJava";
public static final String USE_RX_JAVA2 = "useRxJava2";
public static final String USE_RX_JAVA3 = "useRxJava3";
public static final String USE_COROUTINES = "useCoroutines";
public static final String DO_NOT_USE_RX_AND_COROUTINES = "doNotUseRxAndCoroutines";
public static final String GENERATE_ROOM_MODELS = "generateRoomModels";
public static final String ROOM_MODEL_PACKAGE = "roomModelPackage";
public static final String OMIT_GRADLE_PLUGIN_VERSIONS = "omitGradlePluginVersions";

public static final String DATE_LIBRARY = "dateLibrary";
Expand All @@ -85,6 +88,9 @@ public class KotlinClientCodegen extends AbstractKotlinCodegen {
// backwards compatibility for openapi configs that specify neither rx1 nor rx2
// (mustache does not allow for boolean operators so we need this extra field)
protected boolean doNotUseRxAndCoroutines = true;
protected boolean generateRoomModels = false;
protected String roomModelPackage = "";


protected String authFolder;

Expand Down Expand Up @@ -167,6 +173,9 @@ public KotlinClientCodegen() {

outputFolder = "generated-code" + File.separator + "kotlin-client";
modelTemplateFiles.put("model.mustache", ".kt");
if (generateRoomModels) {
modelTemplateFiles.put("model_room.mustache", ".kt");
}
apiTemplateFiles.put("api.mustache", ".kt");
modelDocTemplateFiles.put("model_doc.mustache", ".md");
apiDocTemplateFiles.put("api_doc.mustache", ".md");
Expand Down Expand Up @@ -197,6 +206,7 @@ public KotlinClientCodegen() {
supportedLibraries.put(JVM_OKHTTP3, "Platform: Java Virtual Machine. HTTP client: OkHttp 3.12.4 (Android 2.3+ and Java 7+). JSON processing: Moshi 1.8.0.");
supportedLibraries.put(JVM_RETROFIT2, "Platform: Java Virtual Machine. HTTP client: Retrofit 2.6.2.");
supportedLibraries.put(MULTIPLATFORM, "Platform: Kotlin multiplatform. HTTP client: Ktor 1.6.0. JSON processing: Kotlinx Serialization: 1.2.1.");
supportedLibraries.put(JVM_VOLLEY, "Platform: JVM for Android. HTTP client: Volley 1.2.1. JSON processing: gson 2.8.9");

CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "Library template (sub-template) to use");
libraryOption.setEnum(supportedLibraries);
Expand All @@ -220,6 +230,8 @@ public KotlinClientCodegen() {

cliOptions.add(CliOption.newBoolean(MOSHI_CODE_GEN, "Whether to enable codegen with the Moshi library. Refer to the [official Moshi doc](https://github.com/square/moshi#codegen) for more info."));

cliOptions.add(CliOption.newBoolean(GENERATE_ROOM_MODELS, "Generate Android Room database models in addition to API models (JVM Volley library only)", false));

cliOptions.add(CliOption.newBoolean(SUPPORT_ANDROID_API_LEVEL_25_AND_BELLOW, "[WARNING] This flag will generate code that has a known security vulnerability. It uses `kotlin.io.createTempFile` instead of `java.nio.file.Files.createTempFile` in oder to support Android API level 25 and bellow. For more info, please check the following links https://github.com/OpenAPITools/openapi-generator/security/advisories/GHSA-23x4-m842-fmwf, https://github.com/OpenAPITools/openapi-generator/pull/9284"));
}

Expand All @@ -235,6 +247,12 @@ public String getHelp() {
return "Generates a Kotlin client.";
}

public boolean getGenerateRoomModels() { return generateRoomModels; }

public void setGenerateRoomModels(Boolean generateRoomModels) {
this.generateRoomModels = generateRoomModels;
}

public void setUseRxJava(boolean useRxJava) {
if (useRxJava) {
this.useRxJava2 = false;
Expand Down Expand Up @@ -298,14 +316,45 @@ public void setCollectionType(String collectionType) {
this.collectionType = collectionType;
}

public void setRoomModelPackage(String roomModelPackage) {
this.roomModelPackage = roomModelPackage;
}

@Override
public void processOpts() {
super.processOpts();
public String modelFilename(String templateName, String modelName) {
String suffix = modelTemplateFiles().get(templateName);
// If this was a proper template method, i wouldn't have to make myself throw up by doing this....
if (getGenerateRoomModels() && suffix.startsWith("RoomModel")) {
return roomModelFileFolder() + File.separator + toModelFilename(modelName) + suffix;
} else {
return modelFileFolder() + File.separator + toModelFilename(modelName) + suffix;
}
}

public String roomModelFileFolder() {
return outputFolder + File.separator + sourceFolder + File.separator + roomModelPackage.replace('.', File.separatorChar);
}

if (MULTIPLATFORM.equals(getLibrary())) {
sourceFolder = "src/commonMain/kotlin";
@Override
public void processOpts() {
if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)) {
setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER));
} else {
// Set the value to defaults if we haven't overridden
if (MULTIPLATFORM.equals(getLibrary())) {
setSourceFolder("src/commonMain/kotlin");
}
else if (JVM_VOLLEY.equals(getLibrary())){
// Android plugin wants it's source in java
setSourceFolder("src/main/java");
}
else {
setSourceFolder(super.sourceFolder);
}
additionalProperties.put(CodegenConstants.SOURCE_FOLDER, this.sourceFolder);
}

super.processOpts();

boolean hasRx = additionalProperties.containsKey(USE_RX_JAVA);
boolean hasRx2 = additionalProperties.containsKey(USE_RX_JAVA2);
Expand Down Expand Up @@ -348,6 +397,12 @@ public void processOpts() {
final String infrastructureFolder = (sourceFolder + File.separator + packageName + File.separator + "infrastructure").replace(".", "/");
authFolder = (sourceFolder + File.separator + packageName + File.separator + "auth").replace(".", "/");

// request destination folder
final String requestFolder = (sourceFolder + File.separator + packageName + File.separator + "request").replace(".", "/");

// auth destination folder
final String authFolder = (sourceFolder + File.separator + packageName + File.separator + "auth").replace(".", "/");

// additional properties
if (additionalProperties.containsKey(DATE_LIBRARY)) {
setDateLibrary(additionalProperties.get(DATE_LIBRARY).toString());
Expand All @@ -364,6 +419,9 @@ public void processOpts() {
case JVM_OKHTTP4:
processJVMOkHttpLibrary(infrastructureFolder);
break;
case JVM_VOLLEY:
processJVMVolleyLibrary(infrastructureFolder, requestFolder, authFolder);
break;
case JVM_RETROFIT2:
processJVMRetrofit2Library(infrastructureFolder);
break;
Expand Down Expand Up @@ -477,6 +535,47 @@ private void processJVMRetrofit2Library(String infrastructureFolder) {
addSupportingSerializerAdapters(infrastructureFolder);
}

private void processJVMVolleyLibrary(String infrastructureFolder, String requestFolder, String authFolder) {

additionalProperties.put(JVM, true);
additionalProperties.put(JVM_VOLLEY, true);

if (additionalProperties.containsKey(GENERATE_ROOM_MODELS)) {
this.setGenerateRoomModels(convertPropertyToBooleanAndWriteBack(GENERATE_ROOM_MODELS));
// Hide this option behind a property getter and setter in case we need to check it elsewhere
if (getGenerateRoomModels()) {
modelTemplateFiles.put("model_room.mustache", "RoomModel.kt");
supportingFiles.add(new SupportingFile("infrastructure/ITransformForStorage.mustache", infrastructureFolder, "ITransformForStorage.kt"));

}
} else {
additionalProperties.put(GENERATE_ROOM_MODELS, generateRoomModels);
}

if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
if (!additionalProperties.containsKey(ROOM_MODEL_PACKAGE))
this.setRoomModelPackage(packageName + ".models.room");
else
this.setRoomModelPackage(additionalProperties.get(ROOM_MODEL_PACKAGE).toString());
}
additionalProperties.put(ROOM_MODEL_PACKAGE, roomModelPackage);

supportingFiles.add(new SupportingFile("infrastructure/CollectionFormats.kt.mustache", infrastructureFolder, "CollectionFormats.kt"));

// We have auth related partial files, so they can be overridden, but don't generate them explicitly
supportingFiles.add(new SupportingFile("request/GsonRequest.mustache", requestFolder, "GsonRequest.kt"));
supportingFiles.add(new SupportingFile("request/IRequestFactory.mustache", requestFolder, "IRequestFactory.kt"));
supportingFiles.add(new SupportingFile("request/RequestFactory.mustache", requestFolder, "RequestFactory.kt"));
supportingFiles.add(new SupportingFile("infrastructure/CollectionFormats.kt.mustache", infrastructureFolder, "CollectionFormats.kt"));

if (getSerializationLibrary() != SERIALIZATION_LIBRARY_TYPE.gson) {
throw new RuntimeException("This library currently only supports gson serialization. Try adding '--additional-properties serializationLibrary=gson' to your command.");
}
addSupportingSerializerAdapters(infrastructureFolder);
supportingFiles.remove(new SupportingFile("jvm-common/infrastructure/Serializer.kt.mustache", infrastructureFolder, "Serializer.kt"));

}

private void addSupportingSerializerAdapters(final String infrastructureFolder) {
supportingFiles.add(new SupportingFile("jvm-common/infrastructure/Serializer.kt.mustache", infrastructureFolder, "Serializer.kt"));
supportingFiles.add(new SupportingFile("jvm-common/infrastructure/ByteArrayAdapter.kt.mustache", infrastructureFolder, "ByteArrayAdapter.kt"));
Expand Down Expand Up @@ -605,6 +704,11 @@ private void commonSupportingFiles() {
if (getLibrary().equals(MULTIPLATFORM)) {
supportingFiles.add(new SupportingFile("build.gradle.kts.mustache", "", "build.gradle.kts"));
supportingFiles.add(new SupportingFile("settings.gradle.kts.mustache", "", "settings.gradle.kts"));
} else if (getLibrary().equals(JVM_VOLLEY)) {
supportingFiles.add(new SupportingFile("build.mustache", "", "build.gradle"));
supportingFiles.add(new SupportingFile("gradle.properties.mustache", "", "gradle.properties"));
supportingFiles.add(new SupportingFile("settings.gradle.mustache", "", "settings.gradle"));
supportingFiles.add(new SupportingFile("manifest.mustache", "", "src/main/AndroidManifest.xml"));
} else {
supportingFiles.add(new SupportingFile("build.gradle.mustache", "", "build.gradle"));
supportingFiles.add(new SupportingFile("settings.gradle.mustache", "", "settings.gradle"));
Expand All @@ -625,6 +729,9 @@ public Map<String, Object> postProcessModels(Map<String, Object> objs) {
for (Object model : models) {
@SuppressWarnings("unchecked") Map<String, Object> mo = (Map<String, Object>) model;
CodegenModel cm = (CodegenModel) mo.get("model");
if (getGenerateRoomModels()) {
cm.vendorExtensions.put("x-has-data-class-body", true);
}

// escape the variable base name for use as a string literal
List<CodegenProperty> vars = Stream.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ import kotlinx.serialization.encoding.*
{{#serializableModel}}
import java.io.Serializable
{{/serializableModel}}
{{#generateRoomModels}}
import {{roomModelPackage}}.{{classname}}RoomModel
import {{packageName}}.infrastructure.ITransformForStorage
{{/generateRoomModels}}

/**
* {{{description}}}
Expand All @@ -56,8 +60,16 @@ import java.io.Serializable
{{#required}}{{>data_class_req_var}}{{/required}}{{^required}}{{>data_class_opt_var}}{{/required}}{{^-last}},{{/-last}}

{{/allVars}}
){{/discriminator}}{{#parent}}{{^serializableModel}}{{^parcelizeModels}} : {{{parent}}}{{#isMap}}(){{/isMap}}{{#isArray}}(){{/isArray}}{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{#parent}}{{#serializableModel}}{{^parcelizeModels}} : {{{parent}}}{{#isMap}}(){{/isMap}}{{#isArray}}(){{/isArray}}, Serializable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{#parent}}{{^serializableModel}}{{#parcelizeModels}} : {{{parent}}}{{#isMap}}(){{/isMap}}{{#isArray}}(){{/isArray}}, Parcelable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{#parent}}{{#serializableModel}}{{#parcelizeModels}} : {{{parent}}}{{#isMap}}(){{/isMap}}{{#isArray}}(){{/isArray}}, Serializable, Parcelable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{^parent}}{{#serializableModel}}{{^parcelizeModels}} : Serializable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{^parent}}{{^serializableModel}}{{#parcelizeModels}} : Parcelable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{^parent}}{{#serializableModel}}{{#parcelizeModels}} : Serializable, Parcelable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{#vendorExtensions.x-has-data-class-body}} {
){{/discriminator}}{{#parent}}{{^serializableModel}}{{^parcelizeModels}} : {{{parent}}}{{#isMap}}(){{/isMap}}{{#isArray}}(){{/isArray}}{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{#parent}}{{#serializableModel}}{{^parcelizeModels}} : {{{parent}}}{{#isMap}}(){{/isMap}}{{#isArray}}(){{/isArray}}, Serializable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{#parent}}{{^serializableModel}}{{#parcelizeModels}} : {{{parent}}}{{#isMap}}(){{/isMap}}{{#isArray}}(){{/isArray}}, Parcelable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{#parent}}{{#serializableModel}}{{#parcelizeModels}} : {{{parent}}}{{#isMap}}(){{/isMap}}{{#isArray}}(){{/isArray}}, Serializable, Parcelable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{^parent}}{{#serializableModel}}{{^parcelizeModels}} : Serializable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{^parent}}{{^serializableModel}}{{#parcelizeModels}} : Parcelable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{^parent}}{{#serializableModel}}{{#parcelizeModels}} : Serializable, Parcelable{{/parcelizeModels}}{{/serializableModel}}{{/parent}}{{#generateRoomModels}}{{#parent}}, {{/parent}}{{^discriminator}}{{^parent}}:{{/parent}} ITransformForStorage<{{classname}}RoomModel>{{/discriminator}}{{/generateRoomModels}}{{#vendorExtensions.x-has-data-class-body}} {
{{/vendorExtensions.x-has-data-class-body}}
{{#generateRoomModels}}
companion object { }
{{^discriminator}}override fun toRoomModel(): {{classname}}RoomModel =
{{classname}}RoomModel(roomTableId = 0,
{{#allVars}}{{#items.isPrimitiveType}}{{#isArray}}{{#isList}}{{name}} = this.{{name}},{{/isList}}{{/isArray}}{{/items.isPrimitiveType}}{{^isEnum}}{{^isArray}}{{name}} = this.{{name}},{{/isArray}}{{/isEnum}}{{#isEnum}}{{^isArray}}{{name}} = this.{{name}},{{/isArray}}{{/isEnum}}
{{/allVars}}
){{/discriminator}}
{{/generateRoomModels}}
{{#serializableModel}}
{{#nonPublicApi}}internal {{/nonPublicApi}}companion object {
private const val serialVersionUID: Long = 123
Expand Down
Loading

0 comments on commit 0de482d

Please sign in to comment.