1 /* 2 * Copyright (C) 2015 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; 18 19 import dagger.Module; 20 import dagger.Provides; 21 22 @Module 23 final class PrimitivesModule { 24 static final byte BOUND_BYTE = -41; 25 static final char BOUND_CHAR = 'g'; 26 static final short BOUND_SHORT = 21840; 27 static final int BOUND_INT = 1894833693; 28 static final long BOUND_LONG = -4369839828653523584L; 29 static final boolean BOUND_BOOLEAN = true; 30 static final float BOUND_FLOAT = (float) 0.9964542; 31 static final double 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 static final byte[] BOUND_BYTE_ARRAY = {1, 2, 3}; 38 static final char[] BOUND_CHAR_ARRAY = {'g', 'a', 'k'}; 39 static final short[] BOUND_SHORT_ARRAY = {2, 4}; 40 static final int[] BOUND_INT_ARRAY = {3, 1, 2}; 41 static final long[] BOUND_LONG_ARRAY = {1, 1, 2, 3, 5}; 42 static final boolean[] BOUND_BOOLEAN_ARRAY = {false, true, false, false}; 43 static final float[] BOUND_FLOAT_ARRAY = {(float) 0.1, (float) 0.01, (float) 0.001}; 44 static final double[] BOUND_DOUBLE_ARRAY = {0.2, 0.02, 0.002}; 45 provideByte()46 @Provides static byte provideByte() { 47 return BOUND_BYTE; 48 } 49 provideChar()50 @Provides static char provideChar() { 51 return BOUND_CHAR; 52 } 53 provideShort()54 @Provides static short provideShort() { 55 return BOUND_SHORT; 56 } 57 provideInt()58 @Provides static int provideInt() { 59 return BOUND_INT; 60 } 61 provideLong()62 @Provides static long provideLong() { 63 return BOUND_LONG; 64 } 65 provideBoolean()66 @Provides static boolean provideBoolean() { 67 return BOUND_BOOLEAN; 68 } 69 provideFloat()70 @Provides static float provideFloat() { 71 return BOUND_FLOAT; 72 } 73 boundDouble()74 @Provides static double boundDouble() { 75 return BOUND_DOUBLE; 76 } 77 provideByteArray()78 @Provides static byte[] provideByteArray() { 79 return BOUND_BYTE_ARRAY; 80 } 81 provideCharArray()82 @Provides static char[] provideCharArray() { 83 return BOUND_CHAR_ARRAY; 84 } 85 provideShortArray()86 @Provides static short[] provideShortArray() { 87 return BOUND_SHORT_ARRAY; 88 } 89 provideIntArray()90 @Provides static int[] provideIntArray() { 91 return BOUND_INT_ARRAY; 92 } 93 provideLongArray()94 @Provides static long[] provideLongArray() { 95 return BOUND_LONG_ARRAY; 96 } 97 provideBooleanArray()98 @Provides static boolean[] provideBooleanArray() { 99 return BOUND_BOOLEAN_ARRAY; 100 } 101 provideFloatArray()102 @Provides static float[] provideFloatArray() { 103 return BOUND_FLOAT_ARRAY; 104 } 105 boundDoubleArray()106 @Provides static double[] boundDoubleArray() { 107 return BOUND_DOUBLE_ARRAY; 108 } 109 } 110