1/* 2 * 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 17package androidx.lifecycle 18 19import androidx.lifecycle.model.EventMethod 20import javax.lang.model.element.TypeElement 21 22object ErrorMessages { 23 const val TOO_MANY_ARGS = "callback method cannot have more than 2 parameters" 24 const val TOO_MANY_ARGS_NOT_ON_ANY = "only callback annotated with ON_ANY " + 25 "can have 2 parameters" 26 const val INVALID_SECOND_ARGUMENT = "2nd argument of a callback method" + 27 " must be Lifecycle.Event and represent the current event" 28 const val INVALID_FIRST_ARGUMENT = "1st argument of a callback method must be " + 29 "a LifecycleOwner which represents the source of the event" 30 const val INVALID_METHOD_MODIFIER = "method marked with OnLifecycleEvent annotation can " + 31 "not be private" 32 const val INVALID_CLASS_MODIFIER = "class containing OnLifecycleEvent methods can not be " + 33 "private" 34 const val INVALID_STATE_OVERRIDE_METHOD = "overridden method must handle the same " + 35 "onState changes as original method" 36 const val INVALID_ENCLOSING_ELEMENT = 37 "Parent of OnLifecycleEvent should be a class or interface" 38 const val INVALID_ANNOTATED_ELEMENT = "OnLifecycleEvent can only be added to methods" 39 40 fun failedToGenerateAdapter(type: TypeElement, failureReason: EventMethod) = 41 """ 42 Failed to generate an Adapter for $type, because it needs to be able to access to 43 package private method ${failureReason.method.name()} from ${failureReason.type} 44 """.trim() 45} 46