-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathCoercions.java
More file actions
107 lines (83 loc) · 2.36 KB
/
Copy pathCoercions.java
File metadata and controls
107 lines (83 loc) · 2.36 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
package org.python.tests;
import java.io.Serializable;
import org.python.core.PyObject;
/**
* Called in various forms by test_java_visibility.CoercionsTest to see if Python wrapped Java types
* are unwrapped to the correct call.
*/
public class Coercions {
public String takeInt(int i) {
return "" + i;
}
public String takeInteger(Integer i) {
return "" + i;
}
public String takeNumber(Number n) {
return "" + n;
}
public String takePyObjInst(PyObject[] args) {
return "" + args.length;
}
public static String takeArray(float[] f) {
return "float";
}
public static String takeArray(double[] d) {
return "double";
}
public static String takePyObj(PyObject[] args) {
return "" + args.length;
}
public static String takeArray(Object[] obj) {
return "Object[]";
}
// Not really an array, but we want to make sure Python code doesn't pick up on it
// inappropriately.
public static String takeArray(Object obj) {
return "Object";
}
public static String takeArray(SubVisible[] vis) {
return "SubVisible[]";
}
public static String takeArray(OtherSubVisible[] vis) {
return "OtherSubVisible[]";
}
public static String takeArray(Visible[] vis) {
return "Visible[]";
}
public String tellClassNameObject(Object o) {
return o.getClass().toString();
}
public String tellClassNameSerializable(Serializable o) {
return o.getClass().toString();
}
public static String take(int i) {
return "take with int arg: " + i;
}
public static String take(char c) {
return "take with char arg: " + c;
}
public static String take(boolean b) {
return "take with boolean arg: " + b;
}
public static String take(byte bt) {
return "take with byte arg: " + bt;
}
public static int takeIterable(Iterable<Integer> it) {
int sum = 0;
for (Integer integer : it) {
sum += integer;
}
return sum;
}
public static boolean takeBoolIterable(Iterable<Boolean> it) {
for (Boolean integer : it) {
if (!integer) {
return false;
}
}
return true;
}
public static void runRunnable(Runnable r){
r.run();
}
}