Package java.lang.reflect

Examples of java.lang.reflect.Type


            continue;

         HttpRequest request = RequestUtil.getHttpRequest(servletRequest);
         Class type = methodParameter.getParameterType();
         Method method = methodParameter.getMethod();
         Type genericType = method.getGenericParameterTypes()[i];
         Annotation[] annotations = method.getParameterAnnotations()[i];

         if (isRestfulData)
         {
            method.getTypeParameters();
View Full Code Here


    return false;
  }

  public static Type getGenericType(Field field) {
   
    Type type = ((ParameterizedType)field.getGenericType()).getActualTypeArguments()[0];
   
    if(type instanceof WildcardType){
     
      //TODO do a little bit more research on this part...
      return ((WildcardType)type).getUpperBounds()[0];
View Full Code Here

         return new CdiConstructorInjector(clazz, manager);
      }

      if (sessionBeanInterface.containsKey(clazz))
      {
         Type intfc = sessionBeanInterface.get(clazz);
         log.debug("Using {0} for lookup of Session Bean {1}.", intfc, clazz);
         return new CdiConstructorInjector(intfc, manager);
      }

      log.debug("No CDI beans found for {0}. Using default ConstructorInjector.", clazz);
View Full Code Here

      headers.putAll(part.getHeaders());
      headers.putSingle(HttpHeaderNames.CONTENT_TYPE, part.getMediaType());

      Object entity = part.getEntity();
      Class<?> entityType = part.getType();
      Type entityGenericType = part.getGenericType();
      MessageBodyWriter writer = workers.getMessageBodyWriter(entityType, entityGenericType, null, part.getMediaType());
      long size = writer.getSize(entity, entityType, entityGenericType, null, part.getMediaType());
      if (size > -1) headers.putSingle(HttpHeaderNames.CONTENT_LENGTH, Integer.toString((int) size));
      writer.writeTo(entity, entityType, entityGenericType, null, part.getMediaType(), headers, new HeaderFlushedOutputStream(headers, entityStream));
      entityStream.write("\r\n".getBytes());
View Full Code Here

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

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

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

   * @return a list of the raw classes for the actual type arguments.
   */
  public static <T> List<Class<?>> getTypeArguments(Class<T> baseClass,
      Class<? extends T> childClass) {
    Map<Type, Type> resolvedTypes = new HashMap<Type, Type>();
    Type type = childClass;
    // start walking up the inheritance hierarchy until we hit baseClass
    while (!getClass(type).equals(baseClass)) {
      if (type instanceof Class) {
        // there is no useful information for us in raw types, so just
        // keep going.
View Full Code Here

    if (type instanceof Class) {
      return (Class) type;
    } else if (type instanceof ParameterizedType) {
      return getClass(((ParameterizedType) type).getRawType());
    } else if (type instanceof GenericArrayType) {
      Type componentType = ((GenericArrayType) type)
          .getGenericComponentType();
      Class<?> componentClass = getClass(componentType);
      if (componentClass != null) {
        return Array.newInstance(componentClass, 0).getClass();
      } else {
View Full Code Here

  public static class ArgumentCandidatesCache {

    private List<ArgumentHolder> cache = new ArrayList<ArgumentHolder>();

    protected void add(MethodParameter parameter, Object object) {
      final Type type = parameter.getGenericParameterType();
      CollectionUtils.filter(this.cache, new Predicate() {
        public boolean evaluate(Object object) {
          ArgumentHolder holder = (ArgumentHolder) object;
          return !holder.match(type);
        }
View Full Code Here

      this.actualArguments = actualTypes;
      this.object = object;
    }

    protected ArgumentHolder(MethodParameter parameter, Object object) {
      Type genericType = parameter.getGenericParameterType();
      if (genericType instanceof Class<?>) {
        this.type = (Class<?>) genericType;
      } else {
        ParameterizedTypeImpl parameterizedType = (ParameterizedTypeImpl) genericType;
        this.type = parameterizedType.getRawType();
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    private Object execute(Select s, Method method, Object[] args, Foo f)
    {
        Type t = method.getGenericReturnType();
        assert(t instanceof ParameterizedType);
        ParameterizedType returnType = (ParameterizedType) t;
        final Type[] h = returnType.getActualTypeArguments();
        assert(h.length == 1);
        assert(h[0] instanceof Class);
View Full Code Here

TOP

Related Classes of java.lang.reflect.Type

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.