Package java.lang.reflect

Examples of java.lang.reflect.Type


      }
    }

    // try walking the context class to see if we can get the OrmLiteSqliteOpenHelper from a generic parameter
    for (; componentClass != null; componentClass = componentClass.getSuperclass()) {
      Type superType = componentClass.getGenericSuperclass();
      if (superType == null || !(superType instanceof ParameterizedType)) {
        continue;
      }
      // get the generic type arguments
      Type[] types = ((ParameterizedType) superType).getActualTypeArguments();
View Full Code Here


            throws Exception {
        if (value == null)
            return null;
        else if (value instanceof Map) {
            Class<?> itemClass = Object.class;
            Type itemType = null;
            if (type != null && type instanceof ParameterizedType) {
                ParameterizedType ptype = (ParameterizedType) type;
                itemType = ptype.getActualTypeArguments()[1];
                if (itemType.getClass().equals(Class.class)) {
                    itemClass = (Class<?>) itemType;
                } else {
                    itemClass = (Class<?>) ((ParameterizedType) itemType).getRawType();
                }
            }
View Full Code Here

        JSONWebService customizeInfo, Method accessor) throws Exception {
        if (value == null)
            return null;
       
        Class<?> itemClass = Object.class;
        Type itemType = null;
        if (type != null && type instanceof ParameterizedType) {
            ParameterizedType ptype = (ParameterizedType) type;
            itemType = ptype.getActualTypeArguments()[0];
            if (itemType.getClass().equals(Class.class)) {
                itemClass = (Class<?>) itemType;
            } else {
                itemClass = (Class<?>) ((ParameterizedType) itemType).getRawType();
            }
        }
View Full Code Here

    for (Type type : genericInterfaces)
    {
      if (type instanceof ParameterizedType)
      {
        ParameterizedType t = (ParameterizedType) type;
        Type rawType = t.getRawType();

        if (rawType instanceof Class && rawType.equals(genericInterface))
        {
          Type[] actualTypeArguments = t.getActualTypeArguments();

          if (actualTypeArguments.length > 0)
          {
            Type arg = actualTypeArguments[0];

            if (arg instanceof Class)
            {

              Class<Object> expectedType = (Class<Object>) arg;
View Full Code Here

    Type[] actualTypeArguments = getGenericTypes(c, genericInterface);

    if (actualTypeArguments != null && actualTypeArguments.length > 0)
    {
      Type arg = actualTypeArguments[0];

      if (arg instanceof Class)
      {
        Class<Object> specificType = (Class<Object>) arg;
        return specificType;
View Full Code Here

    for (Type type : genericInterfaces)
    {
      if (type instanceof ParameterizedType)
      {
        ParameterizedType t = (ParameterizedType) type;
        Type rawType = t.getRawType();

        if (rawType instanceof Class && rawType.equals(genericInterface))
        {
          genericType = t;
          break;
        }
      }
View Full Code Here

        MappingUtils.throwMappingException(e);
      }
    }

    public Class<?> genericType() {
      Type type = field.getGenericType();
      return ReflectionUtils.determineGenericsType(type);
    }
View Full Code Here

  }

  public static Class<?> determineGenericsType(Method method, boolean isReadMethod) {
    Class<?> result = null;
    if (isReadMethod) {
      Type parameterType = method.getGenericReturnType();
      result = determineGenericsType(parameterType);
    } else {
      Type[] parameterTypes = method.getGenericParameterTypes();
      if (parameterTypes != null) {
        result = determineGenericsType(parameterTypes[0]);
View Full Code Here

  }

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

  /**
   * resolves the generic return type of the method
   */
  private static Class<?> resolveReturnType(final Class<?> targetClass, final Method method) {
    // get the generic return type
    Type type = method.getGenericReturnType();

    // get the actual type argument (expect the type to be a TypeVariable)
    return resolveType(targetClass, type);
  }
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.