Home | History | Annotate | Download | only in processor
      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.processor
     18 
     19 import androidx.room.vo.PojoMethod
     20 import com.google.auto.common.MoreTypes
     21 import javax.lang.model.element.ExecutableElement
     22 import javax.lang.model.type.DeclaredType
     23 
     24 /**
     25  * processes an executable element as member of the owning class
     26  */
     27 class PojoMethodProcessor(
     28         private val context: Context,
     29         private val element: ExecutableElement,
     30         private val owner: DeclaredType) {
     31     fun process(): PojoMethod {
     32         val asMember = context.processingEnv.typeUtils.asMemberOf(owner, element)
     33         val name = element.simpleName.toString()
     34         return PojoMethod(
     35                 element = element,
     36                 resolvedType = MoreTypes.asExecutable(asMember),
     37                 name = name
     38         )
     39     }
     40 }