forked from functionaljava/functionaljava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrimitive.java
More file actions
324 lines (251 loc) · 8.12 KB
/
Primitive.java
File metadata and controls
324 lines (251 loc) · 8.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
package fj;
/**
* Functions that convert between Java primitive types.
*
* @version %build.number%
*/
public final class Primitive {
private Primitive() {
throw new UnsupportedOperationException();
}
// BEGIN Boolean ->
/**
* A function that converts booleans to bytes.
*/
public static final F<Boolean, Byte> Boolean_Byte = b -> (byte) (b ? 1 : 0);
/**
* A function that converts booleans to characters.
*/
public static final F<Boolean, Character> Boolean_Character = b -> (char) (b ? 1 : 0);
/**
* A function that converts booleans to doubles.
*/
public static final F<Boolean, Double> Boolean_Double = b -> b ? 1D : 0D;
/**
* A function that converts booleans to floats.
*/
public static final F<Boolean, Float> Boolean_Float = b -> b ? 1F : 0F;
/**
* A function that converts booleans to integers.
*/
public static final F<Boolean, Integer> Boolean_Integer = b -> b ? 1 : 0;
/**
* A function that converts booleans to longs.
*/
public static final F<Boolean, Long> Boolean_Long = b -> b ? 1L : 0L;
/**
* A function that converts booleans to shorts.
*/
public static final F<Boolean, Short> Boolean_Short = b -> (short) (b ? 1 : 0);
// END Boolean ->
// BEGIN Byte ->
/**
* A function that converts bytes to booleans.
*/
public static final F<Byte, Boolean> Byte_Boolean = b -> b != 0;
/**
* A function that converts bytes to characters.
*/
public static final F<Byte, Character> Byte_Character = b -> (char) (byte) b;
/**
* A function that converts bytes to doubles.
*/
public static final F<Byte, Double> Byte_Double = b -> (double) b;
/**
* A function that converts bytes to floats.
*/
public static final F<Byte, Float> Byte_Float = b -> (float) b;
/**
* A function that converts bytes to integers.
*/
public static final F<Byte, Integer> Byte_Integer = b -> (int) b;
/**
* A function that converts bytes to longs.
*/
public static final F<Byte, Long> Byte_Long = b -> (long) b;
/**
* A function that converts bytes to shorts.
*/
public static final F<Byte, Short> Byte_Short = b -> (short) b;
// END Byte ->
// BEGIN Character ->
/**
* A function that converts characters to booleans.
*/
public static final F<Character, Boolean> Character_Boolean = c -> c != 0;
/**
* A function that converts characters to bytes.
*/
public static final F<Character, Byte> Character_Byte = c -> (byte) (char) c;
/**
* A function that converts characters to doubles.
*/
public static final F<Character, Double> Character_Double = c -> (double) (char) c;
/**
* A function that converts characters to floats.
*/
public static final F<Character, Float> Character_Float = c -> (float) (char) c;
/**
* A function that converts characters to integers.
*/
public static final F<Character, Integer> Character_Integer = c -> (int) (char) c;
/**
* A function that converts characters to longs.
*/
public static final F<Character, Long> Character_Long = c -> (long) (char) c;
/**
* A function that converts characters to shorts.
*/
public static final F<Character, Short> Character_Short = c -> (short) (char) c;
// END Character ->
// BEGIN Double ->
/**
* A function that converts doubles to booleans.
*/
public static final F<Double, Boolean> Double_Boolean = d -> d != 0D;
/**
* A function that converts doubles to bytes.
*/
public static final F<Double, Byte> Double_Byte = d -> (byte) (double) d;
/**
* A function that converts doubles to characters.
*/
public static final F<Double, Character> Double_Character = d -> (char) (double) d;
/**
* A function that converts doubles to floats.
*/
public static final F<Double, Float> Double_Float = d -> (float) (double) d;
/**
* A function that converts doubles to integers.
*/
public static final F<Double, Integer> Double_Integer = d -> (int) (double) d;
/**
* A function that converts doubles to longs.
*/
public static final F<Double, Long> Double_Long = d -> (long) (double) d;
/**
* A function that converts doubles to shorts.
*/
public static final F<Double, Short> Double_Short = d -> (short) (double) d;
// END Double ->
// BEGIN Float ->
/**
* A function that converts floats to booleans.
*/
public static final F<Float, Boolean> Float_Boolean = f -> f != 0F;
/**
* A function that converts floats to bytes.
*/
public static final F<Float, Byte> Float_Byte = f -> (byte) (float) f;
/**
* A function that converts floats to characters.
*/
public static final F<Float, Character> Float_Character = f -> (char) (float) f;
/**
* A function that converts floats to doubles.
*/
public static final F<Float, Double> Float_Double = f -> (double) (float) f;
/**
* A function that converts floats to integers.
*/
public static final F<Float, Integer> Float_Integer = f -> (int) (float) f;
/**
* A function that converts floats to longs.
*/
public static final F<Float, Long> Float_Long = f -> (long) (float) f;
/**
* A function that converts floats to shorts.
*/
public static final F<Float, Short> Float_Short = f -> (short) (float) f;
// END Float ->
// BEGIN Integer ->
/**
* A function that converts integers to booleans.
*/
public static final F<Integer, Boolean> Integer_Boolean = i -> i != 0;
/**
* A function that converts integers to bytes.
*/
public static final F<Integer, Byte> Integer_Byte = i -> (byte) (int) i;
/**
* A function that converts integers to characters.
*/
public static final F<Integer, Character> Integer_Character = i -> (char) (int) i;
/**
* A function that converts integers to doubles.
*/
public static final F<Integer, Double> Integer_Double = i -> (double) i;
/**
* A function that converts integers to floats.
*/
public static final F<Integer, Float> Integer_Float = i -> (float) i;
/**
* A function that converts integers to longs.
*/
public static final F<Integer, Long> Integer_Long = i -> (long) i;
/**
* A function that converts integers to shorts.
*/
public static final F<Integer, Short> Integer_Short = i -> (short) (int) i;
// END Integer ->
// BEGIN Long ->
/**
* A function that converts longs to booleans.
*/
public static final F<Long, Boolean> Long_Boolean = l -> l != 0L;
/**
* A function that converts longs to bytes.
*/
public static final F<Long, Byte> Long_Byte = l -> (byte) (long) l;
/**
* A function that converts longs to characters.
*/
public static final F<Long, Character> Long_Character = l -> (char) (long) l;
/**
* A function that converts longs to doubles.
*/
public static final F<Long, Double> Long_Double = l -> (double) (long) l;
/**
* A function that converts longs to floats.
*/
public static final F<Long, Float> Long_Float = l -> (float) (long) l;
/**
* A function that converts longs to integers.
*/
public static final F<Long, Integer> Long_Integer = l -> (int) (long) l;
/**
* A function that converts longs to shorts.
*/
public static final F<Long, Short> Long_Short = l -> (short) (long) l;
// END Long ->
// BEGIN Short ->
/**
* A function that converts shorts to booleans.
*/
public static final F<Short, Boolean> Short_Boolean = s -> s != 0;
/**
* A function that converts shorts to bytes.
*/
public static final F<Short, Byte> Short_Byte = s -> (byte) (short) s;
/**
* A function that converts shorts to characters.
*/
public static final F<Short, Character> Short_Character = s -> (char) (short) s;
/**
* A function that converts shorts to doubles.
*/
public static final F<Short, Double> Short_Double = s -> (double) (short) s;
/**
* A function that converts shorts to floats.
*/
public static final F<Short, Float> Short_Float = s -> (float) (short) s;
/**
* A function that converts shorts to integers.
*/
public static final F<Short, Integer> Short_Integer = s -> (int) (short) s;
/**
* A function that converts shorts to longs.
*/
public static final F<Short, Long> Short_Long = s -> (long) (short) s;
// END Short
}