/** * Method for constructing a marker type that indicates missing generic * type information, which is handled same as simple type for * <code>java.lang.Object</code>. * * @since 1.8 */ public static JavaType unknownType() { return defaultInstance()._unknownType(); }
private JavaType _mapType(Class<?> rawClass) { JavaType[] typeParams = findTypeParameters(rawClass, Map.class); // ok to have no types ("raw") if (typeParams == null) { return MapType.construct(rawClass, _unknownType(), _unknownType()); } // but exactly 2 types if any found if (typeParams.length != 2) { throw new IllegalArgumentException("Strange Map type "+rawClass.getName()+": can not determine type parameters"); } return MapType.construct(rawClass, typeParams[0], typeParams[1]); }
private JavaType _collectionType(Class<?> rawClass) { JavaType[] typeParams = findTypeParameters(rawClass, Collection.class); // ok to have no types ("raw") if (typeParams == null) { return CollectionType.construct(rawClass, _unknownType()); } // but exactly 2 types if any found if (typeParams.length != 1) { throw new IllegalArgumentException("Strange Collection type "+rawClass.getName()+": can not determine type parameters"); } return CollectionType.construct(rawClass, typeParams[0]); }
protected JavaType _resolveVariableViaSubTypes(HierarchicType leafType, String variableName, TypeBindings bindings) { // can't resolve raw types; possible to have as-of-yet-unbound types too: if (leafType != null && leafType.isGeneric()) { TypeVariable<?>[] typeVariables = leafType.getRawClass().getTypeParameters(); for (int i = 0, len = typeVariables.length; i < len; ++i) { TypeVariable<?> tv = typeVariables[i]; if (variableName.equals(tv.getName())) { // further resolution needed? Type type = leafType.asGeneric().getActualTypeArguments()[i]; if (type instanceof TypeVariable<?>) { return _resolveVariableViaSubTypes(leafType.getSubType(), ((TypeVariable<?>) type).getName(), bindings); } // no we're good for the variable (but it may have parameterization of its own) return _constructType(type, bindings); } } } return _unknownType(); }
keyType = paramTypes.get(0); contentType = (paramTypes.size() >= 2) ? paramTypes.get(1) : _unknownType(); return MapType.construct(clz, keyType, contentType);
/** * Method for constructing a marker type that indicates missing generic * type information, which is handled same as simple type for * <code>java.lang.Object</code>. * * @since 1.8 */ public static JavaType unknownType() { return defaultInstance()._unknownType(); }
private JavaType _mapType(Class<?> rawClass) { JavaType[] typeParams = findTypeParameters(rawClass, Map.class); // ok to have no types ("raw") if (typeParams == null) { return MapType.construct(rawClass, _unknownType(), _unknownType()); } // but exactly 2 types if any found if (typeParams.length != 2) { throw new IllegalArgumentException("Strange Map type "+rawClass.getName()+": can not determine type parameters"); } return MapType.construct(rawClass, typeParams[0], typeParams[1]); }
private JavaType _collectionType(Class<?> rawClass) { JavaType[] typeParams = findTypeParameters(rawClass, Collection.class); // ok to have no types ("raw") if (typeParams == null) { return CollectionType.construct(rawClass, _unknownType()); } // but exactly 2 types if any found if (typeParams.length != 1) { throw new IllegalArgumentException("Strange Collection type "+rawClass.getName()+": can not determine type parameters"); } return CollectionType.construct(rawClass, typeParams[0]); }
protected JavaType _resolveVariableViaSubTypes(HierarchicType leafType, String variableName, TypeBindings bindings) { // can't resolve raw types; possible to have as-of-yet-unbound types too: if (leafType != null && leafType.isGeneric()) { TypeVariable<?>[] typeVariables = leafType.getRawClass().getTypeParameters(); for (int i = 0, len = typeVariables.length; i < len; ++i) { TypeVariable<?> tv = typeVariables[i]; if (variableName.equals(tv.getName())) { // further resolution needed? Type type = leafType.asGeneric().getActualTypeArguments()[i]; if (type instanceof TypeVariable<?>) { return _resolveVariableViaSubTypes(leafType.getSubType(), ((TypeVariable<?>) type).getName(), bindings); } // no we're good for the variable (but it may have parameterization of its own) return _constructType(type, bindings); } } } return _unknownType(); }
keyType = paramTypes.get(0); contentType = (paramTypes.size() >= 2) ? paramTypes.get(1) : _unknownType(); return MapType.construct(clz, keyType, contentType);
/** * Method for constructing a marker type that indicates missing generic * type information, which is handled same as simple type for * <code>java.lang.Object</code>. * * @since 1.8 */ public static JavaType unknownType() { return defaultInstance()._unknownType(); }
/** * Method for constructing a marker type that indicates missing generic * type information, which is handled same as simple type for * <code>java.lang.Object</code>. * * @since 1.8 */ public static JavaType unknownType() { return defaultInstance()._unknownType(); }
/** * Method for constructing a marker type that indicates missing generic * type information, which is handled same as simple type for * <code>java.lang.Object</code>. * * @since 1.8 */ public static JavaType unknownType() { return defaultInstance()._unknownType(); }
private JavaType _mapType(Class<?> rawClass) { JavaType[] typeParams = findTypeParameters(rawClass, Map.class); // ok to have no types ("raw") if (typeParams == null) { return MapType.construct(rawClass, _unknownType(), _unknownType()); } // but exactly 2 types if any found if (typeParams.length != 2) { throw new IllegalArgumentException("Strange Map type "+rawClass.getName()+": can not determine type parameters"); } return MapType.construct(rawClass, typeParams[0], typeParams[1]); }
private JavaType _mapType(Class<?> rawClass) { JavaType[] typeParams = findTypeParameters(rawClass, Map.class); // ok to have no types ("raw") if (typeParams == null) { return MapType.construct(rawClass, _unknownType(), _unknownType()); } // but exactly 2 types if any found if (typeParams.length != 2) { throw new IllegalArgumentException("Strange Map type "+rawClass.getName()+": can not determine type parameters"); } return MapType.construct(rawClass, typeParams[0], typeParams[1]); }
private JavaType _mapType(Class<?> rawClass) { JavaType[] typeParams = findTypeParameters(rawClass, Map.class); // ok to have no types ("raw") if (typeParams == null) { return MapType.construct(rawClass, _unknownType(), _unknownType()); } // but exactly 2 types if any found if (typeParams.length != 2) { throw new IllegalArgumentException("Strange Map type "+rawClass.getName()+": can not determine type parameters"); } return MapType.construct(rawClass, typeParams[0], typeParams[1]); }
private JavaType _collectionType(Class<?> rawClass) { JavaType[] typeParams = findTypeParameters(rawClass, Collection.class); // ok to have no types ("raw") if (typeParams == null) { return CollectionType.construct(rawClass, _unknownType()); } // but exactly 2 types if any found if (typeParams.length != 1) { throw new IllegalArgumentException("Strange Collection type "+rawClass.getName()+": can not determine type parameters"); } return CollectionType.construct(rawClass, typeParams[0]); }
private JavaType _collectionType(Class<?> rawClass) { JavaType[] typeParams = findTypeParameters(rawClass, Collection.class); // ok to have no types ("raw") if (typeParams == null) { return CollectionType.construct(rawClass, _unknownType()); } // but exactly 2 types if any found if (typeParams.length != 1) { throw new IllegalArgumentException("Strange Collection type "+rawClass.getName()+": can not determine type parameters"); } return CollectionType.construct(rawClass, typeParams[0]); }