xref: /aosp_15_r20/external/dagger2/javatests/dagger/functional/kotlinsrc/basic/PrimitivesModule.kt (revision f585d8a307d0621d6060bd7e80091fdcbf94fe27)
1 /*
2  * Copyright (C) 2022 The Dagger Authors.
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 dagger.functional.kotlinsrc.basic
18 
19 import dagger.Module
20 import dagger.Provides
21 
22 @Module
23 object PrimitivesModule {
24   const val BOUND_BYTE: Byte = -41
25   const val BOUND_CHAR = 'g'
26   const val BOUND_SHORT: Short = 21840
27   const val BOUND_INT = 1894833693
28   const val BOUND_LONG = -4369839828653523584L
29   const val BOUND_BOOLEAN = true
30   const val BOUND_FLOAT = 0.9964542f
31   const val BOUND_DOUBLE = 0.12681322049667765
32 
33   /*
34    * While we can't ensure that these constants stay constant, this is a test so we're just going to
35    * keep our fingers crossed that we're not going to be jerks.
36    */
37   val BOUND_BYTE_ARRAY = byteArrayOf(1, 2, 3)
38   val BOUND_CHAR_ARRAY = charArrayOf('g', 'a', 'k')
39   val BOUND_SHORT_ARRAY = shortArrayOf(2, 4)
40   val BOUND_INT_ARRAY = intArrayOf(3, 1, 2)
41   val BOUND_LONG_ARRAY = longArrayOf(1, 1, 2, 3, 5)
42   val BOUND_BOOLEAN_ARRAY = booleanArrayOf(false, true, false, false)
43   val BOUND_FLOAT_ARRAY = floatArrayOf(0.1f, 0.01f, 0.001f)
44   val BOUND_DOUBLE_ARRAY = doubleArrayOf(0.2, 0.02, 0.002)
45 
provideBytenull46   @Provides fun provideByte(): Byte = BOUND_BYTE
47   @Provides fun provideChar(): Char = BOUND_CHAR
48   @Provides fun provideShort(): Short = BOUND_SHORT
49   @Provides fun provideInt(): Int = BOUND_INT
50   @Provides fun provideLong(): Long = BOUND_LONG
51   @Provides fun provideBoolean(): Boolean = BOUND_BOOLEAN
52   @Provides fun provideFloat(): Float = BOUND_FLOAT
53   @Provides fun boundDouble(): Double = BOUND_DOUBLE
54   @Provides fun provideByteArray(): ByteArray = BOUND_BYTE_ARRAY
55   @Provides fun provideCharArray(): CharArray = BOUND_CHAR_ARRAY
56   @Provides fun provideShortArray(): ShortArray = BOUND_SHORT_ARRAY
57   @Provides fun provideIntArray(): IntArray = BOUND_INT_ARRAY
58   @Provides fun provideLongArray(): LongArray = BOUND_LONG_ARRAY
59   @Provides fun provideBooleanArray(): BooleanArray = BOUND_BOOLEAN_ARRAY
60   @Provides fun provideFloatArray(): FloatArray = BOUND_FLOAT_ARRAY
61   @Provides fun boundDoubleArray(): DoubleArray = BOUND_DOUBLE_ARRAY
62 }
63