Package java.lang.reflect

Examples of java.lang.reflect.GenericArrayType


    public static Class<?> getClassFromType(Type t) {
        if (t instanceof Class) {
            return (Class)t;
        } else if (t instanceof GenericArrayType) {
            GenericArrayType g = (GenericArrayType)t;
            return Array.newInstance(getClassFromType(g.getGenericComponentType()), 0).getClass();
        } else if (t instanceof ParameterizedType) {
            ParameterizedType p = (ParameterizedType)t;
            return getClassFromType(p.getRawType());
        }
        // TypeVariable and WildCardType are not handled as it is unlikely such
View Full Code Here


    public static Class<?> getClassFromType(Type t) {
        if (t instanceof Class) {
            return (Class)t;
        } else if (t instanceof GenericArrayType) {
            GenericArrayType g = (GenericArrayType)t;
            return Array.newInstance(getClassFromType(g.getGenericComponentType()), 0).getClass();
        } else if (t instanceof ParameterizedType) {
            ParameterizedType p = (ParameterizedType)t;
            return getClassFromType(p.getRawType());
        }
        // TypeVariable and WildCardType are not handled as it is unlikely such
View Full Code Here

         Type rawType = parameterizedType.getRawType();
         return (Class<?>) rawType;
      }
      else if (type instanceof GenericArrayType)
      {
         final GenericArrayType genericArrayType = (GenericArrayType) type;
         final Class<?> componentRawType = getRawType(genericArrayType.getGenericComponentType());
         return Array.newInstance(componentRawType, 0).getClass();
      }
      throw new RuntimeException("Unable to determine base class from Type");
   }
View Full Code Here

         Type rawType = parameterizedType.getRawType();
         return (Class<?>) rawType;
      }
      else if (type instanceof GenericArrayType)
      {
         final GenericArrayType genericArrayType = (GenericArrayType) type;
         final Class<?> componentRawType = getRawType(genericArrayType.getGenericComponentType());
         return Array.newInstance(componentRawType, 0).getClass();
      }
      return null;
   }
View Full Code Here

         Type componentGenericType = parameterizedType.getActualTypeArguments()[0];
         return getRawType(componentGenericType);
      }
      else if (genericType instanceof GenericArrayType)
      {
         final GenericArrayType genericArrayType = (GenericArrayType) genericType;
         Type componentGenericType = genericArrayType.getGenericComponentType();
         return getRawType(componentGenericType);
      }
      else if (type.isArray())
      {
         return type.getComponentType();
View Full Code Here

      Type componentGenericType = parameterizedType.getActualTypeArguments()[0];
      return componentGenericType;
    }
    else if (genericType instanceof GenericArrayType)
    {
      final GenericArrayType genericArrayType = (GenericArrayType) genericType;
      Type componentGenericType = genericArrayType.getGenericComponentType();
      return componentGenericType;
    }
    else if (type.isArray())
    {
      return type.getComponentType();
View Full Code Here

      Type rawType = parameterizedType.getRawType();
      return (Class<?>) rawType;
    }
    else if (type instanceof GenericArrayType)
    {
      final GenericArrayType genericArrayType = (GenericArrayType) type;
      final Class<?> componentRawType = getRawType(genericArrayType.getGenericComponentType());
      return Array.newInstance(componentRawType, 0).getClass();
    }
    else if (type instanceof TypeVariable)
    {
      final TypeVariable<?> typeVar = (TypeVariable<?>) type;
View Full Code Here

        }
      };
    }
    else if (propertyType instanceof GenericArrayType)
    {
      final GenericArrayType genericArrayType = (GenericArrayType) propertyType;
      final Class<?> componentRawType = getRawType(getPropertyType(genericArrayType.getGenericComponentType(), baseClass, baseRawType));
      result = Array.newInstance(componentRawType, 0).getClass();
    }
    else if (propertyType instanceof TypeVariable)
    {
      Type[] typeArguments = ((ParameterizedType)baseClass).getActualTypeArguments();
View Full Code Here

                final Type[] actualArguments = parametrizedType.getActualTypeArguments();
                for (final Type actualArgument : actualArguments) {
                    localTypes.add(actualArgument);
                }
            } else if (type instanceof GenericArrayType) {
                final GenericArrayType arrayType = (GenericArrayType)type;
                localTypes.add(arrayType.getGenericComponentType());
            }

            if (!localTypes.isEmpty()) {
                final Iterator<Type> iter = localTypes.iterator();
                type = iter.next();
View Full Code Here

    if (genericType instanceof Class) {
      return (Class<?>) genericType;
    } else if (genericType instanceof ParameterizedType) {
      return resolveRawClass(((ParameterizedType) genericType).getRawType(), subType);
    } else if (genericType instanceof GenericArrayType) {
      GenericArrayType arrayType = (GenericArrayType) genericType;
      Class<?> compoment = resolveRawClass(arrayType.getGenericComponentType(), subType);
      return Array.newInstance(compoment, 0).getClass();
    } else if (genericType instanceof TypeVariable) {
      TypeVariable<?> variable = (TypeVariable<?>) genericType;
      genericType = getTypeVariableMap(subType).get(variable);
      genericType = genericType == null ? resolveBound(variable) : resolveRawClass(genericType,
View Full Code Here

TOP

Related Classes of java.lang.reflect.GenericArrayType

Copyright © 2018 www.massapicom. 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.