Package java.lang.reflect

Examples of java.lang.reflect.ParameterizedType


                                                                javax.xml.ws.Holder.class});

        assertNotNull("method echoData can not be found", method1);

        Type[] types = method1.getGenericParameterTypes();
        ParameterizedType paraType = (ParameterizedType)types[1];
        Class typeClass = (Class)paraType.getActualTypeArguments()[0];
        assertEquals("javax.activation.DataHandler", typeClass.getName());
    }
View Full Code Here


        return Schema.create(Schema.Type.BYTES);          
      Schema result = Schema.createArray(createSchema(component, names));
      setElement(result, component);
      return result;
    } else if (type instanceof ParameterizedType) {
      ParameterizedType ptype = (ParameterizedType)type;
      Class raw = (Class)ptype.getRawType();
      Type[] params = ptype.getActualTypeArguments();
      if (Map.class.isAssignableFrom(raw)) {                 // Map
        Schema schema = Schema.createMap(createSchema(params[1], names));
        Class key = (Class)params[0];
        if (isStringable(key)) {                             // Stringable key
          schema.addProp(KEY_CLASS_PROP, key.getName());
View Full Code Here

                            Type[] interfaces = cls.getGenericInterfaces();
                            for (Type t : interfaces)
                            {
                                if(t instanceof ParameterizedType)
                                {
                                    ParameterizedType pt = (ParameterizedType)t;
                                    if (((Class)pt.getRawType()).getSimpleName().equals("ICompactSerializer"))
                                    {
                                        discoveredClassNames.add(simpleName);
                                        break classTraversal;
                                    }
                                }
View Full Code Here

                            Type[] interfaces = cls.getGenericInterfaces();
                            for (Type t : interfaces)
                            {
                                if(t instanceof ParameterizedType)
                                {
                                    ParameterizedType pt = (ParameterizedType)t;
                                    if (((Class)pt.getRawType()).getSimpleName().equals("ICompactSerializer"))
                                    {
                                        discoveredClassNames.add(simpleName);
                                        break classTraversal;
                                    }
                                }
View Full Code Here

        holder.setTag(tag);
        List<TagVO2Holder> list = new ArrayList<TagVO2Holder>();
        list.add(holder);
   
        //ParameterizedType required for Lists of Objects
        ParameterizedType type = new ParameterizedType() {
            public Type getRawType() { return List.class; }
            public Type getOwnerType() { return null; }
            public Type[] getActualTypeArguments() {
                return new Type[] {TagVO2Holder.class};
            }
View Full Code Here

        part.setProperty(JAXBDataBinding.class.getName() + ".CUSTOM_EXCEPTION", Boolean.TRUE);
    }
   
    private boolean generateGenericType(Type type) {
        if (type instanceof ParameterizedType) {
            ParameterizedType paramType = (ParameterizedType)type;
            if (paramType.getActualTypeArguments().length > 1) {
                return true;

            }
        }
        return false;
View Full Code Here

   
    static boolean isArray(Type cls) {
        if (cls instanceof Class) {
            return ((Class<?>)cls).isArray();
        } else if (cls instanceof ParameterizedType) {
            ParameterizedType pt = (ParameterizedType)cls;
            return pt.getActualTypeArguments().length == 1
                && pt.getRawType() instanceof Class
                && Collection.class.isAssignableFrom((Class<?>)pt.getRawType());
        } else if (cls instanceof GenericArrayType) {
            return true;
        }
        return false;
    }
View Full Code Here

                addType(genericType, true);
            }

            if (isList
                && genericType instanceof ParameterizedType) {
                ParameterizedType pt = (ParameterizedType) genericType;
                if (pt.getActualTypeArguments().length > 0
                    && pt.getActualTypeArguments()[0] instanceof Class) {

                    Class<? extends Object> arrayCls =
                        Array.newInstance((Class<?>) pt.getActualTypeArguments()[0], 0).getClass();
                    clazz = arrayCls;
                    part.setTypeClass(clazz);
                    if (isFromWrapper) {
                        addType(clazz.getComponentType(), true);
                    }
                } else if (pt.getActualTypeArguments().length > 0
                    && pt.getActualTypeArguments()[0] instanceof GenericArrayType) {
                    GenericArrayType gat = (GenericArrayType)pt.getActualTypeArguments()[0];
                    gat.getGenericComponentType();
                    Class<? extends Object> arrayCls =
                        Array.newInstance((Class<?>) gat.getGenericComponentType(), 0).getClass();
                    clazz = Array.newInstance(arrayCls, 0).getClass();
                    part.setTypeClass(clazz);
View Full Code Here

                addClass(((Class<?>)cls).getComponentType());
            } else {
                addClass((Class<?>)cls);
            }
        } else if (cls instanceof ParameterizedType) {
            final ParameterizedType parameterizedType = (ParameterizedType)cls;
            addType(parameterizedType.getRawType());
            if (!parameterizedType.getRawType().equals(Enum.class)) {
                for (Type t2 : parameterizedType.getActualTypeArguments()) {
                    if (shouldTypeBeAdded(t2, parameterizedType)) {
                        addType(t2);
                    }
                }
            }
View Full Code Here

            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
        // Types will
        // JAXB Code Generated.
        assert false;
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.