Package java.lang.reflect

Examples of java.lang.reflect.ParameterizedType


    @SuppressWarnings("unchecked")
    private Class<T> messyCastToRawType(Type genericType) {
        if (genericType instanceof Class) {
            return (Class<T>)genericType;
        } else if (genericType instanceof ParameterizedType) {
            ParameterizedType pType = (ParameterizedType) genericType;
            return (Class<T>)pType.getRawType();
        } else {
            return null;
        }
    }
View Full Code Here


                return getClassCode(bounds[0]);
            } else {
                throw new IllegalArgumentException("Unable to determine type for: " + tv);
            }
        } else if (type instanceof ParameterizedType) {
            ParameterizedType pt = (ParameterizedType)type;
            StringBuilder a = new StringBuilder(getClassCode(pt.getRawType()));
            if (!pt.getRawType().equals(Enum.class)) {
                a.setLength(a.length() - 1);
                a.append('<');

                for (java.lang.reflect.Type t : pt.getActualTypeArguments()) {
                    a.append(getClassCode(t));
                }
                a.append(">;");
            }
            return a.toString();
View Full Code Here

    public <T> ContextResolver<T> createContextResolver(Type contextType, Message m) {
        for (ProviderInfo<ContextResolver> cr : userContextResolvers) {
            Type[] types = cr.getProvider().getClass().getGenericInterfaces();
            for (Type t : types) {
                if (t instanceof ParameterizedType) {
                    ParameterizedType pt = (ParameterizedType)t;
                    Type[] args = pt.getActualTypeArguments();
                    for (int i = 0; i < args.length; i++) {
                        if (contextType == args[i]) {
                           
                            InjectionUtils.injectContextFields(cr.getProvider(), cr, m);
                            InjectionUtils.injectContextMethods(cr.getProvider(), cr, m);
View Full Code Here

    public <T> ExceptionMapper<T> createExceptionMapper(Class<?> exceptionType, Message m) {
        for (ProviderInfo<ExceptionMapper> em : userExceptionMappers) {
            Type[] types = em.getProvider().getClass().getGenericInterfaces();
            for (Type t : types) {
                if (t instanceof ParameterizedType) {
                    ParameterizedType pt = (ParameterizedType)t;
                    Type[] args = pt.getActualTypeArguments();
                    for (int i = 0; i < args.length; i++) {
                        if (((Class<?>)args[i]).isAssignableFrom(exceptionType)) {
                            InjectionUtils.injectContextFields(em.getProvider(), em, m);
                            InjectionUtils.injectContextMethods(em.getProvider(), em, m);
                            return em.getProvider();
View Full Code Here

            Type superType = containingClassType.getGenericSuperclass();

            if (superType instanceof ParameterizedType)
            {
                ParameterizedType superPType = (ParameterizedType) superType;

                TypeVariable tv = (TypeVariable) genericType;

                String name = tv.getName();

                TypeVariable[] typeVariables = tv.getGenericDeclaration().getTypeParameters();

                for (int i = 0; i < typeVariables.length; i++)
                {
                    TypeVariable stv = typeVariables[i];

                    // We're trying to match the name of the type variable that is used as the return type
                    // of the method. With that name, we find the corresponding index in the
                    // type declarations. With the index, we check superPType for the Class instance
                    // that defines it. Generics has lots of other options that we simply can't handle.

                    if (stv.getName().equals(name))
                    {
                        Type actualType = superPType.getActualTypeArguments()[i];

                        if (actualType instanceof Class)
                            return (Class) actualType;

                        break;
View Full Code Here

    public static Class<?> getActualType(Type genericType) {
        if (genericType == null
            || !ParameterizedType.class.isAssignableFrom(genericType.getClass())) {
            return null;
        }
        ParameterizedType paramType = (ParameterizedType)genericType;
        return (Class<?>)paramType.getActualTypeArguments()[0];
    }
View Full Code Here

            if (paramType instanceof Class) {
                Class paramClass = (Class)paramType;
                String fullType = "";
                pdc.setParameterType(paramClass.getName());
            } else if (paramType instanceof ParameterizedType) {
                ParameterizedType pt = (ParameterizedType)paramType;
                String fullType = "";
                fullType = ConverterUtils.getFullType(pt, fullType);
                pdc.setParameterType(fullType);
            }
            pdc.setListOrder(i);
View Full Code Here

        if (isJAXWSAsyncClientMethod()) {
            //pooling implementation
            if (Response.class == returnType) {
                if (!isDBC()) {
                    Type type = seiMethod.getGenericReturnType();
                    ParameterizedType pType = (ParameterizedType)type;
                    Type aType = pType.getActualTypeArguments()[0];
                    if (aType != null && ParameterizedType.class.isInstance(aType)) {
                        return (Class)((ParameterizedType)aType).getRawType();
                    }
                    return (Class)aType;
                } else {
                    // FIXME: This doesn't work for DBC.  That's OK for now because DBC isn't used on the client side
                    //        yet; the client is all Java Reflection.  On the Service side, the Async methods are not used.
                    //        This needs to return T for Response<T>, or List for Response<List<T>>>
                    return returnType;
                }
            }
            //Callback Implementation
            else {
                // FIXME: This doesn't work for DBC.  That's OK for now because DBC isn't used on the client side
                //        yet; the client is all Java Reflection.  On the Service side, the Async methods are not used.
                //        This needs to find and return T for AsyncHandler<T>, or List for AsyncHandler<List<T>>>
                Type[] type = getGenericParameterTypes();
                Class parameters[] = getParameterTypes();
                int i = 0;
                for (Class param : parameters) {
                    if (AsyncHandler.class.isAssignableFrom(param)) {
                        ParameterizedType pType = (ParameterizedType)type[i];
                        Type aType = pType.getActualTypeArguments()[0];
                        if (aType != null && ParameterizedType.class.isInstance(aType)) {
                            return (Class)((ParameterizedType)aType).getRawType();
                        }
                        return (Class)aType;
                    }
View Full Code Here

            Type[] exceptionTypes = method.getGenericExceptionTypes();
            String[] exceptions = new String[exceptionTypes.length];
            for (int i = 0; i < exceptionTypes.length; i++) {
                Type type = exceptionTypes[i];
                if (type instanceof ParameterizedType) {
                    ParameterizedType pt = (ParameterizedType)type;
                    String fullType = "";
                    fullType = ConverterUtils.getFullType(pt, fullType);
                    exceptions[i] = fullType;
                } else if (type instanceof Class) {
                    exceptions[i] = ((Class)type).getName();
View Full Code Here

    private void setReturnType(MethodDescriptionComposite mdc, Method method) {
        Type type = method.getGenericReturnType();
        if (type == null) {
            mdc.setReturnType("void");
        } else if (type instanceof ParameterizedType) {
            ParameterizedType pt = (ParameterizedType)type;
            String fullType = "";
            fullType = ConverterUtils.getFullType(pt, fullType);
            mdc.setReturnType(fullType);
        } else if (type instanceof Class) {
            mdc.setReturnType(((Class)type).getName());
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.