1 package com.fasterxml.jackson.databind.type;
2
3 import java.lang.reflect.TypeVariable;
4
5 import com.fasterxml.jackson.databind.JavaType;
6
7
10 public final class CollectionType
11 extends CollectionLikeType
12 {
13 private static final long serialVersionUID = 1L;
14
15
20
21 private CollectionType(Class<?> collT, TypeBindings bindings,
22 JavaType superClass, JavaType[] superInts, JavaType elemT,
23 Object valueHandler, Object typeHandler, boolean asStatic)
24 {
25 super(collT, bindings, superClass, superInts, elemT, valueHandler, typeHandler, asStatic);
26 }
27
28
31 protected CollectionType(TypeBase base, JavaType elemT) {
32 super(base, elemT);
33 }
34
35
38 public static CollectionType construct(Class<?> rawType, TypeBindings bindings,
39 JavaType superClass, JavaType[] superInts, JavaType elemT) {
40 return new CollectionType(rawType, bindings, superClass, superInts, elemT,
41 null, null, false);
42 }
43
44
47 @Deprecated
48 public static CollectionType construct(Class<?> rawType, JavaType elemT) {
49
50
51 TypeVariable<?>[] vars = rawType.getTypeParameters();
52 TypeBindings bindings;
53 if ((vars == null) || (vars.length != 1)) {
54 bindings = TypeBindings.emptyBindings();
55 } else {
56 bindings = TypeBindings.create(rawType, elemT);
57 }
58 return new CollectionType(rawType, bindings,
59
60 _bogusSuperClass(rawType), null, elemT,
61 null, null, false);
62 }
63
64 @Deprecated
65 @Override
66 protected JavaType _narrow(Class<?> subclass) {
67 return new CollectionType(subclass, _bindings,
68 _superClass, _superInterfaces, _elementType, null, null, _asStatic);
69 }
70
71 @Override
72 public JavaType withContentType(JavaType contentType) {
73 if (_elementType == contentType) {
74 return this;
75 }
76 return new CollectionType(_class, _bindings, _superClass, _superInterfaces,
77 contentType, _valueHandler, _typeHandler, _asStatic);
78 }
79
80 @Override
81 public CollectionType withTypeHandler(Object h) {
82 return new CollectionType(_class, _bindings,
83 _superClass, _superInterfaces, _elementType, _valueHandler, h, _asStatic);
84 }
85
86 @Override
87 public CollectionType withContentTypeHandler(Object h)
88 {
89 return new CollectionType(_class, _bindings,
90 _superClass, _superInterfaces, _elementType.withTypeHandler(h),
91 _valueHandler, _typeHandler, _asStatic);
92 }
93
94 @Override
95 public CollectionType withValueHandler(Object h) {
96 return new CollectionType(_class, _bindings,
97 _superClass, _superInterfaces, _elementType, h, _typeHandler, _asStatic);
98 }
99
100 @Override
101 public CollectionType withContentValueHandler(Object h) {
102 return new CollectionType(_class, _bindings,
103 _superClass, _superInterfaces, _elementType.withValueHandler(h),
104 _valueHandler, _typeHandler, _asStatic);
105 }
106
107 @Override
108 public CollectionType withStaticTyping() {
109 if (_asStatic) {
110 return this;
111 }
112 return new CollectionType(_class, _bindings,
113 _superClass, _superInterfaces, _elementType.withStaticTyping(),
114 _valueHandler, _typeHandler, true);
115 }
116
117 @Override
118 public JavaType refine(Class<?> rawType, TypeBindings bindings,
119 JavaType superClass, JavaType[] superInterfaces) {
120 return new CollectionType(rawType, bindings,
121 superClass, superInterfaces, _elementType,
122 _valueHandler, _typeHandler, _asStatic);
123 }
124
125
130
131 @Override
132 public String toString()
133 {
134 return "[collection type; class "+_class.getName()+", contains "+_elementType+"]";
135 }
136 }
137