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