Examples of TypeVariable


Examples of java.lang.reflect.TypeVariable

        }
        if (type instanceof TypeVariable) {
            if (parameterizedTypes == null) {
                processParameterizedTypes();
            }
            TypeVariable var = (TypeVariable)type;
            Map<String, Class<?>> mp = parameterizedTypes.get(var.getGenericDeclaration());
            if (mp != null) {
                Class<?> c = parameterizedTypes.get(var.getGenericDeclaration()).get(var.getName());
                if (c != null) {
                    rawClass = c;
                    type = c;
                    part.getMessageInfo().setProperty("parameterized", Boolean.TRUE);
                }
View Full Code Here

Examples of java.lang.reflect.TypeVariable

                    Type[] actualTypeArguments = ((ParameterizedType) genericParent).getActualTypeArguments();
                    TypeVariable[] typeVariables = ((Class) ((ParameterizedType) genericParent).getRawType()).getTypeParameters();
                   
                    for (int i = 0; i < actualTypeArguments.length; i++) {
                        Type actualTypeArgument = actualTypeArguments[i];
                        TypeVariable variable = typeVariables[i];
                       
                        // We are building bottom up and need to link up
                        // any TypeVariables with the actual class from the
                        // originating entity.
                        if (actualTypeArgument instanceof TypeVariable) {
                            getDescriptor().addGenericType(variable.getName(), getDescriptor().getGenericType(((TypeVariable) actualTypeArgument).getName()));
                        } else {
                            getDescriptor().addGenericType(variable.getName(), actualTypeArgument);
                        }
                    }
                }
               
                MappedSuperclassAccessor accessor = getProject().getMappedSuperclass(parent);
View Full Code Here

Examples of java.lang.reflect.TypeVariable

    private static Class<?> resolveReturnType(Method method, Class<? extends Decoder> decoder) {
        Type genericReturnType = method.getGenericReturnType();
        if (genericReturnType instanceof Class) {
            return (Class<?>) genericReturnType;
        } else if (genericReturnType instanceof TypeVariable) {
            TypeVariable type = ((TypeVariable) genericReturnType);
            List<Class> classes = new ArrayList<>();
            Class c = decoder;
            while (c != method.getDeclaringClass() && c != null) {
                classes.add(c);
                c = c.getSuperclass();
            }
            Collections.reverse(classes);

            String currentName = type.getName();
            int currentPos = -1;
            for (Class clz : classes) {
                for (int i = 0; i < clz.getSuperclass().getTypeParameters().length; ++i) {
                    TypeVariable<? extends Class<?>> param = clz.getSuperclass().getTypeParameters()[i];
                    if (param.getName().equals(currentName)) {
                        currentPos = i;
                        break;
                    }
                }
                Type gs = clz.getGenericSuperclass();
                if (gs instanceof ParameterizedType) {
                    ParameterizedType pt = (ParameterizedType) gs;
                    Type at = pt.getActualTypeArguments()[currentPos];
                    if (at instanceof Class) {
                        return (Class<?>) at;
                    } else if (at instanceof TypeVariable) {
                        TypeVariable tv = (TypeVariable) at;
                        currentName = tv.getName();
                    }
                }
            }
            //todo: should we throw an exception here? It should never actually be reached
            return method.getReturnType();
View Full Code Here

Examples of java.lang.reflect.TypeVariable

            Type genericType = field.getGenericType();
            if (genericType instanceof Class) {
               return fieldClass.getComponentType();
            }
            GenericArrayType genericArrayType = (GenericArrayType) genericType;
            TypeVariable genericComponentType = (TypeVariable) genericArrayType.getGenericComponentType();
            return (Class) genericComponentType.getBounds()[0];
         } else if (Collection.class.isAssignableFrom(fieldClass)) {
            return determineCollectionElementTypeParam(field.getGenericType());
         } else if (Map.class.isAssignableFrom(fieldClass)) {
            return determineMapValueTypeParam(field.getGenericType());
         }
View Full Code Here

Examples of java.lang.reflect.TypeVariable

   private static Class determineMapValueTypeParam(Type genericFieldType) {
      if (genericFieldType instanceof ParameterizedType) {
         ParameterizedType type = (ParameterizedType) genericFieldType;
         Type fieldArgType = type.getActualTypeArguments()[1];
         if (fieldArgType instanceof TypeVariable) {
            TypeVariable genericComponentType = (TypeVariable) fieldArgType;
            return (Class) genericComponentType.getBounds()[0];
         } else {
            return (Class) fieldArgType;
         }
      } else if (genericFieldType instanceof Class) {
         Class genericFieldType1 = (Class) genericFieldType;
View Full Code Here

Examples of java.lang.reflect.TypeVariable

         type = ((ParameterizedClassInfo) classInfo).parameterizedType;

      Type result = locateActualType(reference, parameter, classInfo.getType(), type);
      if (result instanceof TypeVariable)
      {
         TypeVariable typeVariable = (TypeVariable) result;
         result = typeVariable.getBounds()[0];
      }
      return getTypeInfo(result);
   }
View Full Code Here

Examples of java.lang.reflect.TypeVariable

      Class<?> t = null;
      if(t0 instanceof Class)
         t = (Class<?>) t0;
      else if(t0 instanceof TypeVariable)
      {
         TypeVariable tv = (TypeVariable) t0;
         t = (Class<?>)tv.getBounds()[0];
      }
     
      // Add processed annotations
      addProcessedAnnotations(scope, processor.getAnnotationTypes());
     
View Full Code Here

Examples of java.lang.reflect.TypeVariable

                ParameterizedType pt = (ParameterizedType)t;
                Type[] args = pt.getActualTypeArguments();
                for (int i = 0; i < args.length; i++) {
                    Type arg = args[i];
                    if (arg instanceof TypeVariable) {
                        TypeVariable var = (TypeVariable)arg;
                        Type[] bounds = var.getBounds();
                        boolean isResolved = false;
                        for (int j = 0; j < bounds.length; j++) {
                            Class<?> cls = InjectionUtils.getRawType(bounds[j]);
                            if (cls != null && cls.isAssignableFrom(expectedType)) {
                                isResolved = true;
View Full Code Here

Examples of java.lang.reflect.TypeVariable

        }
        if (type instanceof TypeVariable) {
            if (parameterizedTypes == null) {
                processParameterizedTypes();
            }
            TypeVariable var = (TypeVariable)type;
            Map<String, Class<?>> mp = parameterizedTypes.get(var.getGenericDeclaration());
            if (mp != null) {
                Class<?> c = parameterizedTypes.get(var.getGenericDeclaration()).get(var.getName());
                if (c != null) {
                    rawClass = c;
                    type = c;
                    part.getMessageInfo().setProperty("parameterized", Boolean.TRUE);
                }
View Full Code Here

Examples of java.lang.reflect.TypeVariable

    {
        Asserts.assertNotNull(type, "type parameter can not be null");
       
        if (type instanceof TypeVariable)
        {
            TypeVariable wc = (TypeVariable)type;
            Type[] upper = wc.getBounds();           
           
           
            if(upper.length > 1)
            {
                return false;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.