File tree 2 files changed +8
-1
lines changed
main/java/com/google/api/client/util
test/java/com/google/api/client/util
2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ public class Data {
108
108
* @return magic object instance that represents the "null" value (not Java {@code null})
109
109
* @throws IllegalArgumentException if unable to create a new instance
110
110
*/
111
- public static <T > T nullOf (Class <? > objClass ) {
111
+ public static <T > T nullOf (Class <T > objClass ) {
112
112
// ConcurrentMap.computeIfAbsent is explicitly NOT used in the following logic. The
113
113
// ConcurrentHashMap implementation of that method BLOCKS if the mappingFunction triggers
114
114
// modification of the map which createNullInstance can do depending on the state of class
Original file line number Diff line number Diff line change 14
14
15
15
package com .google .api .client .util ;
16
16
17
+ import com .google .common .collect .ImmutableMap ;
17
18
import java .lang .reflect .ParameterizedType ;
18
19
import java .lang .reflect .Type ;
19
20
import java .lang .reflect .TypeVariable ;
@@ -68,6 +69,12 @@ public void testNullOf() {
68
69
}
69
70
}
70
71
72
+ public void testNullOfTemplateTypes () {
73
+ String nullValue = Data .nullOf (String .class );
74
+ Map <String , String > nullField = ImmutableMap .of ("v" , nullValue );
75
+ assertEquals (nullValue , nullField .get ("v" ));
76
+ }
77
+
71
78
public void testIsNull () {
72
79
assertTrue (Data .isNull (Data .NULL_BOOLEAN ));
73
80
assertTrue (Data .isNull (Data .NULL_STRING ));
You can’t perform that action at this time.
0 commit comments