File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed
main/java/com/google/api/client/util
test/java/com/google/api/client/util Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ public class Data {
108108 * @return magic object instance that represents the "null" value (not Java {@code null})
109109 * @throws IllegalArgumentException if unable to create a new instance
110110 */
111- public static <T > T nullOf (Class <? > objClass ) {
111+ public static <T > T nullOf (Class <T > objClass ) {
112112 // ConcurrentMap.computeIfAbsent is explicitly NOT used in the following logic. The
113113 // ConcurrentHashMap implementation of that method BLOCKS if the mappingFunction triggers
114114 // modification of the map which createNullInstance can do depending on the state of class
Original file line number Diff line number Diff line change 1414
1515package com .google .api .client .util ;
1616
17+ import com .google .common .collect .ImmutableMap ;
1718import java .lang .reflect .ParameterizedType ;
1819import java .lang .reflect .Type ;
1920import java .lang .reflect .TypeVariable ;
@@ -68,6 +69,12 @@ public void testNullOf() {
6869 }
6970 }
7071
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+
7178 public void testIsNull () {
7279 assertTrue (Data .isNull (Data .NULL_BOOLEAN ));
7380 assertTrue (Data .isNull (Data .NULL_STRING ));
You can’t perform that action at this time.
0 commit comments