/** * Method that will force construction of a simple type, without trying to * check for more specialized types. *<p> * NOTE: no type modifiers are called on type either, so calling this method * should only be used if caller really knows what it's doing... * * @since 1.8 */ public JavaType uncheckedSimpleType(Class<?> cls) { return new SimpleType(cls); }
/** * Method used by core Jackson classes: NOT to be used by application code. *<p> * NOTE: public only because it is called by <code>ObjectMapper</code> which is * not in same package */ public static SimpleType constructUnsafe(Class<?> raw) { return new SimpleType(raw, null, null, null, null); }
@Override public SimpleType withValueHandler(Object h) { if (h == _valueHandler) { return this; } return new SimpleType(_class, _typeNames, _typeParameters, h, _typeHandler); }
@Override public SimpleType withTypeHandler(Object h) { return new SimpleType(_class, _typeNames, _typeParameters, _valueHandler, h); }
@Override protected JavaType _narrow(Class<?> subclass) { // Should we check that there is a sub-class relationship? return new SimpleType(subclass, _typeNames, _typeParameters, _valueHandler, _typeHandler); }
protected JavaType _unknownType() { return new SimpleType(Object.class); }
/** * Method for constructing a type instance with specified parameterization. * * @since 1.8 */ public JavaType constructSimpleType(Class<?> rawType, JavaType[] parameterTypes) { // Quick sanity check: must match numbers of types with expected... TypeVariable<?>[] typeVars = rawType.getTypeParameters(); if (typeVars.length != parameterTypes.length) { throw new IllegalArgumentException("Parameter type mismatch for "+rawType.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(); } JavaType resultType = new SimpleType(rawType, names, parameterTypes, null, null); return resultType; }
public static SimpleType construct(Class<?> cls) { /* Let's add sanity checks, just to ensure no * Map/Collection entries are constructed */ if (Map.class.isAssignableFrom(cls)) { throw new IllegalArgumentException("Can not construct SimpleType for a Map (class: "+cls.getName()+")"); } if (Collection.class.isAssignableFrom(cls)) { throw new IllegalArgumentException("Can not construct SimpleType for a Collection (class: "+cls.getName()+")"); } // ... and while we are at it, not array types either if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } return new SimpleType(cls); }
/** * @param context Mapping of formal parameter declarations (for generic * types) into actual types */ protected JavaType _fromClass(Class<?> clz, TypeBindings context) { // First: do we have an array type? if (clz.isArray()) { return ArrayType.construct(_constructType(clz.getComponentType(), null), null, null); } /* Also: although enums can also be fully resolved, there's little * point in doing so (T extends Enum<T>) etc. */ if (clz.isEnum()) { return new SimpleType(clz); } /* Maps and Collections aren't quite as hot; problem is, due * to type erasure we often do not know typing and can only assume * base Object. */ if (Map.class.isAssignableFrom(clz)) { return _mapType(clz); } if (Collection.class.isAssignableFrom(clz)) { return _collectionType(clz); } return new SimpleType(clz); }
return new SimpleType(clz); return new SimpleType(clz);
return new SimpleType(rawType);
@Override public SimpleType withTypeHandler(Object h) { return new SimpleType(_class, _typeNames, _typeParameters, _valueHandler, h); }
/** * Method used by core Jackson classes: NOT to be used by application code. *<p> * NOTE: public only because it is called by <code>ObjectMapper</code> which is * not in same package */ public static SimpleType constructUnsafe(Class<?> raw) { return new SimpleType(raw, null, null, null, null); }
@Override protected JavaType _narrow(Class<?> subclass) { // Should we check that there is a sub-class relationship? return new SimpleType(subclass, _typeNames, _typeParameters, _valueHandler, _typeHandler); }
@Override public SimpleType withValueHandler(Object h) { if (h == _valueHandler) { return this; } return new SimpleType(_class, _typeNames, _typeParameters, h, _typeHandler); }
/** * Method that will force construction of a simple type, without trying to * check for more specialized types. *<p> * NOTE: no type modifiers are called on type either, so calling this method * should only be used if caller really knows what it's doing... * * @since 1.8 */ public JavaType uncheckedSimpleType(Class<?> cls) { return new SimpleType(cls); }
protected JavaType _unknownType() { return new SimpleType(Object.class); }
/** * Method for constructing a type instance with specified parameterization. * * @since 1.8 */ public JavaType constructSimpleType(Class<?> rawType, JavaType[] parameterTypes) { // Quick sanity check: must match numbers of types with expected... TypeVariable<?>[] typeVars = rawType.getTypeParameters(); if (typeVars.length != parameterTypes.length) { throw new IllegalArgumentException("Parameter type mismatch for "+rawType.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(); } JavaType resultType = new SimpleType(rawType, names, parameterTypes, null, null); return resultType; }
public static SimpleType construct(Class<?> cls) { /* Let's add sanity checks, just to ensure no * Map/Collection entries are constructed */ if (Map.class.isAssignableFrom(cls)) { throw new IllegalArgumentException("Can not construct SimpleType for a Map (class: "+cls.getName()+")"); } if (Collection.class.isAssignableFrom(cls)) { throw new IllegalArgumentException("Can not construct SimpleType for a Collection (class: "+cls.getName()+")"); } // ... and while we are at it, not array types either if (cls.isArray()) { throw new IllegalArgumentException("Can not construct SimpleType for an array (class: "+cls.getName()+")"); } return new SimpleType(cls); }
/** * @param context Mapping of formal parameter declarations (for generic * types) into actual types */ protected JavaType _fromClass(Class<?> clz, TypeBindings context) { // First: do we have an array type? if (clz.isArray()) { return ArrayType.construct(_constructType(clz.getComponentType(), null), null, null); } /* Also: although enums can also be fully resolved, there's little * point in doing so (T extends Enum<T>) etc. */ if (clz.isEnum()) { return new SimpleType(clz); } /* Maps and Collections aren't quite as hot; problem is, due * to type erasure we often do not know typing and can only assume * base Object. */ if (Map.class.isAssignableFrom(clz)) { return _mapType(clz); } if (Collection.class.isAssignableFrom(clz)) { return _collectionType(clz); } return new SimpleType(clz); }