Package java.lang.reflect

Examples of java.lang.reflect.GenericArrayType


    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


      return true;
    if (obj == null)
      return false;
    if (!(obj instanceof GenericArrayType))
      return false;
    GenericArrayType other = (GenericArrayType) obj;
    if (genericComponentType == null) {
      if (other.getGenericComponentType() != null)
        return false;
    } else if (!genericComponentType.equals(other.getGenericComponentType()))
      return false;
    return true;
  }
View Full Code Here

            TypeVariable<?> tv = (TypeVariable<?>)type;
            for (Type t : tv.getBounds()) {
                findClasses(t, classSet, visited);
            }
        } else if (type instanceof GenericArrayType) {
            GenericArrayType gType = (GenericArrayType)type;
            findClasses(gType, classSet, visited);
        } else if (type instanceof WildcardType) {
            WildcardType wType = (WildcardType)type;
            for (Type t : wType.getLowerBounds()) {
                findClasses(t, classSet, visited);
View Full Code Here

        } else if (cls instanceof ParameterizedType) {
            for (Type t2 : ((ParameterizedType)cls).getActualTypeArguments()) {
                return getArrayComponentType(t2);
            }
        } else if (cls instanceof GenericArrayType) {
            GenericArrayType gt = (GenericArrayType)cls;
            Class<?> ct = (Class<?>) gt.getGenericComponentType();
            return Array.newInstance(ct, 0).getClass();
        }
        return null;
    }
View Full Code Here

        } else if (cls instanceof ParameterizedType) {
            for (Type t2 : ((ParameterizedType)cls).getActualTypeArguments()) {
                return getBeanInfo(t2);
            }
        } else if (cls instanceof GenericArrayType) {
            GenericArrayType gt = (GenericArrayType)cls;
            Class<?> ct = (Class<?>) gt.getGenericComponentType();
            ct = Array.newInstance(ct, 0).getClass();

            return getBeanInfo(ct);
        }
View Full Code Here

    }
    return TypeFactory.createGenericArrayType( componentType );
  }

  private static GenericArrayType createGenericArrayType(final Type componentType) {
    return new GenericArrayType() {

      public Type getGenericComponentType() {
        return componentType;
      }

      @Override
      public boolean equals(Object obj) {
        if ( !( obj instanceof GenericArrayType ) ) {
          return false;
        }
        GenericArrayType other = (GenericArrayType) obj;
        return safeEquals( getGenericComponentType(), other.getGenericComponentType() );
      }

      @Override
      public int hashCode() {
        return safeHashCode( getGenericComponentType() );
View Full Code Here

   private static Class determineElementType(Class<?> type, Type genericType) {
      if (type.isArray()) {
         if (genericType instanceof Class) {
            return type.getComponentType();
         }
         GenericArrayType genericArrayType = (GenericArrayType) genericType;
         TypeVariable genericComponentType = (TypeVariable) genericArrayType.getGenericComponentType();
         return (Class) genericComponentType.getBounds()[0];
      } else if (Collection.class.isAssignableFrom(type)) {
         return determineCollectionElementType(genericType);
      } else if (Map.class.isAssignableFrom(type)) {
         return determineMapValueTypeParam(genericType);
View Full Code Here

      ParamType paramType = new ParamType(rawType, args, newParamMap);
     
      return paramType;
    }
    else if (type instanceof GenericArrayType) {
      GenericArrayType aType = (GenericArrayType) type;

      BaseType baseType = create(aType.getGenericComponentType(),
                                 paramMap, paramDeclName,
                                 classFill);
      Class<?> rawType = Array.newInstance(baseType.getRawClass(), 0).getClass();
     
      return new ArrayType(baseType, rawType);
    }
    else if (type instanceof TypeVariable<?>) {
      TypeVariable<?> aType = (TypeVariable<?>) type;
     
      return createVar(aType, paramMap, paramDeclName, parentType, classFill);
    }
    else if (type instanceof WildcardType) {
      WildcardType aType = (WildcardType) type;

      BaseType []lowerBounds = toBaseType(aType.getLowerBounds(),
                                          paramMap, paramDeclName);
      BaseType []upperBounds = toBaseType(aType.getUpperBounds(),
                                          paramMap, paramDeclName);
     
      return new WildcardTypeImpl(lowerBounds, upperBounds);
    }
   
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

            ParameterizedType pType = (ParameterizedType) type;
            return getTypeRelatedClass(pType.getRawType());
        }
       
        if (type instanceof GenericArrayType) {
            GenericArrayType gat = (GenericArrayType) type;
            java.lang.reflect.Type compType = gat.getGenericComponentType();
            Class<?> arrayBaseType = getTypeRelatedClass(compType);
            // believe it or not, this seems to be the only way to get the
            // Class object for an array of primitive type.
            Object instance = Array.newInstance(arrayBaseType, 0);
            return instance.getClass();
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.