1 /*
2  * Copyright (C) 2024 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 com.android.tools.metalava.model.api.surface
18 
19 import com.android.tools.metalava.model.Item
20 
21 /**
22  * The types of API variants.
23  *
24  * Each of these refers to a different variant of the API, where each variant has a unique set of
25  * criteria that determines which [Item]s in the API are part of the variant. e.g. [DOC_ONLY] only
26  * includes [Item]s that have `@doconly` specified. The intent is that every traversal of the API,
27  * e.g. when generating output files, will just specify the set of variants that it needs to visit.
28  *
29  * e.g. When generating the public API it will visit [CORE] in [ApiSurfaces.main] and there will be
30  * no [ApiSurfaces.base]. When generating the system API delta it will also visit [CORE] in
31  * [ApiSurfaces.main] even though there will be an [ApiSurfaces.base] (which represents the public
32  * API).
33  *
34  * Similarly, when generate the removed public API it will visit [REMOVED] in [ApiSurfaces.main] and
35  * there will be no [ApiSurfaces.base]. When generating the system API delta it will also visit
36  * [REMOVED] in [ApiSurfaces.main] even though there will be an [ApiSurfaces.base] (which represents
37  * the public API).
38  *
39  * When generating the public stubs it will visit [CORE] in [ApiSurfaces.main]. However, when
40  * generating the system stubs (which have to include the public stubs) it will visit [CORE] in both
41  * [ApiSurfaces.main] and [ApiSurfaces.base].
42  *
43  * When generating documentation stubs it will visit the same set as for stubs plus [DOC_ONLY] for
44  * each of the [ApiSurface]s.
45  */
46 enum class ApiVariantType(
47     /**
48      * Used in [ApiVariantSet.toString] to reduce the size of the string representation when
49      * debugging.
50      */
51     val shortCode: Char,
52 ) {
53     /** The core API that is used everywhere. */
54     CORE(shortCode = 'C'),
55 
56     /** The removed API items. */
57     REMOVED(shortCode = 'R'),
58 
59     /** Doc stub only items. */
60     DOC_ONLY(shortCode = 'D'),
61 }
62