12259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar/* 22259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar * Copyright (C) 2016 The Android Open Source Project 32259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar * 42259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar * Licensed under the Apache License, Version 2.0 (the "License"); 52259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar * you may not use this file except in compliance with the License. 62259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar * You may obtain a copy of the License at 72259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar * 82259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar * http://www.apache.org/licenses/LICENSE-2.0 92259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar * 102259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar * Unless required by applicable law or agreed to in writing, software 112259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar * distributed under the License is distributed on an "AS IS" BASIS, 122259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 132259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar * See the License for the specific language governing permissions and 142259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar * limitations under the License. 152259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar */ 162259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar 17ba069d50913c3fb250bb60ec310439db36895337Alan Viverettepackage androidx.room.solver 182259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar 193c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyarimport COMMON 20ba069d50913c3fb250bb60ec310439db36895337Alan Viveretteimport androidx.paging.DataSource 21ba069d50913c3fb250bb60ec310439db36895337Alan Viveretteimport androidx.paging.PositionalDataSource 22ba069d50913c3fb250bb60ec310439db36895337Alan Viveretteimport androidx.room.Entity 23ba069d50913c3fb250bb60ec310439db36895337Alan Viveretteimport androidx.room.ext.L 24ba069d50913c3fb250bb60ec310439db36895337Alan Viveretteimport androidx.room.ext.LifecyclesTypeNames 25ba069d50913c3fb250bb60ec310439db36895337Alan Viveretteimport androidx.room.ext.PagingTypeNames 26ba069d50913c3fb250bb60ec310439db36895337Alan Viveretteimport androidx.room.ext.ReactiveStreamsTypeNames 27ba069d50913c3fb250bb60ec310439db36895337Alan Viveretteimport androidx.room.ext.RoomTypeNames.STRING_UTIL 28ba069d50913c3fb250bb60ec310439db36895337Alan Viveretteimport androidx.room.ext.RxJava2TypeNames 29ba069d50913c3fb250bb60ec310439db36895337Alan Viveretteimport androidx.room.ext.T 30ba069d50913c3fb250bb60ec310439db36895337Alan Viveretteimport androidx.room.ext.typeName 31ba069d50913c3fb250bb60ec310439db36895337Alan Viveretteimport androidx.room.parser.SQLTypeAffinity 32ba069d50913c3fb250bb60ec310439db36895337Alan Viveretteimport androidx.room.processor.Context 33ba069d50913c3fb250bb60ec310439db36895337Alan Viveretteimport androidx.room.processor.ProcessorErrors 34ba069d50913c3fb250bb60ec310439db36895337Alan Viveretteimport androidx.room.solver.binderprovider.DataSourceFactoryQueryResultBinderProvider 35ba069d50913c3fb250bb60ec310439db36895337Alan Viveretteimport androidx.room.solver.binderprovider.DataSourceQueryResultBinderProvider 36ba069d50913c3fb250bb60ec310439db36895337Alan Viveretteimport androidx.room.solver.binderprovider.FlowableQueryResultBinderProvider 37ba069d50913c3fb250bb60ec310439db36895337Alan Viveretteimport androidx.room.solver.binderprovider.LiveDataQueryResultBinderProvider 38ba069d50913c3fb250bb60ec310439db36895337Alan Viveretteimport androidx.room.solver.types.CompositeAdapter 39ba069d50913c3fb250bb60ec310439db36895337Alan Viveretteimport androidx.room.solver.types.TypeConverter 40ba069d50913c3fb250bb60ec310439db36895337Alan Viveretteimport androidx.room.testing.TestInvocation 41ba069d50913c3fb250bb60ec310439db36895337Alan Viveretteimport androidx.room.testing.TestProcessor 423c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyarimport com.google.auto.common.MoreTypes 432259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyarimport com.google.common.truth.Truth 442259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyarimport com.google.testing.compile.CompileTester 452259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyarimport com.google.testing.compile.JavaFileObjects 462259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyarimport com.google.testing.compile.JavaSourcesSubjectFactory 471f8acf732b58974cb4f06c686e3e770ccf2a6e62Yigit Boyarimport com.squareup.javapoet.TypeName 48aa82fce1d73394bdc7f4c2510cf94a3572032b24Yigit Boyarimport org.hamcrest.CoreMatchers.`is` 49aa82fce1d73394bdc7f4c2510cf94a3572032b24Yigit Boyarimport org.hamcrest.CoreMatchers.instanceOf 50aa82fce1d73394bdc7f4c2510cf94a3572032b24Yigit Boyarimport org.hamcrest.CoreMatchers.notNullValue 51fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyarimport org.hamcrest.CoreMatchers.nullValue 522259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyarimport org.hamcrest.MatcherAssert.assertThat 532259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyarimport org.junit.Test 542259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyarimport org.junit.runner.RunWith 552259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyarimport org.junit.runners.JUnit4 563c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyarimport simpleRun 57645abf12d5a13dae5c2271cedd0563a580871a2bYigit Boyarimport testCodeGenScope 582259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyarimport javax.annotation.processing.ProcessingEnvironment 592259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyarimport javax.lang.model.type.TypeKind 602259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar 612259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") 622259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar@RunWith(JUnit4::class) 632259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyarclass TypeAdapterStoreTest { 642259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar companion object { 652259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar fun tmp(index: Int) = CodeGenScope._tmpVar(index) 662259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar } 672259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar 682259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar @Test 692259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar fun testDirect() { 702259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar singleRun { invocation -> 717a705bcaf6c86eae4c28e38f119289826a651e5bYigit Boyar val store = TypeAdapterStore.create(Context(invocation.processingEnv)) 722259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar val primitiveType = invocation.processingEnv.typeUtils.getPrimitiveType(TypeKind.INT) 73275e7088223c097c1a2df718455bede42bc9efedYigit Boyar val adapter = store.findColumnTypeAdapter(primitiveType, null) 742259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar assertThat(adapter, notNullValue()) 752259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar }.compilesWithoutError() 762259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar } 772259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar 782259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar @Test 791f8acf732b58974cb4f06c686e3e770ccf2a6e62Yigit Boyar fun testJavaLangBoolean() { 801f8acf732b58974cb4f06c686e3e770ccf2a6e62Yigit Boyar singleRun { invocation -> 811f8acf732b58974cb4f06c686e3e770ccf2a6e62Yigit Boyar val store = TypeAdapterStore.create(Context(invocation.processingEnv)) 821f8acf732b58974cb4f06c686e3e770ccf2a6e62Yigit Boyar val boolean = invocation 831f8acf732b58974cb4f06c686e3e770ccf2a6e62Yigit Boyar .processingEnv 841f8acf732b58974cb4f06c686e3e770ccf2a6e62Yigit Boyar .elementUtils 851f8acf732b58974cb4f06c686e3e770ccf2a6e62Yigit Boyar .getTypeElement("java.lang.Boolean") 861f8acf732b58974cb4f06c686e3e770ccf2a6e62Yigit Boyar .asType() 871f8acf732b58974cb4f06c686e3e770ccf2a6e62Yigit Boyar val adapter = store.findColumnTypeAdapter(boolean, null) 881f8acf732b58974cb4f06c686e3e770ccf2a6e62Yigit Boyar assertThat(adapter, notNullValue()) 891f8acf732b58974cb4f06c686e3e770ccf2a6e62Yigit Boyar assertThat(adapter, instanceOf(CompositeAdapter::class.java)) 901f8acf732b58974cb4f06c686e3e770ccf2a6e62Yigit Boyar val composite = adapter as CompositeAdapter 911f8acf732b58974cb4f06c686e3e770ccf2a6e62Yigit Boyar assertThat(composite.intoStatementConverter?.from?.typeName(), 921f8acf732b58974cb4f06c686e3e770ccf2a6e62Yigit Boyar `is`(TypeName.BOOLEAN.box())) 931f8acf732b58974cb4f06c686e3e770ccf2a6e62Yigit Boyar assertThat(composite.columnTypeAdapter.out.typeName(), 941f8acf732b58974cb4f06c686e3e770ccf2a6e62Yigit Boyar `is`(TypeName.INT.box())) 951f8acf732b58974cb4f06c686e3e770ccf2a6e62Yigit Boyar }.compilesWithoutError() 961f8acf732b58974cb4f06c686e3e770ccf2a6e62Yigit Boyar } 971f8acf732b58974cb4f06c686e3e770ccf2a6e62Yigit Boyar 981f8acf732b58974cb4f06c686e3e770ccf2a6e62Yigit Boyar @Test 992259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar fun testVia1TypeAdapter() { 1002259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar singleRun { invocation -> 1017a705bcaf6c86eae4c28e38f119289826a651e5bYigit Boyar val store = TypeAdapterStore.create(Context(invocation.processingEnv)) 1022259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar val booleanType = invocation.processingEnv.typeUtils 1032259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar .getPrimitiveType(TypeKind.BOOLEAN) 104275e7088223c097c1a2df718455bede42bc9efedYigit Boyar val adapter = store.findColumnTypeAdapter(booleanType, null) 1052259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar assertThat(adapter, notNullValue()) 1062259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar assertThat(adapter, instanceOf(CompositeAdapter::class.java)) 107645abf12d5a13dae5c2271cedd0563a580871a2bYigit Boyar val bindScope = testCodeGenScope() 108efaf86afac3163868eda7f91a1c04e3f6e6d7520Yigit Boyar adapter!!.bindToStmt("stmt", "41", "fooVar", bindScope) 1092259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar assertThat(bindScope.generate().trim(), `is`(""" 1102259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar final int ${tmp(0)}; 1112259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar ${tmp(0)} = fooVar ? 1 : 0; 1122259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar stmt.bindLong(41, ${tmp(0)}); 1132259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar """.trimIndent())) 1142259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar 115645abf12d5a13dae5c2271cedd0563a580871a2bYigit Boyar val cursorScope = testCodeGenScope() 116efaf86afac3163868eda7f91a1c04e3f6e6d7520Yigit Boyar adapter.readFromCursor("res", "curs", "7", cursorScope) 1172259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar assertThat(cursorScope.generate().trim(), `is`(""" 1182259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar final int ${tmp(0)}; 1192259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar ${tmp(0)} = curs.getInt(7); 1202259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar res = ${tmp(0)} != 0; 1212259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar """.trimIndent())) 1222259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar }.compilesWithoutError() 1232259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar } 1242259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar 1252259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar @Test 1262259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar fun testVia2TypeAdapters() { 1272259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar singleRun { invocation -> 1287a705bcaf6c86eae4c28e38f119289826a651e5bYigit Boyar val store = TypeAdapterStore.create(Context(invocation.processingEnv), 129fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar pointTypeConverters(invocation.processingEnv)) 1302259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar val pointType = invocation.processingEnv.elementUtils 1312259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar .getTypeElement("foo.bar.Point").asType() 132275e7088223c097c1a2df718455bede42bc9efedYigit Boyar val adapter = store.findColumnTypeAdapter(pointType, null) 1332259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar assertThat(adapter, notNullValue()) 1342259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar assertThat(adapter, instanceOf(CompositeAdapter::class.java)) 1352259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar 136645abf12d5a13dae5c2271cedd0563a580871a2bYigit Boyar val bindScope = testCodeGenScope() 137efaf86afac3163868eda7f91a1c04e3f6e6d7520Yigit Boyar adapter!!.bindToStmt("stmt", "41", "fooVar", bindScope) 1382259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar assertThat(bindScope.generate().trim(), `is`(""" 1398e543c445cb5559e579f54c1ac00d0ca83ec3fbbYigit Boyar final int ${tmp(0)}; 1408e543c445cb5559e579f54c1ac00d0ca83ec3fbbYigit Boyar final boolean ${tmp(1)}; 1418e543c445cb5559e579f54c1ac00d0ca83ec3fbbYigit Boyar ${tmp(1)} = foo.bar.Point.toBoolean(fooVar); 1428e543c445cb5559e579f54c1ac00d0ca83ec3fbbYigit Boyar ${tmp(0)} = ${tmp(1)} ? 1 : 0; 1438e543c445cb5559e579f54c1ac00d0ca83ec3fbbYigit Boyar stmt.bindLong(41, ${tmp(0)}); 1442259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar """.trimIndent())) 1452259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar 146645abf12d5a13dae5c2271cedd0563a580871a2bYigit Boyar val cursorScope = testCodeGenScope() 147efaf86afac3163868eda7f91a1c04e3f6e6d7520Yigit Boyar adapter.readFromCursor("res", "curs", "11", cursorScope).toString() 1482259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar assertThat(cursorScope.generate().trim(), `is`(""" 1492259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar final int ${tmp(0)}; 1502259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar ${tmp(0)} = curs.getInt(11); 1512259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar final boolean ${tmp(1)}; 1522259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar ${tmp(1)} = ${tmp(0)} != 0; 1532259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar res = foo.bar.Point.fromBoolean(${tmp(1)}); 1542259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar """.trimIndent())) 1552259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar }.compilesWithoutError() 1562259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar } 1572259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar 1582259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar @Test 1591676c28584028f8427475745d7a779607af67ecbYigit Boyar fun testDate() { 1601676c28584028f8427475745d7a779607af67ecbYigit Boyar singleRun { (processingEnv) -> 1611676c28584028f8427475745d7a779607af67ecbYigit Boyar val store = TypeAdapterStore.create(Context(processingEnv), 1621676c28584028f8427475745d7a779607af67ecbYigit Boyar dateTypeConverters(processingEnv)) 1631676c28584028f8427475745d7a779607af67ecbYigit Boyar val tDate = processingEnv.elementUtils.getTypeElement("java.util.Date").asType() 1641676c28584028f8427475745d7a779607af67ecbYigit Boyar val adapter = store.findCursorValueReader(tDate, SQLTypeAffinity.INTEGER) 1651676c28584028f8427475745d7a779607af67ecbYigit Boyar assertThat(adapter, notNullValue()) 1661676c28584028f8427475745d7a779607af67ecbYigit Boyar assertThat(adapter?.typeMirror(), `is`(tDate)) 1671676c28584028f8427475745d7a779607af67ecbYigit Boyar val bindScope = testCodeGenScope() 1681676c28584028f8427475745d7a779607af67ecbYigit Boyar adapter!!.readFromCursor("outDate", "curs", "0", bindScope) 1691676c28584028f8427475745d7a779607af67ecbYigit Boyar assertThat(bindScope.generate().trim(), `is`(""" 1701676c28584028f8427475745d7a779607af67ecbYigit Boyar final java.lang.Long _tmp; 1711676c28584028f8427475745d7a779607af67ecbYigit Boyar if (curs.isNull(0)) { 1721676c28584028f8427475745d7a779607af67ecbYigit Boyar _tmp = null; 1731676c28584028f8427475745d7a779607af67ecbYigit Boyar } else { 1741676c28584028f8427475745d7a779607af67ecbYigit Boyar _tmp = curs.getLong(0); 1751676c28584028f8427475745d7a779607af67ecbYigit Boyar } 1761676c28584028f8427475745d7a779607af67ecbYigit Boyar // convert Long to Date; 1771676c28584028f8427475745d7a779607af67ecbYigit Boyar """.trimIndent())) 1781676c28584028f8427475745d7a779607af67ecbYigit Boyar }.compilesWithoutError() 1791676c28584028f8427475745d7a779607af67ecbYigit Boyar } 1801676c28584028f8427475745d7a779607af67ecbYigit Boyar 1811676c28584028f8427475745d7a779607af67ecbYigit Boyar @Test 1822259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar fun testIntList() { 1832259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar singleRun { invocation -> 184fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar val binders = createIntListToStringBinders(invocation) 1857a705bcaf6c86eae4c28e38f119289826a651e5bYigit Boyar val store = TypeAdapterStore.create(Context(invocation.processingEnv), binders[0], 186fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar binders[1]) 187fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar 188275e7088223c097c1a2df718455bede42bc9efedYigit Boyar val adapter = store.findColumnTypeAdapter(binders[0].from, null) 1892259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar assertThat(adapter, notNullValue()) 1902259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar 191645abf12d5a13dae5c2271cedd0563a580871a2bYigit Boyar val bindScope = testCodeGenScope() 192efaf86afac3163868eda7f91a1c04e3f6e6d7520Yigit Boyar adapter!!.bindToStmt("stmt", "41", "fooVar", bindScope) 1932259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar assertThat(bindScope.generate().trim(), `is`(""" 19464db0cc15b78b62a1d44a70fc8b4552e660d952cYigit Boyar final java.lang.String ${tmp(0)}; 195ba069d50913c3fb250bb60ec310439db36895337Alan Viverette ${tmp(0)} = androidx.room.util.StringUtil.joinIntoString(fooVar); 19664db0cc15b78b62a1d44a70fc8b4552e660d952cYigit Boyar if (${tmp(0)} == null) { 19764db0cc15b78b62a1d44a70fc8b4552e660d952cYigit Boyar stmt.bindNull(41); 19864db0cc15b78b62a1d44a70fc8b4552e660d952cYigit Boyar } else { 19964db0cc15b78b62a1d44a70fc8b4552e660d952cYigit Boyar stmt.bindString(41, ${tmp(0)}); 20064db0cc15b78b62a1d44a70fc8b4552e660d952cYigit Boyar } 20164db0cc15b78b62a1d44a70fc8b4552e660d952cYigit Boyar """.trimIndent())) 202fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar 203fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar val converter = store.findTypeConverter(binders[0].from, 204fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar invocation.context.COMMON_TYPES.STRING) 205fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar assertThat(converter, notNullValue()) 206fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar assertThat(store.reverse(converter!!), `is`(binders[1])) 2072259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar }.compilesWithoutError() 2082259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar } 2092259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar 210fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar @Test 211fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar fun testOneWayConversion() { 212fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar singleRun { invocation -> 213fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar val binders = createIntListToStringBinders(invocation) 2147a705bcaf6c86eae4c28e38f119289826a651e5bYigit Boyar val store = TypeAdapterStore.create(Context(invocation.processingEnv), binders[0]) 215275e7088223c097c1a2df718455bede42bc9efedYigit Boyar val adapter = store.findColumnTypeAdapter(binders[0].from, null) 216fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar assertThat(adapter, nullValue()) 217fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar 218275e7088223c097c1a2df718455bede42bc9efedYigit Boyar val stmtBinder = store.findStatementValueBinder(binders[0].from, null) 219fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar assertThat(stmtBinder, notNullValue()) 220fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar 221fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar val converter = store.findTypeConverter(binders[0].from, 222fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar invocation.context.COMMON_TYPES.STRING) 223fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar assertThat(converter, notNullValue()) 224fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar assertThat(store.reverse(converter!!), nullValue()) 225fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar } 226fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar } 227fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar 2283c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar @Test 2293c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar fun testMissingRxRoom() { 2303c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar simpleRun(jfos = *arrayOf(COMMON.PUBLISHER, COMMON.FLOWABLE)) { invocation -> 2313c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar val publisherElement = invocation.processingEnv.elementUtils 2323c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar .getTypeElement(ReactiveStreamsTypeNames.PUBLISHER.toString()) 2333c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar assertThat(publisherElement, notNullValue()) 2349fd8e6171bbdc37f5516fe15b2d96f4ae926ef1aChris Craik assertThat(FlowableQueryResultBinderProvider(invocation.context).matches( 2353c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar MoreTypes.asDeclared(publisherElement.asType())), `is`(true)) 2363c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar }.failsToCompile().withErrorContaining(ProcessorErrors.MISSING_ROOM_RXJAVA2_ARTIFACT) 2373c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar } 2383c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar 2393c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar @Test 2403c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar fun testFindPublisher() { 2413c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar simpleRun(jfos = *arrayOf(COMMON.PUBLISHER, COMMON.FLOWABLE, COMMON.RX2_ROOM)) { 2423c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar invocation -> 2433c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar val publisher = invocation.processingEnv.elementUtils 2443c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar .getTypeElement(ReactiveStreamsTypeNames.PUBLISHER.toString()) 2453c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar assertThat(publisher, notNullValue()) 2469fd8e6171bbdc37f5516fe15b2d96f4ae926ef1aChris Craik assertThat(FlowableQueryResultBinderProvider(invocation.context).matches( 2473c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar MoreTypes.asDeclared(publisher.asType())), `is`(true)) 2483c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar }.compilesWithoutError() 2493c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar } 2503c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar 2513c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar @Test 2523c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar fun testFindFlowable() { 2533c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar simpleRun(jfos = *arrayOf(COMMON.PUBLISHER, COMMON.FLOWABLE, COMMON.RX2_ROOM)) { 2543c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar invocation -> 2553c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar val flowable = invocation.processingEnv.elementUtils 2563c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar .getTypeElement(RxJava2TypeNames.FLOWABLE.toString()) 2573c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar assertThat(flowable, notNullValue()) 2589fd8e6171bbdc37f5516fe15b2d96f4ae926ef1aChris Craik assertThat(FlowableQueryResultBinderProvider(invocation.context).matches( 2593c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar MoreTypes.asDeclared(flowable.asType())), `is`(true)) 2603c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar }.compilesWithoutError() 2613c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar } 2623c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar 2633c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar @Test 2643c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar fun testFindLiveData() { 2653c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar simpleRun(jfos = *arrayOf(COMMON.COMPUTABLE_LIVE_DATA, COMMON.LIVE_DATA)) { 2663c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar invocation -> 2673c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar val liveData = invocation.processingEnv.elementUtils 2683c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar .getTypeElement(LifecyclesTypeNames.LIVE_DATA.toString()) 2693c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar assertThat(liveData, notNullValue()) 2709fd8e6171bbdc37f5516fe15b2d96f4ae926ef1aChris Craik assertThat(LiveDataQueryResultBinderProvider(invocation.context).matches( 2713c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar MoreTypes.asDeclared(liveData.asType())), `is`(true)) 2723c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar }.compilesWithoutError() 2733c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar } 2743c592c4ccbc6052b11443b0fa575052c08fefa55Yigit Boyar 2759fd8e6171bbdc37f5516fe15b2d96f4ae926ef1aChris Craik @Test 276abd098954d3fe996f336201ccb25884aaa34e07fYigit Boyar fun findDataSource() { 2779fd8e6171bbdc37f5516fe15b2d96f4ae926ef1aChris Craik simpleRun { 2789fd8e6171bbdc37f5516fe15b2d96f4ae926ef1aChris Craik invocation -> 27924418e9aafa6ae3128ae47cf7087eda46dae4f5dChris Craik val dataSource = invocation.processingEnv.elementUtils 28024418e9aafa6ae3128ae47cf7087eda46dae4f5dChris Craik .getTypeElement(DataSource::class.java.canonicalName) 28124418e9aafa6ae3128ae47cf7087eda46dae4f5dChris Craik assertThat(dataSource, notNullValue()) 28224418e9aafa6ae3128ae47cf7087eda46dae4f5dChris Craik assertThat(DataSourceQueryResultBinderProvider(invocation.context).matches( 283abd098954d3fe996f336201ccb25884aaa34e07fYigit Boyar MoreTypes.asDeclared(dataSource.asType())), `is`(true)) 284abd098954d3fe996f336201ccb25884aaa34e07fYigit Boyar }.failsToCompile().withErrorContaining(ProcessorErrors.PAGING_SPECIFY_DATA_SOURCE_TYPE) 285abd098954d3fe996f336201ccb25884aaa34e07fYigit Boyar } 286abd098954d3fe996f336201ccb25884aaa34e07fYigit Boyar 287abd098954d3fe996f336201ccb25884aaa34e07fYigit Boyar @Test 288dc60cacc66972b47f27acdf727332878ce5958aeChris Craik fun findPositionalDataSource() { 289abd098954d3fe996f336201ccb25884aaa34e07fYigit Boyar simpleRun { 290abd098954d3fe996f336201ccb25884aaa34e07fYigit Boyar invocation -> 291abd098954d3fe996f336201ccb25884aaa34e07fYigit Boyar val dataSource = invocation.processingEnv.elementUtils 292dc60cacc66972b47f27acdf727332878ce5958aeChris Craik .getTypeElement(PositionalDataSource::class.java.canonicalName) 293abd098954d3fe996f336201ccb25884aaa34e07fYigit Boyar assertThat(dataSource, notNullValue()) 294abd098954d3fe996f336201ccb25884aaa34e07fYigit Boyar assertThat(DataSourceQueryResultBinderProvider(invocation.context).matches( 29524418e9aafa6ae3128ae47cf7087eda46dae4f5dChris Craik MoreTypes.asDeclared(dataSource.asType())), `is`(true)) 2969fd8e6171bbdc37f5516fe15b2d96f4ae926ef1aChris Craik }.compilesWithoutError() 2979fd8e6171bbdc37f5516fe15b2d96f4ae926ef1aChris Craik } 2989fd8e6171bbdc37f5516fe15b2d96f4ae926ef1aChris Craik 2999fd8e6171bbdc37f5516fe15b2d96f4ae926ef1aChris Craik @Test 300dc60cacc66972b47f27acdf727332878ce5958aeChris Craik fun findDataSourceFactory() { 301c21394d1dcb24518061aabde879baff891a426e3Sergey Vasilinets simpleRun(jfos = *arrayOf(COMMON.DATA_SOURCE_FACTORY)) { 3029fd8e6171bbdc37f5516fe15b2d96f4ae926ef1aChris Craik invocation -> 30324418e9aafa6ae3128ae47cf7087eda46dae4f5dChris Craik val pagedListProvider = invocation.processingEnv.elementUtils 304dc60cacc66972b47f27acdf727332878ce5958aeChris Craik .getTypeElement(PagingTypeNames.DATA_SOURCE_FACTORY.toString()) 30524418e9aafa6ae3128ae47cf7087eda46dae4f5dChris Craik assertThat(pagedListProvider, notNullValue()) 306dc60cacc66972b47f27acdf727332878ce5958aeChris Craik assertThat(DataSourceFactoryQueryResultBinderProvider(invocation.context).matches( 30724418e9aafa6ae3128ae47cf7087eda46dae4f5dChris Craik MoreTypes.asDeclared(pagedListProvider.asType())), `is`(true)) 3089fd8e6171bbdc37f5516fe15b2d96f4ae926ef1aChris Craik }.compilesWithoutError() 3099fd8e6171bbdc37f5516fe15b2d96f4ae926ef1aChris Craik } 3109fd8e6171bbdc37f5516fe15b2d96f4ae926ef1aChris Craik 311fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar private fun createIntListToStringBinders(invocation: TestInvocation): List<TypeConverter> { 312fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar val intType = invocation.processingEnv.elementUtils 313fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar .getTypeElement(Integer::class.java.canonicalName) 314fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar .asType() 315fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar val listType = invocation.processingEnv.elementUtils 316fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar .getTypeElement(java.util.List::class.java.canonicalName) 317fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar val listOfInts = invocation.processingEnv.typeUtils.getDeclaredType(listType, intType) 318fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar 319fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar val intListConverter = object : TypeConverter(listOfInts, 320fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar invocation.context.COMMON_TYPES.STRING) { 321fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar override fun convert(inputVarName: String, outputVarName: String, 322fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar scope: CodeGenScope) { 323fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar scope.builder().apply { 324fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar addStatement("$L = $T.joinIntoString($L)", outputVarName, STRING_UTIL, 325fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar inputVarName) 326fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar } 327fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar } 328fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar } 329fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar 330fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar val stringToIntListConverter = object : TypeConverter( 331fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar invocation.context.COMMON_TYPES.STRING, listOfInts) { 332fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar override fun convert(inputVarName: String, outputVarName: String, 333fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar scope: CodeGenScope) { 334fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar scope.builder().apply { 335fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar addStatement("$L = $T.splitToIntList($L)", outputVarName, STRING_UTIL, 336fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar inputVarName) 337fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar } 338fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar } 339fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar } 340fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar return listOf(intListConverter, stringToIntListConverter) 341fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar } 342fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar 3432259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar fun singleRun(handler: (TestInvocation) -> Unit): CompileTester { 3442259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar return Truth.assertAbout(JavaSourcesSubjectFactory.javaSources()) 3452259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar .that(listOf(JavaFileObjects.forSourceString("foo.bar.DummyClass", 3462259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar """ 3472259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar package foo.bar; 348ba069d50913c3fb250bb60ec310439db36895337Alan Viverette import androidx.room.*; 3492259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar @Entity 3502259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar public class DummyClass {} 3512259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar """ 3522259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar ), JavaFileObjects.forSourceString("foo.bar.Point", 3532259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar """ 3542259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar package foo.bar; 355ba069d50913c3fb250bb60ec310439db36895337Alan Viverette import androidx.room.*; 3562259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar @Entity 3572259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar public class Point { 3582259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar public int x, y; 3592259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar public Point(int x, int y) { 3602259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar this.x = x; 3612259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar this.y = y; 3622259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar } 3632259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar public static Point fromBoolean(boolean val) { 3642259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar return val ? new Point(1, 1) : new Point(0, 0); 3652259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar } 3662259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar public static boolean toBoolean(Point point) { 3672259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar return point.x > 0; 3682259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar } 3692259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar } 3702259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar """ 3712259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar ))) 3722259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar .processedWith(TestProcessor.builder() 3732259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar .forAnnotations(Entity::class) 3742259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar .nextRunHandler { invocation -> 3752259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar handler(invocation) 3762259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar true 3772259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar } 3782259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar .build()) 3792259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar } 3802259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar 381fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar fun pointTypeConverters(env: ProcessingEnvironment): List<TypeConverter> { 382fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar val tPoint = env.elementUtils.getTypeElement("foo.bar.Point").asType() 383fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar val tBoolean = env.typeUtils.getPrimitiveType(TypeKind.BOOLEAN) 384fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar return listOf( 385fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar object : TypeConverter(tPoint, tBoolean) { 386fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar override fun convert(inputVarName: String, outputVarName: String, 387fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar scope: CodeGenScope) { 388fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar scope.builder().apply { 389fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar addStatement("$L = $T.toBoolean($L)", outputVarName, from, inputVarName) 390fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar } 391fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar } 392fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar }, 393fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar object : TypeConverter(tBoolean, tPoint) { 394fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar override fun convert(inputVarName: String, outputVarName: String, 395fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar scope: CodeGenScope) { 396fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar scope.builder().apply { 397fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar addStatement("$L = $T.fromBoolean($L)", outputVarName, tPoint, 398fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar inputVarName) 399fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar } 400fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar } 401fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar } 402fb4fcc8caf2a1908843bd18298447ff6fc498896Yigit Boyar ) 4032259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar } 4041676c28584028f8427475745d7a779607af67ecbYigit Boyar 4051676c28584028f8427475745d7a779607af67ecbYigit Boyar fun dateTypeConverters(env: ProcessingEnvironment): List<TypeConverter> { 4061676c28584028f8427475745d7a779607af67ecbYigit Boyar val tDate = env.elementUtils.getTypeElement("java.util.Date").asType() 4071676c28584028f8427475745d7a779607af67ecbYigit Boyar val tLong = env.elementUtils.getTypeElement("java.lang.Long").asType() 4081676c28584028f8427475745d7a779607af67ecbYigit Boyar return listOf( 4091676c28584028f8427475745d7a779607af67ecbYigit Boyar object : TypeConverter(tDate, tLong) { 4101676c28584028f8427475745d7a779607af67ecbYigit Boyar override fun convert(inputVarName: String, outputVarName: String, 4111676c28584028f8427475745d7a779607af67ecbYigit Boyar scope: CodeGenScope) { 4121676c28584028f8427475745d7a779607af67ecbYigit Boyar scope.builder().apply { 4131676c28584028f8427475745d7a779607af67ecbYigit Boyar addStatement("// convert Date to Long") 4141676c28584028f8427475745d7a779607af67ecbYigit Boyar } 4151676c28584028f8427475745d7a779607af67ecbYigit Boyar } 4161676c28584028f8427475745d7a779607af67ecbYigit Boyar }, 4171676c28584028f8427475745d7a779607af67ecbYigit Boyar object : TypeConverter(tLong, tDate) { 4181676c28584028f8427475745d7a779607af67ecbYigit Boyar override fun convert(inputVarName: String, outputVarName: String, 4191676c28584028f8427475745d7a779607af67ecbYigit Boyar scope: CodeGenScope) { 4201676c28584028f8427475745d7a779607af67ecbYigit Boyar scope.builder().apply { 4211676c28584028f8427475745d7a779607af67ecbYigit Boyar addStatement("// convert Long to Date") 4221676c28584028f8427475745d7a779607af67ecbYigit Boyar } 4231676c28584028f8427475745d7a779607af67ecbYigit Boyar } 4241676c28584028f8427475745d7a779607af67ecbYigit Boyar } 4251676c28584028f8427475745d7a779607af67ecbYigit Boyar ) 4261676c28584028f8427475745d7a779607af67ecbYigit Boyar } 4272259e4dc433701d006db35df4c5e9f8d51e7d29bYigit Boyar} 428