1 /*
2  * Copyright 2019 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 @file:Suppress("deprecation")
18 
19 package sample.experimental
20 
21 import androidx.annotation.experimental.UseExperimental
22 
23 @Suppress("unused", "MemberVisibilityCanBePrivate")
24 class UseJavaExperimentalFromKt {
25     /** Unsafe call into an experimental class. */
getDateUnsafenull26     fun getDateUnsafe(): Int {
27         val dateProvider = DateProvider()
28         return dateProvider.date
29     }
30 
31     @ExperimentalDateTime
getDateExperimentalnull32     fun getDateExperimental(): Int {
33         val dateProvider = DateProvider()
34         return dateProvider.date
35     }
36 
37     @UseExperimental(ExperimentalDateTime::class)
getDateUseExperimentalnull38     fun getDateUseExperimental(): Int {
39         val dateProvider = DateProvider()
40         return dateProvider.date
41     }
42 
displayDatenull43     fun displayDate() {
44         println("" + getDateUnsafe())
45     }
46 
47     // Tests involving multiple experimental markers.
48 
49     /** Unsafe call into an experimental class. */
50     @ExperimentalDateTime
getDateExperimentalLocationUnsafenull51     fun getDateExperimentalLocationUnsafe(): Int {
52         val dateProvider = DateProvider()
53         val locationProvider = LocationProvider()
54         return dateProvider.date + locationProvider.location
55     }
56 
57     @ExperimentalDateTime
58     @ExperimentalLocation
getDateAndLocationExperimentalnull59     fun getDateAndLocationExperimental(): Int {
60         val dateProvider = DateProvider()
61         val locationProvider = LocationProvider()
62         return dateProvider.date + locationProvider.location
63     }
64 
65     @UseExperimental(ExperimentalDateTime::class)
66     @ExperimentalLocation
getDateUseExperimentalLocationExperimentalnull67     fun getDateUseExperimentalLocationExperimental(): Int {
68         val dateProvider = DateProvider()
69         val locationProvider = LocationProvider()
70         return dateProvider.date + locationProvider.location
71     }
72 
73     @UseExperimental(ExperimentalDateTime::class, ExperimentalLocation::class)
getDateAndLocationUseExperimentalnull74     fun getDateAndLocationUseExperimental(): Int {
75         val dateProvider = DateProvider()
76         val locationProvider = LocationProvider()
77         return dateProvider.date + locationProvider.location
78     }
79 }
80