Package java.lang.reflect

Examples of java.lang.reflect.ParameterizedType


        return Holder.class.isAssignableFrom(cType);
        // set the actual type argument of Holder in the TypeReference
    }

    private Class getHoldedClass(Class holderClazz, Type type) {
        ParameterizedType pt = (ParameterizedType)type;
        return getClass(pt.getActualTypeArguments()[0]);
    }
View Full Code Here


        return Holder.class.isAssignableFrom(cType);
        // set the actual type argument of Holder in the TypeReference
    }

    private Class getHoldedClass(Class holderClazz, Type type) {
        ParameterizedType pt = (ParameterizedType)type;
        return getClass(pt.getActualTypeArguments()[0]);
    }
View Full Code Here

    private synchronized Template lookupImpl(Type targetType,
      final boolean forceLoad, final boolean forceBuild, final boolean fallbackDefault) {
  Template tmpl;

  if (targetType instanceof ParameterizedType) {
      ParameterizedType pType = (ParameterizedType) targetType;
      // ParameterizedType is not a Class<?>?
      tmpl = lookupGenericImpl(pType);
      if (tmpl != null) {
    return tmpl;
      }
      try {
    tmpl = parent.lookupGenericImpl(pType);
    if (tmpl != null) {
        return tmpl;
    }
      } catch (NullPointerException e) { // ignore
      }
      targetType = pType.getRawType();
  }

  tmpl = cache.get(targetType);
  if (tmpl != null) {
      return tmpl;
View Full Code Here

  }
    }

    public synchronized Template lookupGeneric(final Type targetType) {
  if (targetType instanceof ParameterizedType) {
      ParameterizedType parameterizedType = (ParameterizedType)targetType;
      Template tmpl = lookupGenericImpl(parameterizedType);
      if (tmpl != null) {
    return tmpl;
      }
      return new DefaultTemplate(this, (Class<?>) parameterizedType.getRawType(), parameterizedType);
  } else {
      throw new IllegalArgumentException("Actual types of the generic type are erased: "+targetType);
  }
    }
View Full Code Here

      else
      {
         final Type methodGenericReturnType = method.getGenericReturnType();
         if (methodGenericReturnType instanceof ParameterizedType)
         {
            final ParameterizedType zType = (ParameterizedType) methodGenericReturnType;
            final Type genericReturnType = zType.getActualTypeArguments()[0];
            final Class<?> responseReturnType = Types.getRawType(genericReturnType);
            return new EntityExtractor()
            {
               public Object extractEntity(ClientRequestContext context, Object... args)
               {
View Full Code Here

      }
      if (isCollection)
      {
         if (genericType instanceof ParameterizedType)
         {
            ParameterizedType zType = (ParameterizedType) genericType;
            baseType = (Class) zType.getActualTypeArguments()[0];
         }
         else
         {
            baseType = String.class;
         }
View Full Code Here

    if (!(genericType instanceof ParameterizedType))
      throw new IllegalArgumentException("Reader = " + this
          + " recived genericType = " + genericType
          + ", but it is not instance of " + ParameterizedType.class);

    ParameterizedType param = (ParameterizedType) genericType;
    Type baseType = param.getActualTypeArguments()[1];
    Class<?> rawType = Types.getRawType(baseType);

    MultipartFormDataInputImpl input = new MultipartFormDataInputImpl(
        mediaType, workers);
    input.parse(entityStream);
View Full Code Here

      Type[] intfs = provider.getClass().getGenericInterfaces();
      for (Type type : intfs)
      {
         if (type instanceof ParameterizedType)
         {
            ParameterizedType pt = (ParameterizedType) type;
            if (pt.getRawType().equals(StringParameterUnmarshaller.class))
            {
               Class<?> aClass = Types.getRawType(pt.getActualTypeArguments()[0]);
               stringParameterUnmarshallers.put(aClass, provider);
            }
         }
      }
   }
View Full Code Here

         if (intf.equals(desiredInterface))
         {
            Type generic = base.getGenericInterfaces()[i];
            if (generic instanceof ParameterizedType)
            {
               ParameterizedType p = (ParameterizedType) generic;
               Type type = p.getActualTypeArguments()[0];
               Class rtn = getRawTypeNoException(type);
               if (rtn != null) return rtn;
               return type;
            }
            else
            {
               return null;
            }
         }
      }
      if (base.getSuperclass() == null || base.getSuperclass().equals(Object.class)) return null;
      Object rtn = getSomething(base.getSuperclass(), desiredInterface);
      if (rtn == null || rtn instanceof Class) return rtn;
      if (!(rtn instanceof TypeVariable)) return null;

      String name = ((TypeVariable) rtn).getName();
      int index = -1;
      TypeVariable[] variables = base.getSuperclass().getTypeParameters();
      if (variables == null || variables.length < 1) return null;

      for (int i = 0; i < variables.length; i++)
      {
         if (variables[i].getName().equals(name)) index = i;
      }
      if (index == -1) return null;


      Type genericSuperclass = base.getGenericSuperclass();
      if (!(genericSuperclass instanceof ParameterizedType)) return null;

      ParameterizedType pt = (ParameterizedType) genericSuperclass;
      Type type = pt.getActualTypeArguments()[index];

      Class clazz = getRawTypeNoException(type);
      if (clazz != null) return clazz;
      return type;
   }
View Full Code Here

         return (Class<?>) type;

      }
      else if (type instanceof ParameterizedType)
      {
         ParameterizedType parameterizedType = (ParameterizedType) type;
         Type rawType = parameterizedType.getRawType();
         return (Class<?>) rawType;
      }
      else if (type instanceof GenericArrayType)
      {
         final GenericArrayType genericArrayType = (GenericArrayType) type;
View Full Code Here

TOP

Related Classes of java.lang.reflect.ParameterizedType

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.