-
-
Notifications
You must be signed in to change notification settings - Fork 221
/
TypeUtil.java
29 lines (27 loc) · 1017 Bytes
/
TypeUtil.java
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
package com.fasterxml.jackson.dataformat.xml.util;
import com.fasterxml.jackson.databind.JavaType;
public class TypeUtil
{
/**
* Helper method used for figuring out if given raw type is a collection ("indexed") type;
* in which case a wrapper element is typically added.
*/
public static boolean isIndexedType(JavaType type)
{
Class<?> cls = type.getRawClass();
if (type.isContainerType() || type.isIterationType()) {
// One special case; byte[] will be serialized as base64-encoded String, not real array, so:
// (actually, ditto for char[]; thought to be a String)
if (cls == byte[].class || cls == char[].class) {
return false;
}
// Also, should not add wrapping for Maps
// [dataformat-xml#220]: nor map-like (Scala Map) types
if (type.isMapLikeType()) {
return false;
}
return true;
}
return false;
}
}