1 /* 2 * Copyright 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package androidx.room.vo 18 19 import androidx.room.ext.CommonTypeNames 20 import androidx.room.ext.SupportDbTypeNames 21 import androidx.room.ext.typeName 22 import androidx.room.solver.query.result.QueryResultBinder 23 import com.squareup.javapoet.TypeName 24 import javax.lang.model.element.ExecutableElement 25 import javax.lang.model.type.TypeMirror 26 27 /** 28 * A class that holds information about a method annotated with RawQuery. 29 * It is self sufficient and must have all generics etc resolved once created. 30 */ 31 data class RawQueryMethod( 32 val element: ExecutableElement, 33 val name: String, 34 val returnType: TypeMirror, 35 val inTransaction: Boolean, 36 val observedTableNames: Set<String>, 37 val runtimeQueryParam: RuntimeQueryParameter?, 38 val queryResultBinder: QueryResultBinder) { 39 val returnsValue by lazy { 40 returnType.typeName() != TypeName.VOID 41 } 42 43 data class RuntimeQueryParameter( 44 val paramName: String, 45 val type: TypeName) { 46 fun isString() = CommonTypeNames.STRING == type 47 fun isSupportQuery() = SupportDbTypeNames.QUERY == type 48 } 49 } 50