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


Java ResolvableType.hasUnresolvableGenerics方法代码示例

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


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

示例1: 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

示例2: supportsEventType

import org.springframework.core.ResolvableType; //导入方法依赖的package包/类
@Override
public boolean supportsEventType(ResolvableType eventType) {
	for (ResolvableType declaredEventType : this.declaredEventTypes) {
		if (declaredEventType.isAssignableFrom(eventType)) {
			return true;
		}
		else if (PayloadApplicationEvent.class.isAssignableFrom(eventType.getRawClass())) {
			ResolvableType payloadType = eventType.as(PayloadApplicationEvent.class).getGeneric();
			if (declaredEventType.isAssignableFrom(payloadType)) {
				return true;
			}
		}
	}
	return eventType.hasUnresolvableGenerics();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:16,代码来源:ApplicationListenerMethodAdapter.java

示例3: supportsEventType

import org.springframework.core.ResolvableType; //导入方法依赖的package包/类
@Override
public boolean supportsEventType(ResolvableType eventType) {
    for (ResolvableType declaredEventType : this.declaredEventTypes) {
        if (declaredEventType.isAssignableFrom(eventType)) {
            return true;
        } else if (PayloadApplicationEvent.class.isAssignableFrom(eventType.getRawClass())) {
            ResolvableType payloadType = eventType.as(PayloadApplicationEvent.class).getGeneric();
            if (declaredEventType.isAssignableFrom(payloadType)) {
                return true;
            }
        }
    }
    return eventType.hasUnresolvableGenerics();
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:15,代码来源:UiEventListenerMethodAdapter.java

示例4: checkGenericTypeMatch

import org.springframework.core.ResolvableType; //导入方法依赖的package包/类
/**
 * Match the given dependency type with its generic type information against the given
 * candidate bean definition.
 */
protected boolean checkGenericTypeMatch(BeanDefinitionHolder bdHolder, DependencyDescriptor descriptor) {
	ResolvableType dependencyType = descriptor.getResolvableType();
	if (dependencyType.getType() instanceof Class) {
		// No generic type -> we know it's a Class type-match, so no need to check again.
		return true;
	}
	ResolvableType targetType = null;
	RootBeanDefinition rbd = null;
	if (bdHolder.getBeanDefinition() instanceof RootBeanDefinition) {
		rbd = (RootBeanDefinition) bdHolder.getBeanDefinition();
	}
	if (rbd != null) {
		// First, check factory method return type, if applicable
		targetType = getReturnTypeForFactoryMethod(rbd, descriptor);
		if (targetType == null) {
			RootBeanDefinition dbd = getResolvedDecoratedDefinition(rbd);
			if (dbd != null) {
				targetType = getReturnTypeForFactoryMethod(dbd, descriptor);
			}
		}
	}
	if (targetType == null) {
		// Regular case: straight bean instance, with BeanFactory available.
		if (this.beanFactory != null) {
			Class<?> beanType = this.beanFactory.getType(bdHolder.getBeanName());
			if (beanType != null) {
				targetType = ResolvableType.forClass(ClassUtils.getUserClass(beanType));
			}
		}
		// Fallback: no BeanFactory set, or no type resolvable through it
		// -> best-effort match against the target class if applicable.
		if (targetType == null && rbd != null && rbd.hasBeanClass() && rbd.getFactoryMethodName() == null) {
			Class<?> beanClass = rbd.getBeanClass();
			if (!FactoryBean.class.isAssignableFrom(beanClass)) {
				targetType = ResolvableType.forClass(ClassUtils.getUserClass(beanClass));
			}
		}
	}
	if (targetType == null || (descriptor.fallbackMatchAllowed() && targetType.hasUnresolvableGenerics())) {
		return true;
	}
	// Full check for complex generic type match...
	return dependencyType.isAssignableFrom(targetType);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:49,代码来源:GenericTypeAwareAutowireCandidateResolver.java


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