Refine search
@Override public JavaType getValueType() { return SimpleType.construct(String.class); }
/** * Customized {@link TypeResolverBuilder} that provides type resolver builders * used with so-called "default typing" * (see {@link ObjectMapper#enableDefaultTyping()} for details). *<p> * Type resolver construction is based on configuration: implementation takes care * of only providing builders in cases where type information should be applied. * This is important since build calls may be sent for any and all types, and * type information should NOT be applied to all of them. */ public static class DefaultTypeResolverBuilder extends StdTypeResolverBuilder implements java.io.Serializable { private static final long serialVersionUID = 1L; /** * Definition of what types is this default typer valid for. */ protected final DefaultTyping _appliesFor; public DefaultTypeResolverBuilder(DefaultTyping t) { _appliesFor = t; } @Override public TypeDeserializer buildTypeDeserializer(DeserializationConfig config, JavaType baseType, Collection<NamedType> subtypes) { return useForType(baseType) ? super.buildTypeDeserializer(config, baseType, subtypes) : null;
/** * Helper method we need to recursively build skeletal representations * of superclasses. * * @since 2.7 -- remove when not needed (2.8?) */ private static JavaType _buildSuperClass(Class<?> superClass, TypeBindings b) { if (superClass == null) { return null; } if (superClass == Object.class) { return TypeFactory.unknownType(); } JavaType superSuper = _buildSuperClass(superClass.getSuperclass(), b); return new SimpleType(superClass, b, superSuper, null, null, null, false); }
@Override public StringBuilder getGenericSignature(StringBuilder sb) { _classSignature(_class, sb, false); final int count = _bindings.size(); if (count > 0) { sb.append('<'); for (int i = 0; i < count; ++i) { sb = containedType(i).getGenericSignature(sb); } sb.append('>'); } sb.append(';'); return sb; }
return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); return new SimpleType(subclass, _bindings, this, _superInterfaces, _valueHandler, _typeHandler, _asStatic); JavaType superb = _narrow(next); return new SimpleType(subclass, _bindings, superb, null, _valueHandler, _typeHandler, _asStatic); for (Class<?> iface : nextI) { if (iface == _class) { // directly implemented return new SimpleType(subclass, _bindings, null, new JavaType[] { this }, _valueHandler, _typeHandler, _asStatic); JavaType superb = _narrow(iface); return new SimpleType(subclass, _bindings, null, new JavaType[] { superb }, _valueHandler, _typeHandler, _asStatic);
final JavaType javaType = TypeFactory.defaultInstance().constructType(responseType); if (!isVoid(javaType)) { final JavaType futureType = TypeFactory.defaultInstance().constructType(javaType.containedType(0)); responseType = futureType.containedType(0); type = simpleType.containedType(0);
result = ArrayType.construct(_constructType(clz.getComponentType(), null), null, null); result = new SimpleType(clz); result = _mapType(clz); } else if (Collection.class.isAssignableFrom(clz)) { result = _collectionType(clz); } else { result = constructSimpleType(clz, Map.Entry.class, new JavaType[] { kt, vt }); } else { result = new SimpleType(clz);
return ArrayType.construct(_constructType(clz.getComponentType(), null), null, null); return new SimpleType(clz); keyType = paramTypes.get(0); contentType = (paramTypes.size() >= 2) ? paramTypes.get(1) : _unknownType(); return MapType.construct(clz, keyType, contentType); return _mapType(clz); return new SimpleType(clz);
pt = new JavaType[paramCount]; for (int i = 0; i < paramCount; ++i) { pt[i] = _constructType(args[i], context); JavaType subtype = constructSimpleType(rawType, pt); JavaType[] mapParams = findTypeParameters(subtype, Map.class); if (mapParams.length != 2) { throw new IllegalArgumentException("Could not find 2 type parameters for Map class "+rawType.getName()+" (found "+mapParams.length+")"); return new SimpleType(rawType); return constructSimpleType(rawType, pt);
@Override public JavaType handleUnknownTypeId(DeserializationContext ctxt, JavaType baseType, String subTypeId, TypeIdResolver idResolver, String failureMsg) throws IOException { if (baseType.getRawClass().equals(RetentionStrategyConfig.class)) { return SimpleType.constructUnsafe(UnknownRetentionStrategyConfig.class); } return super.handleUnknownTypeId(ctxt, baseType, subTypeId, idResolver, failureMsg); } }
result = ArrayType.construct(_constructType(clz.getComponentType(), null), null, null); result = new SimpleType(clz); result = _mapType(clz); } else if (Collection.class.isAssignableFrom(clz)) { result = _collectionType(clz); } else { result = new SimpleType(clz);
public JavaType constructSimpleType(Class<?> rawType, Class<?> parameterTarget, JavaType[] parameterTypes) { // Quick sanity check: must match numbers of types with expected... TypeVariable<?>[] typeVars = parameterTarget.getTypeParameters(); if (typeVars.length != parameterTypes.length) { throw new IllegalArgumentException("Parameter type mismatch for "+rawType.getName() +" (and target "+parameterTarget.getName()+"): expected "+typeVars.length +" parameters, was given "+parameterTypes.length); } String[] names = new String[typeVars.length]; for (int i = 0, len = typeVars.length; i < len; ++i) { names[i] = typeVars[i].getName(); } return new SimpleType(rawType, names, parameterTypes, null, null, false, parameterTarget); }
@Override public SimpleType withValueHandler(Object h) { if (h == _valueHandler) { return this; } return new SimpleType(_class, _bindings, _superClass, _superInterfaces, h, _typeHandler, _asStatic); }
@Override public StringBuilder getErasedSignature(StringBuilder sb) { return _classSignature(_class, sb, true); }
@Override public String toString() { StringBuilder sb = new StringBuilder(40); sb.append("[simple type, class ").append(buildCanonicalName()).append(']'); return sb.toString(); }
/** * @param type the property type * @return true if a byte array */ private boolean isByteArray(final Type type) { boolean ret = type instanceof Class && type == byte[].class; if (!ret && type instanceof ArrayType) { ArrayType at = (ArrayType) type; JavaType contentType = at.getContentType(); if (contentType instanceof SimpleType) { SimpleType st = (SimpleType) contentType; ret = st.getRawClass() == byte.class; } } return ret; } }
return new SimpleType(cls, b, _buildSuperClass(cls.getSuperclass(), b), null, null, null, false);
@Override protected String buildCanonicalName() { StringBuilder sb = new StringBuilder(); sb.append(_class.getName()); final int count = _bindings.size(); if (count > 0) { sb.append('<'); for (int i = 0; i < count; ++i) { JavaType t = containedType(i); if (i > 0) { sb.append(','); } sb.append(t.toCanonical()); } sb.append('>'); } return sb.toString(); }
result = ArrayType.construct(_constructType(clz.getComponentType(), null), null, null); result = new SimpleType(clz); result = _mapType(clz); } else if (Collection.class.isAssignableFrom(clz)) { result = _collectionType(clz); } else { result = constructSimpleType(clz, Map.Entry.class, new JavaType[] { kt, vt }); } else { result = new SimpleType(clz);
return ArrayType.construct(_constructType(clz.getComponentType(), null), null, null); return new SimpleType(clz); keyType = paramTypes.get(0); contentType = (paramTypes.size() >= 2) ? paramTypes.get(1) : _unknownType(); return MapType.construct(clz, keyType, contentType); return _mapType(clz); return new SimpleType(clz);