1 /* <lambda>null2 * Copyright (C) 2017 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.lifecycle.model 18 19 import androidx.lifecycle.name 20 import androidx.lifecycle.syntheticName 21 import javax.lang.model.element.ExecutableElement 22 import javax.lang.model.element.TypeElement 23 24 data class InputModel( 25 // all java files with lifecycle annotations excluding classes from classpath 26 private val rootTypes: Set<TypeElement>, 27 // info about all lifecycle observers including classes from classpath 28 val observersInfo: Map<TypeElement, LifecycleObserverInfo>, 29 // info about generated adapters from class path 30 val generatedAdapters: Map<TypeElement, List<ExecutableElement>> 31 ) { 32 33 /** Root class is class defined in currently processed module, not in classpath */ 34 fun isRootType(type: TypeElement) = type in rootTypes 35 36 fun hasSyntheticAccessorFor(eventMethod: EventMethod): Boolean { 37 val syntheticMethods = generatedAdapters[eventMethod.type] ?: return false 38 return syntheticMethods.any { executable -> 39 executable.name() == syntheticName(eventMethod.method) && 40 // same number + receiver object 41 (eventMethod.method.parameters.size + 1) == executable.parameters.size 42 } 43 } 44 } 45