|
66 | 66 | */ |
67 | 67 | public class MapperImpl implements Mapper { |
68 | 68 |
|
69 | | - /** Marker object to signal that null is meant to be used as value. */ |
70 | | - public static final Object RETURN_NULL = new Object(); |
71 | | - |
72 | 69 | // --------- |
73 | 70 | // Fields and general configurable methods |
74 | 71 | // --------- |
@@ -125,13 +122,13 @@ public MapperImpl(@NotNull BeanDefinitionService beanDefinitionService, |
125 | 122 | // Step 1: attempt simple value transformation |
126 | 123 | Object exportValue = leafValueHandler.toExportValue(value, exportContext); |
127 | 124 | if (exportValue != null || value == null) { |
128 | | - return unwrapReturnNull(exportValue); |
| 125 | + return LeafValueHandler.unwrapReturnNull(exportValue); |
129 | 126 | } |
130 | 127 |
|
131 | 128 | // Step 2: handle special cases like Collection |
132 | 129 | exportValue = createExportValueForSpecialTypes(value, exportContext); |
133 | 130 | if (exportValue != null) { |
134 | | - return unwrapReturnNull(exportValue); |
| 131 | + return LeafValueHandler.unwrapReturnNull(exportValue); |
135 | 132 | } |
136 | 133 |
|
137 | 134 | // Step 3: treat as bean |
@@ -159,12 +156,12 @@ public MapperImpl(@NotNull BeanDefinitionService beanDefinitionService, |
159 | 156 |
|
160 | 157 | /** |
161 | 158 | * Handles values of types which need special handling (such as Optional). Null means the value is not |
162 | | - * a special type and that the export value should be built differently. Use {@link #RETURN_NULL} to |
| 159 | + * a special type and that the export value should be built differently. Use {@link LeafValueHandler#RETURN_NULL} to |
163 | 160 | * signal that null should be used as the export value of the provided value. |
164 | 161 | * |
165 | 162 | * @param value the value to convert |
166 | 163 | * @param exportContext export context |
167 | | - * @return the export value to use or {@link #RETURN_NULL}, or null if not applicable |
| 164 | + * @return the export value to use or {@link LeafValueHandler#RETURN_NULL}, or null if not applicable |
168 | 165 | */ |
169 | 166 | protected @Nullable Object createExportValueForSpecialTypes(@Nullable Object value, |
170 | 167 | @NotNull ExportContext exportContext) { |
@@ -192,16 +189,12 @@ public MapperImpl(@NotNull BeanDefinitionService beanDefinitionService, |
192 | 189 | Optional<?> optional = (Optional<?>) value; |
193 | 190 | return optional |
194 | 191 | .map(v -> toExportValue(v, exportContext.createChildContext(OPTIONAL_SPECIFIER))) |
195 | | - .orElse(RETURN_NULL); |
| 192 | + .orElse(LeafValueHandler.RETURN_NULL); |
196 | 193 | } |
197 | 194 |
|
198 | 195 | return null; |
199 | 196 | } |
200 | 197 |
|
201 | | - protected static @Nullable Object unwrapReturnNull(@Nullable Object o) { |
202 | | - return o == RETURN_NULL ? null : o; |
203 | | - } |
204 | | - |
205 | 198 | // --------- |
206 | 199 | // Bean mapping |
207 | 200 | // --------- |
|
0 commit comments