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


Java TypeUtils.getTypeArguments方法代码示例

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


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

示例1: createSignature

import org.apache.commons.lang3.reflect.TypeUtils; //导入方法依赖的package包/类
private static Signature createSignature(final Object input, final Type type, final Map<TypeVariable<?>, Type> typeArgs, final boolean isInput) {
    final Class clazz = getTypeClass(type, typeArgs);

    if (Tuple.class.isAssignableFrom(clazz)) {
        final TypeVariable[] tupleTypes = getTypeClass(type, typeArgs).getTypeParameters();
        final Map<TypeVariable<?>, Type> classTypeArgs = TypeUtils.getTypeArguments(type, clazz);
        Collection<? extends Type> types = TypeUtils.getTypeArguments(type, clazz).values();
        Class[] classes = new Class[types.size()];
        int i = 0;
        for (final TypeVariable tupleType : tupleTypes) {
            classes[i++] = getTypeClass(classTypeArgs.get(tupleType), typeArgs);
        }

        return new TupleSignature(input, clazz, classes, isInput);
    }

    return new SingletonSignature(input, clazz, isInput);
}
 
开发者ID:gchq,项目名称:koryphe,代码行数:19,代码来源:Signature.java

示例2: getTypeFromExactReturnType

import org.apache.commons.lang3.reflect.TypeUtils; //导入方法依赖的package包/类
/**
 * Returns the exact return type of the given method in the given type. This
 * may be different from <tt>m.getGenericReturnType()</tt> when the method
 * was declared in a superclass, or <tt>type</tt> has a type parameter that
 * is used in the return type, or <tt>type</tt> is a raw type.
 */
protected static Type getTypeFromExactReturnType(ParameterizedType returnType,
        ParameterizedType type) {
	Map<TypeVariable<?>, Type> typeMap = TypeUtils.getTypeArguments(returnType);
	Type[] actualParameters = new Type[type.getActualTypeArguments().length];
	int num = 0;
	for (TypeVariable<?> parameterType : ((Class<?>) type.getRawType()).getTypeParameters()) {
		//for(Type parameterType : type.getActualTypeArguments()) {
		//	if(parameterType instanceof TypeVariable<?>) {
		boolean replaced = false;
		for (TypeVariable<?> var : typeMap.keySet()) {
			// D'oh! Why the heck do we need this?? 
			if (var.getName().equals(parameterType.getName())) {
				//if(typeMap.containsKey(parameterType)) {
				actualParameters[num] = typeMap.get(var);
				replaced = true;
				break;
				//} else {
			}
		}
		if (!replaced) {
			actualParameters[num] = parameterType;
		}
		//}
		//    	} else {
		//    		LoggingUtils.getEvoLogger().info("Not a type variable "+parameterType);
		//    		actualParameters[num] = parameterType;
		//    		}
		num++;
	}

	return new ParameterizedTypeImpl((Class<?>) type.getRawType(), actualParameters,
	        null);
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:40,代码来源:GenericAccessibleObject.java

示例3: getParameterTypesForCollection

import org.apache.commons.lang3.reflect.TypeUtils; //导入方法依赖的package包/类
public static Collection<Type> getParameterTypesForCollection(Class<?> type) {
    if (isCollectionOrSequence(type)) {
        Map<TypeVariable<?>, Type> m
                = TypeUtils.getTypeArguments((ParameterizedType) type.getGenericSuperclass());
        return m.values();
    }

    return null;
}
 
开发者ID:moosbusch,项目名称:Lumpi,代码行数:10,代码来源:LumpiUtil.java

示例4: getTypeParameter

import org.apache.commons.lang3.reflect.TypeUtils; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static <T> Class<T> getTypeParameter(Type subType, Class<?> superType, int index) {
    final Map<TypeVariable<?>, Type> arguments = TypeUtils.getTypeArguments(subType, superType);
    final TypeVariable<? extends Class<?>> variable = superType.getTypeParameters()[index];
    return (Class<T>) arguments.get(variable);
}
 
开发者ID:Microbule,项目名称:microbule,代码行数:7,代码来源:Types.java

示例5: getType

import org.apache.commons.lang3.reflect.TypeUtils; //导入方法依赖的package包/类
private static Class getType(final Class<? extends Operation> operation, final Class<?> objectClass) {
    final TypeVariable<?> tv = objectClass.getTypeParameters()[0];
    final Map<TypeVariable<?>, Type> typeArgs = TypeUtils.getTypeArguments(operation, objectClass);
    final Type type = typeArgs.get(tv);
    return getType(type, typeArgs);
}
 
开发者ID:gchq,项目名称:Gaffer,代码行数:7,代码来源:OperationUtil.java

示例6: createSignatureFromTypeVariable

import org.apache.commons.lang3.reflect.TypeUtils; //导入方法依赖的package包/类
/**
 * Create a <code>Signature</code> for the type variable at the given index.
 *
 * @param input             Function to create signature for.
 * @param functionClass     The input class
 * @param typeVariableIndex 0 for I or 1 for O.
 * @param isInput           if true then it is an input signature otherwise it is an output signature
 * @return Signature of the type variable.
 */
private static Signature createSignatureFromTypeVariable(final Object input, final Class functionClass, final int typeVariableIndex, final boolean isInput) {
    TypeVariable<?> tv = functionClass.getTypeParameters()[typeVariableIndex];
    final Map<TypeVariable<?>, Type> typeArgs = TypeUtils.getTypeArguments(input.getClass(), functionClass);
    Type type = typeArgs.get(tv);
    return createSignature(input, type, typeArgs, isInput);
}
 
开发者ID:gchq,项目名称:koryphe,代码行数:16,代码来源:Signature.java


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