@Override public JavaType getType() { return TypeFactory.unknownType(); }
/** * Internal helper method used to figure out nominal super-class for * deprecated factory methods / constructors, where we are not given * properly resolved supertype hierarchy. * Will basically give `JavaType` for `java.lang.Object` for classes * other than `java.lafgn.Object`; null for others. * * @since 2.7 */ protected static JavaType _bogusSuperClass(Class<?> cls) { Class<?> parent = cls.getSuperclass(); if (parent == null) { return null; } return TypeFactory.unknownType(); } }
/** * Method that can be used to construct "raw" Map type; meaning that its * parameterization is unknown. * This is similar to using <code>Object.class</code> parameterization, * and is equivalent to calling: *<pre> * typeFactory.constructMapType(collectionClass, typeFactory.unknownType(), typeFactory.unknownType()); *</pre> *<p> * This method should only be used if parameterization is completely unavailable. */ public MapType constructRawMapType(Class<? extends Map> mapClass) { return constructMapType(mapClass, unknownType(), unknownType()); }
/** * Method that can be used to construct "raw" Map-like type; meaning that its * parameterization is unknown. * This is similar to using <code>Object.class</code> parameterization, * and is equivalent to calling: *<pre> * typeFactory.constructMapLikeType(collectionClass, typeFactory.unknownType(), typeFactory.unknownType()); *</pre> *<p> * This method should only be used if parameterization is completely unavailable. */ public MapLikeType constructRawMapLikeType(Class<?> mapClass) { return constructMapLikeType(mapClass, unknownType(), unknownType()); }
@Override public JavaType getPrimaryType() { if (_member == null) { return TypeFactory.unknownType(); } return _member.getType(); }
/** * Accessor for declared type of contained value elements; either exact * type, or one of its supertypes. */ public JavaType getContentType() { if (_containerType == null) { return TypeFactory.unknownType(); // should never occur but... } return _containerType.getContentType(); }
public PlaceholderForType(int ordinal) { super(Object.class, TypeBindings.emptyBindings(), TypeFactory.unknownType(), null, 1, // super-class, super-interfaces, hashCode null, null, false); // value/type handler, as-static _ordinal = ordinal; }
/** * Method that can be used to construct "raw" Collection type; meaning that its * parameterization is unknown. * This is similar to using <code>Object.class</code> parameterization, * and is equivalent to calling: *<pre> * typeFactory.constructCollectionType(collectionClass, typeFactory.unknownType()); *</pre> *<p> * This method should only be used if parameterization is completely unavailable. */ public CollectionType constructRawCollectionType(Class<? extends Collection> collectionClass) { return constructCollectionType(collectionClass, unknownType()); }
/** * Method that can be used to construct "raw" Collection-like type; meaning that its * parameterization is unknown. * This is similar to using <code>Object.class</code> parameterization, * and is equivalent to calling: *<pre> * typeFactory.constructCollectionLikeType(collectionClass, typeFactory.unknownType()); *</pre> *<p> * This method should only be used if parameterization is completely unavailable. */ public CollectionLikeType constructRawCollectionLikeType(Class<?> collectionClass) { return constructCollectionLikeType(collectionClass, unknownType()); }
/** * Convenience method that is functionally same as: *<code> * JavaType t = containedType(index); * if (t == null) { * t = TypeFactory.unknownType(); * } *</code> * and typically used to eliminate need for null checks for common case * where we just want to check if containedType is available first; and * if not, use "unknown type" (which translates to <code>java.lang.Object</code> * basically). * * @since 2.5 */ public JavaType containedTypeOrUnknown(int index) { JavaType t = containedType(index); return (t == null) ? TypeFactory.unknownType() : t; }
/** * 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); }
/** * Reflection-based serialized find method, which checks if * given class implements one of recognized "add-on" interfaces. * Add-on here means a role that is usually or can be a secondary * trait: for example, * bean classes may implement {@link Iterable}, but their main * function is usually something else. The reason for */ protected final JsonSerializer<?> findSerializerByAddonType(SerializationConfig config, JavaType javaType, BeanDescription beanDesc, boolean staticTyping) throws JsonMappingException { Class<?> rawType = javaType.getRawClass(); if (Iterator.class.isAssignableFrom(rawType)) { JavaType[] params = config.getTypeFactory().findTypeParameters(javaType, Iterator.class); JavaType vt = (params == null || params.length != 1) ? TypeFactory.unknownType() : params[0]; return buildIteratorSerializer(config, javaType, beanDesc, staticTyping, vt); } if (Iterable.class.isAssignableFrom(rawType)) { JavaType[] params = config.getTypeFactory().findTypeParameters(javaType, Iterable.class); JavaType vt = (params == null || params.length != 1) ? TypeFactory.unknownType() : params[0]; return buildIterableSerializer(config, javaType, beanDesc, staticTyping, vt); } if (CharSequence.class.isAssignableFrom(rawType)) { return ToStringSerializer.instance; } return null; }
if (m == null) { return TypeFactory.unknownType(); m = getGetter(); if (m == null) { return TypeFactory.unknownType();
JavaType elemType = (tps == null || tps.length != 1) ? TypeFactory.unknownType() : tps[0]; CollectionType ct = tf.constructCollectionType(Collection.class, elemType);
JavaType unknown = TypeFactory.unknownType(); _mapDeserializer = (JsonDeserializer<Object>) ctxt.handleSecondaryContextualization(_mapDeserializer, null, unknown); _listDeserializer = (JsonDeserializer<Object>) ctxt.handleSecondaryContextualization(_listDeserializer, null, unknown);
@Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { if (_endpointDeserializer == null) { JavaType endpointType = _rangeType.containedType(0); if (endpointType == null) { // should this ever occur? endpointType = TypeFactory.unknownType(); } JsonDeserializer<Object> deser = ctxt.findContextualValueDeserializer(endpointType, property); return new RangeDeserializer(_rangeType, deser, _defaultBoundType); } return this; }
/** * Use Jackson ObjectMapper to read the transient 'many' property. */ void jsonReadUsingObjectMapper(BeanPropertyAssocMany<?> many, SpiJsonReader readJson, EntityBean parentBean) throws IOException { ObjectMapper mapper = readJson.getObjectMapper(); ManyType manyType = many.getManyType(); Object value; if (manyType.isMap()) { // read map using Jackson object mapper with unknown key type TypeFactory typeFactory = mapper.getTypeFactory(); JavaType target = typeFactory.constructType(many.getTargetType()); MapType jacksonType = typeFactory.constructMapType(LinkedHashMap.class, TypeFactory.unknownType(), target); value = mapper.readValue(readJson.getParser(), jacksonType); } else { // read list or set using Jackson object mapper CollectionType jacksonType = mapper.getTypeFactory().constructCollectionType(manyType.getCollectionType(), many.getTargetType()); value = mapper.readValue(readJson.getParser(), jacksonType); } many.setValue(parentBean, value); } }
@Deprecated // since 2.5; remove from 2.6 public JsonDeserializer<?> handlePrimaryContextualization(JsonDeserializer<?> deser, BeanProperty prop) throws JsonMappingException { return handlePrimaryContextualization(deser, prop, TypeFactory.unknownType()); }
private static void addMapping(String classId, Class<?> basicClass, Class<?> genericClass) { JavaType javaType = genericClass == null ? TypeFactory.defaultInstance().constructSpecializedType(unknownType(), basicClass) : TypeFactory.defaultInstance().constructParametricType(basicClass, genericClass); BASIC_MAPPING.put(classId, javaType); log.trace("Added mapping for polymorphic deserialization {} <-> {}", classId, javaType); }