Package java.lang.reflect

Examples of java.lang.reflect.ParameterizedType


        for (Field f : ClassUtils.getFields(clazz)) {
            if (f.getAnnotation(org.hibernate.search.annotations.Field.class) != null) fields.add(prefix + f.getName());
            if (f.getAnnotation(IndexedEmbedded.class) != null) {
                Class<?> fieldClass = f.getType();
                if (Collection.class.isAssignableFrom(fieldClass)) {
                    ParameterizedType coltype = (ParameterizedType) f.getGenericType();
                    fields.addAll(getAllIndexedFields((Class<?>) coltype.getActualTypeArguments()[0], prefix + f.getName() + "."));
                } else fields.addAll(getAllIndexedFields(fieldClass, prefix + f.getName() + "."));
            }
        }
        return fields;
    }
View Full Code Here


    public static Class<?> getGenericType(Field field) {
        Class<?> clazz = null;
        if (field != null) {
            Type t = field.getGenericType();
            if (t instanceof ParameterizedType) {
                ParameterizedType type = (ParameterizedType) t;
                if ((type != null) && (type.getActualTypeArguments() != null) && (type.getActualTypeArguments().length > 0)) clazz = (Class<?>) type.getActualTypeArguments()[0];
            } else if (t instanceof Class) clazz = (Class<?>) t;
        }
        return clazz;
    }
View Full Code Here

    }

    public static Class<?> getGenericType(Field field) {
        Class<?> clazz = null;
        if (field != null) {
            ParameterizedType type = (ParameterizedType) field.getGenericType();
            if ((type != null) && (type.getActualTypeArguments() != null) && (type.getActualTypeArguments().length > 0)) clazz = (Class<?>) type.getActualTypeArguments()[0];
        }
        return clazz;
    }
View Full Code Here

    private Object getGenericComponent(Object genericType, int index)
    {
        if (genericType instanceof ParameterizedType)
        {
            ParameterizedType type = (ParameterizedType) genericType;

            if (type.getActualTypeArguments()[index] instanceof WildcardType)
            {
                WildcardType wildcardType = (WildcardType) type.getActualTypeArguments()[index];

                return wildcardType;
            }
            else if (type.getActualTypeArguments()[index] instanceof ParameterizedType)
            {
                ParameterizedType ptype = (ParameterizedType) type.getActualTypeArguments()[index];
               
                return ptype;
            }
        }
       
View Full Code Here

    {
        Class paramClass = null;

        if (genericType instanceof ParameterizedType)
        {
            ParameterizedType type = (ParameterizedType) genericType;

            if (type.getActualTypeArguments()[index] instanceof Class)
            {
                paramClass = (Class) type.getActualTypeArguments()[index];
            }

            else if (type.getActualTypeArguments()[index] instanceof WildcardType)
            {
                WildcardType wildcardType = (WildcardType) type.getActualTypeArguments()[index];

                if (wildcardType.getUpperBounds()[index] instanceof Class)
                {
                    paramClass = (Class) wildcardType.getUpperBounds()[index];
                }
            }
            else if (type.getActualTypeArguments()[index] instanceof ParameterizedType)
            {
                ParameterizedType ptype = (ParameterizedType) type.getActualTypeArguments()[index];
                paramClass = (Class) ptype.getRawType();
            }
        }
        return paramClass;
    }
View Full Code Here

    {
        Class paramClass = null;

        if (genericType instanceof ParameterizedType)
        {
            ParameterizedType type = (ParameterizedType) genericType;

            if (type.getActualTypeArguments()[index] instanceof Class)
            {
                paramClass = (Class) type.getActualTypeArguments()[index];
            }

            else if (type.getActualTypeArguments()[index] instanceof WildcardType)
            {
                WildcardType wildcardType = (WildcardType) type.getActualTypeArguments()[index];

                if (wildcardType.getUpperBounds()[index] instanceof Class)
                {
                    paramClass = (Class) wildcardType.getUpperBounds()[index];
                }
            }
            else if (type.getActualTypeArguments()[index] instanceof ParameterizedType)
            {
                ParameterizedType ptype = (ParameterizedType) type.getActualTypeArguments()[index];
                paramClass = (Class) ptype.getRawType();
            }
        }
        return paramClass;
    }
View Full Code Here

            cls = callback.getMethod().getParameterTypes()[idx];
            if (cls.isAssignableFrom(Holder.class)) {
                //INOUT and OUT Params are mapped to Holder<T>.
                Type[] genericParameterTypes = callback.getMethod().getGenericParameterTypes();
                //ParameterizedType represents Holder<?>
                ParameterizedType paramType = (ParameterizedType)genericParameterTypes[idx];
                cls = JAXBEncoderDecoder.getClassFromType(
                                         paramType.getActualTypeArguments()[0]);               
            }
        }
        Node xmlNode = (Node)input;
       
        return JAXBEncoderDecoder.unmarshall(callback.getJAXBContext(),
View Full Code Here

                    Class<?> cls = callback.getMethod().getParameterTypes()[idx];               
                    if (param.mode() != WebParam.Mode.IN) {
                        //INOUT and OUT Params are mapped to Holder<T>.
                        Type[] genericParameterTypes = callback.getMethod().getGenericParameterTypes();
                        //ParameterizedType represents Holder<?>
                        ParameterizedType paramType = (ParameterizedType)genericParameterTypes[idx];
                        Class<?> c =
                            JAXBEncoderDecoder.getClassFromType(paramType.getActualTypeArguments()[0]);
                        Object partValue = callback.getWrappedPart(param.name(), obj, c);
                        //TO avoid type safety warning the Holder
                        //needs tobe set as below.                       
                        cls.getField("value").set(methodArgs[idx], partValue);
                    } else {
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;
        throw new IllegalArgumentException("Cannot get Class object from unknown Type");
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

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.