当前位置: 首页>>代码示例>>Java>>正文


Java ResolvableType.resolve方法代码示例

本文整理汇总了Java中org.springframework.core.ResolvableType.resolve方法的典型用法代码示例。如果您正苦于以下问题:Java ResolvableType.resolve方法的具体用法?Java ResolvableType.resolve怎么用?Java ResolvableType.resolve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.core.ResolvableType的用法示例。


在下文中一共展示了ResolvableType.resolve方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolveVariable

import org.springframework.core.ResolvableType; //导入方法依赖的package包/类
private static ResolvableType resolveVariable(TypeVariable<?> typeVariable, ResolvableType contextType) {
    ResolvableType resolvedType;
    if (contextType.hasGenerics()) {
        resolvedType = ResolvableType.forType(typeVariable, contextType);
        if (resolvedType.resolve() != null) {
            return resolvedType;
        }
    }

    ResolvableType superType = contextType.getSuperType();
    if (superType != ResolvableType.NONE) {
        resolvedType = resolveVariable(typeVariable, superType);
        if (resolvedType.resolve() != null) {
            return resolvedType;
        }
    }
    for (ResolvableType ifc : contextType.getInterfaces()) {
        resolvedType = resolveVariable(typeVariable, ifc);
        if (resolvedType.resolve() != null) {
            return resolvedType;
        }
    }
    return ResolvableType.NONE;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:FastJsonHttpMessageConverter.java

示例2: configureBeanGrid

import org.springframework.core.ResolvableType; //导入方法依赖的package包/类
@Bean
@Scope(scopeName = "prototype")
@SuppressWarnings("unchecked")
public <ITEM> Grid<ITEM> configureBeanGrid(DependencyDescriptor dependencyDescriptor) {
	logger.debug("Configuring Vaadin Grid as bean");

	long timestamp = System.currentTimeMillis();

	ResolvableType injectionPointType = dependencyDescriptor.getResolvableType();
	if (!injectionPointType.hasGenerics()) {
		throw new IllegalStateException("Grid injection point is expected to declare a static item type");
	}

	ResolvableType genericType = injectionPointType.getGeneric();
	Class<ITEM> itemType = (Class<ITEM>) genericType.resolve();

	logger.debug("Vaadin Grid will use " + itemType.getCanonicalName() + " as item type");

	Grid<ITEM> grid = configureGridInstance(itemType);
	long configTime = System.currentTimeMillis() - timestamp;
	logger.debug("Done configuring Grid for " + itemType.getName() + " in " + configTime + "ms");

	return grid;
}
 
开发者ID:peterl1084,项目名称:bean-grid,代码行数:25,代码来源:BeanGridConfiguration.java

示例3: getType

import org.springframework.core.ResolvableType; //导入方法依赖的package包/类
/**
 *
 * @param rt
 * @return
 */
protected static Type getType(final ResolvableType rt) {
    if (!rt.hasGenerics()) {
        return rt.resolve();
    } else {
        return new ParameterizedType() {
            public Type[] getActualTypeArguments() {
                Type[] ret = new Type[rt.getGenerics().length];
                for (int i = 0; i < ret.length; i++) {
                    ret[i] = getType(rt.getGenerics()[i]);
                }
                return ret;
            }

            public Type getRawType() {
                return rt.resolve();
            }

            public Type getOwnerType() {
                return null;
            }
        };
    }
}
 
开发者ID:brutusin,项目名称:Brutusin-RPC,代码行数:29,代码来源:RpcComponent.java

示例4: getType

import org.springframework.core.ResolvableType; //导入方法依赖的package包/类
private static Type getType(Type type, Class<?> contextClass) {
    if (contextClass != null) {
        ResolvableType resolvedType = ResolvableType.forType(type);
        if (type instanceof TypeVariable) {
            ResolvableType resolvedTypeVariable = resolveVariable((TypeVariable) type, ResolvableType.forClass(contextClass));
            if (resolvedTypeVariable != ResolvableType.NONE) {
                return resolvedTypeVariable.resolve();
            }
        } else if (type instanceof ParameterizedType && resolvedType.hasUnresolvableGenerics()) {
            ParameterizedType parameterizedType = (ParameterizedType) type;
            Class<?>[] generics = new Class[parameterizedType.getActualTypeArguments().length];
            Type[] typeArguments = parameterizedType.getActualTypeArguments();

            for (int i = 0; i < typeArguments.length; ++i) {
                Type typeArgument = typeArguments[i];
                if (typeArgument instanceof TypeVariable) {
                    ResolvableType resolvedTypeArgument = resolveVariable((TypeVariable) typeArgument, ResolvableType.forClass(contextClass));
                    if (resolvedTypeArgument != ResolvableType.NONE) {
                        generics[i] = resolvedTypeArgument.resolve();
                    } else {
                        generics[i] = ResolvableType.forType(typeArgument).resolve();
                    }
                } else {
                    generics[i] = ResolvableType.forType(typeArgument).resolve();
                }
            }

            return ResolvableType.forClassWithGenerics(resolvedType.getRawClass(), generics).getType();
        }
    }

    return type;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:34,代码来源:FastJsonHttpMessageConverter.java

示例5: getActualType

import org.springframework.core.ResolvableType; //导入方法依赖的package包/类
public static Class<?> getActualType(ResolvableType type){
	if(Publisher.class.isAssignableFrom(type.resolve())){
		return type.getGeneric(0).resolve();
	}else{
		return type.resolve();
	}
}
 
开发者ID:viniciusccarvalho,项目名称:spring-cloud-sockets,代码行数:8,代码来源:ServiceUtils.java

示例6: getRelatedIfResolvable

import org.springframework.core.ResolvableType; //导入方法依赖的package包/类
private static TypeDescriptor getRelatedIfResolvable(TypeDescriptor source, ResolvableType type) {
	if (type.resolve() == null) {
		return null;
	}
	return new TypeDescriptor(type, null, source.annotations);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:7,代码来源:TypeDescriptor.java

示例7: ConverterAdapter

import org.springframework.core.ResolvableType; //导入方法依赖的package包/类
public ConverterAdapter(Converter<?, ?> converter, ResolvableType sourceType, ResolvableType targetType) {
	this.converter = (Converter<Object, Object>) converter;
	this.typeInfo = new ConvertiblePair(sourceType.resolve(Object.class), targetType.resolve(Object.class));
	this.targetType = targetType;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:6,代码来源:GenericConversionService.java

示例8: TypeDescriptor

import org.springframework.core.ResolvableType; //导入方法依赖的package包/类
/**
 * Create a new type descriptor from a {@link ResolvableType}. This protected
 * constructor is used internally and may also be used by subclasses that support
 * non-Java languages with extended type systems.
 * @param resolvableType the resolvable type
 * @param type the backing type (or {@code null} if it should get resolved)
 * @param annotations the type annotations
 */
protected TypeDescriptor(ResolvableType resolvableType, Class<?> type, Annotation[] annotations) {
	this.resolvableType = resolvableType;
	this.type = (type != null ? type : resolvableType.resolve(Object.class));
	this.annotations = nullSafeAnnotations(annotations);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:14,代码来源:TypeDescriptor.java


注:本文中的org.springframework.core.ResolvableType.resolve方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。