|
1 | 1 | public class GenericFunctions
|
2 | 2 | {
|
3 |
| - public static <T> void processSimpleGeneric(Generic<T> x) |
| 3 | + |
| 4 | + //Methods with generic inputs |
| 5 | + public static <T> void processSimple(Generic<T> x) |
4 | 6 | {
|
5 | 7 |
|
6 | 8 | }
|
7 | 9 |
|
8 |
| - // Test a wildcard generic bound by an interface |
9 |
| - public static <T extends Interface> void processUpperBoundInterfaceGeneric(Generic<T> x) |
| 10 | + public static <T extends Interface> void processUpperBoundInterface(Generic<T> x) |
10 | 11 | {
|
11 | 12 |
|
12 | 13 | }
|
13 | 14 |
|
14 |
| - // Test a wild card generic bound by a class |
15 |
| - public static <T extends Interface_Implementation> void processUpperBoundClassGeneric(Generic<T> x) |
| 15 | + public static <T extends Interface_Implementation> void processUpperBoundClass(Generic<T> x) |
16 | 16 | {
|
17 | 17 |
|
18 | 18 | }
|
19 | 19 |
|
20 |
| - // Test a wild card generic bound by a class and an interface |
21 |
| - public static <T extends Interface_Implementation & Interface> void processDoubleUpperBoundClassGeneric(Generic<T> x) |
| 20 | + public static <T extends Interface_Implementation & Interface> void processDoubleUpperBoundClass(Generic<T> x) |
22 | 21 | {
|
23 | 22 |
|
24 | 23 | }
|
25 | 24 |
|
26 |
| - // Test a wild card generic bound by two interfaces |
27 |
| - public static <T extends Interface & Interface_Copy> void processDoubleUpperBoundInterfaceGeneric(Generic<T> x) |
| 25 | + public static <T extends Interface & Interface_Copy> void processDoubleUpperBoundInterface(Generic<T> x) |
28 | 26 | {
|
29 | 27 |
|
30 | 28 | }
|
| 29 | + |
| 30 | + public static <T,U> void processMultipleSimple(Generic<T> t, Generic<U> u) |
| 31 | + { |
| 32 | + |
| 33 | + } |
| 34 | + |
| 35 | + public static <T extends Interface,U extends Interface_Implementation & Interface> void processMultipleUpperBound(Generic<T> t, Generic<U> u) |
| 36 | + { |
| 37 | + |
| 38 | + } |
| 39 | + |
| 40 | + //Methods with generic output |
| 41 | + public static <T> Generic<T> returnSimple() |
| 42 | + { |
| 43 | + Generic<T> x=new Generic<T>(); |
| 44 | + return x; |
| 45 | + } |
| 46 | + |
| 47 | + public static <T> T returnSimpleField() |
| 48 | + { |
| 49 | + Generic<T> x=new Generic<T>(); |
| 50 | + return x.t; |
| 51 | + } |
| 52 | + |
| 53 | + public static <T extends Interface> Generic<T> returnUpperBoundInterface() |
| 54 | + { |
| 55 | + Generic<T> x=new Generic<T>(); |
| 56 | + return x; |
| 57 | + } |
| 58 | + |
| 59 | + public static <T extends Interface_Implementation> Generic<T> returnUpperBoundClass() |
| 60 | + { |
| 61 | + Generic<T> x=new Generic<T>(); |
| 62 | + return x; |
| 63 | + } |
| 64 | + |
| 65 | + public static <T extends Interface_Implementation & Interface> Generic<T> returnDoubleUpperBoundClass() |
| 66 | + { |
| 67 | + Generic<T> x=new Generic<T>(); |
| 68 | + return x; |
| 69 | + } |
| 70 | + |
| 71 | + public static <T extends Interface & Interface_Copy> Generic<T> returnDoubleUpperBoundInterface() |
| 72 | + { |
| 73 | + Generic<T> x=new Generic<T>(); |
| 74 | + return x; |
| 75 | + } |
| 76 | + |
| 77 | + //Methods with generic input and output |
| 78 | + public static <T> Generic<T> processReturnSimpleSame(Generic<T> x) |
| 79 | + { |
| 80 | + return x; |
| 81 | + } |
| 82 | + |
| 83 | + public static <T extends Interface> Generic<T> processReturnUpperBoundInterfaceSame(Generic<T> x) |
| 84 | + { |
| 85 | + return x; |
| 86 | + } |
| 87 | + |
| 88 | + public static <T extends Interface_Implementation> Generic<T> processReturnUpperBoundClassSame(Generic<T> x) |
| 89 | + { |
| 90 | + return x; |
| 91 | + } |
| 92 | + |
| 93 | + public static <T extends Interface_Implementation & Interface> Generic<T> processReturnDoubleUpperBoundClassSame(Generic<T> x) |
| 94 | + { |
| 95 | + return x; |
| 96 | + } |
| 97 | + |
| 98 | + public static <T extends Interface & Interface_Copy> Generic<T> processReturnDoubleUpperBoundInterfaceSame(Generic<T> x) |
| 99 | + { |
| 100 | + return x; |
| 101 | + } |
| 102 | + |
| 103 | + public static <T,U> Generic<T> processReturnSimpleDifferent(Generic<U> u) |
| 104 | + { |
| 105 | + Generic<T> t=new Generic<T>(); |
| 106 | + return t; |
| 107 | + } |
| 108 | + |
| 109 | + public static <T extends Interface,U extends Interface_Implementation & Interface> Generic<T> processReturnUpperBoundDifferent(Generic<U> u) |
| 110 | + { |
| 111 | + Generic<T> t=new Generic<T>(); |
| 112 | + return t; |
| 113 | + } |
| 114 | + |
| 115 | + public static <T,U,V> Generic<T> processReturnMultipleSimpleDifferent(Generic<U> u, Generic<V> v) |
| 116 | + { |
| 117 | + Generic<T> t=new Generic<T>(); |
| 118 | + return t; |
| 119 | + } |
| 120 | + |
| 121 | + public static <T extends Interface,U extends Interface_Implementation & Interface, V extends Interface_Copy> Generic<T> processReturnMultipleUpperBoundDifferent(Generic<U> u, Generic<V> v) |
| 122 | + { |
| 123 | + Generic<T> t=new Generic<T>(); |
| 124 | + return t; |
| 125 | + } |
31 | 126 | }
|
0 commit comments