当前位置: 首页>>代码示例>>Java>>正文


Java GenericArrayType.getGenericComponentType方法代码示例

本文整理汇总了Java中java.lang.reflect.GenericArrayType.getGenericComponentType方法的典型用法代码示例。如果您正苦于以下问题:Java GenericArrayType.getGenericComponentType方法的具体用法?Java GenericArrayType.getGenericComponentType怎么用?Java GenericArrayType.getGenericComponentType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.lang.reflect.GenericArrayType的用法示例。


在下文中一共展示了GenericArrayType.getGenericComponentType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: canonicalize

import java.lang.reflect.GenericArrayType; //导入方法依赖的package包/类
/**
 * Returns a type that is functionally equal but not necessarily equal according to {@link
 * Object#equals(Object) Object.equals()}.
 */
private static Type canonicalize(Type type) {
  if (type instanceof Class) {
    Class<?> c = (Class<?>) type;
    return c.isArray() ? new GenericArrayTypeImpl(canonicalize(c.getComponentType())) : c;
  } else if (type instanceof ParameterizedType) {
    if (type instanceof ParameterizedTypeImpl) return type;
    ParameterizedType p = (ParameterizedType) type;
    return new ParameterizedTypeImpl(p.getOwnerType(),
      p.getRawType(), p.getActualTypeArguments());
  } else if (type instanceof GenericArrayType) {
    if (type instanceof GenericArrayTypeImpl) return type;
    GenericArrayType g = (GenericArrayType) type;
    return new GenericArrayTypeImpl(g.getGenericComponentType());
  } else if (type instanceof WildcardType) {
    if (type instanceof WildcardTypeImpl) return type;
    WildcardType w = (WildcardType) type;
    return new WildcardTypeImpl(w.getUpperBounds(), w.getLowerBounds());
  } else {
    return type; // This type is unsupported!
  }
}
 
开发者ID:rogues-dev,项目名称:hoard,代码行数:26,代码来源:Types.java

示例2: canonicalize

import java.lang.reflect.GenericArrayType; //导入方法依赖的package包/类
/**
 * Returns a type that is functionally equal but not necessarily equal
 * according to {@link Object#equals(Object) Object.equals()}. The returned
 * type is {@link java.io.Serializable}.
 */
public static Type canonicalize(Type type) {
  if (type instanceof Class) {
    Class<?> c = (Class<?>) type;
    return c.isArray() ? new GenericArrayTypeImpl(canonicalize(c.getComponentType())) : c;

  } else if (type instanceof ParameterizedType) {
    ParameterizedType p = (ParameterizedType) type;
    return new ParameterizedTypeImpl(p.getOwnerType(),
        p.getRawType(), p.getActualTypeArguments());

  } else if (type instanceof GenericArrayType) {
    GenericArrayType g = (GenericArrayType) type;
    return new GenericArrayTypeImpl(g.getGenericComponentType());

  } else if (type instanceof WildcardType) {
    WildcardType w = (WildcardType) type;
    return new WildcardTypeImpl(w.getUpperBounds(), w.getLowerBounds());

  } else {
    // type is either serializable as-is or unsupported
    return type;
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:$Gson$Types.java

示例3: getItemType

import java.lang.reflect.GenericArrayType; //导入方法依赖的package包/类
public TypeInfo getItemType() {
        if (type instanceof Class && ((Class)type).isArray() && !byte[].class.equals(type)) {
            Type componentType = ((Class)type).getComponentType();
            Type genericComponentType = null;
            if (genericType!= null && genericType instanceof GenericArrayType) {
                GenericArrayType arrayType = (GenericArrayType) type;
                genericComponentType = arrayType.getGenericComponentType();
                componentType = arrayType.getGenericComponentType();
            }
            TypeInfo ti =new TypeInfo(tagName, componentType, annotations);
            if (genericComponentType != null) ti.setGenericType(genericComponentType);
            for(Annotation anno : annotations) if (anno instanceof XmlElementWrapper) ti.wrapperType = this;
            return ti;
        }
//        if (type instanceof Class && java.util.Collection.class.isAssignableFrom((Class)type)) {
        Type t = (genericType != null)? genericType : type;
        Type base = Utils.REFLECTION_NAVIGATOR.getBaseClass(t, Collection.class);
        if ( base != null)  {
            return new TypeInfo(tagName, Utils.REFLECTION_NAVIGATOR.getTypeArgument(base,0), annotations);
        }
        return null;
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:TypeInfo.java

示例4: canonicalize

import java.lang.reflect.GenericArrayType; //导入方法依赖的package包/类
/**
 * Returns a type that is functionally equal but not necessarily equal
 * according to {@link Object#equals(Object) Object.equals()}. The returned
 * type is {@link Serializable}.
 */
public static Type canonicalize(Type type) {
  if (type instanceof Class) {
    Class<?> c = (Class<?>) type;
    return c.isArray() ? new GenericArrayTypeImpl(canonicalize(c.getComponentType())) : c;

  } else if (type instanceof CompositeType) {
    return type;

  } else if (type instanceof ParameterizedType) {
    ParameterizedType p = (ParameterizedType) type;
    return new ParameterizedTypeImpl(p.getOwnerType(),
        p.getRawType(), p.getActualTypeArguments());

  } else if (type instanceof GenericArrayType) {
    GenericArrayType g = (GenericArrayType) type;
    return new GenericArrayTypeImpl(g.getGenericComponentType());

  } else if (type instanceof WildcardType) {
    WildcardType w = (WildcardType) type;
    return new WildcardTypeImpl(w.getUpperBounds(), w.getLowerBounds());

  } else {
    // type is either serializable as-is or unsupported
    return type;
  }
}
 
开发者ID:maetrive,项目名称:businessworks,代码行数:32,代码来源:MoreTypes.java

示例5: isAssignableFrom

import java.lang.reflect.GenericArrayType; //导入方法依赖的package包/类
private static boolean isAssignableFrom(Type from, GenericArrayType to) {
    Type toGenericComponentType = to.getGenericComponentType();
    if (!(toGenericComponentType instanceof ParameterizedType)) {
        return true;
    }
    Type t = from;
    if (from instanceof GenericArrayType) {
        t = ((GenericArrayType) from).getGenericComponentType();
    } else if (from instanceof Class) {
        Class<?> classType = (Class) from;
        while (classType.isArray()) {
            classType = classType.getComponentType();
        }
        Object t2 = classType;
    }
    return isAssignableFrom(t, (ParameterizedType) toGenericComponentType, new HashMap());
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:18,代码来源:TypeToken.java

示例6: canonicalize

import java.lang.reflect.GenericArrayType; //导入方法依赖的package包/类
/**
 * Returns a type that is functionally equal but not necessarily equal
 * according to {@link Object#equals(Object) Object.equals()}. The returned
 * type is {@link Serializable}.
 */
public static Type canonicalize(Type type) {
  if (type instanceof Class) {
    Class<?> c = (Class<?>) type;
    return c.isArray() ? new GenericArrayTypeImpl(canonicalize(c.getComponentType())) : c;

  } else if (type instanceof ParameterizedType) {
    ParameterizedType p = (ParameterizedType) type;
    return new ParameterizedTypeImpl(p.getOwnerType(),
        p.getRawType(), p.getActualTypeArguments());

  } else if (type instanceof GenericArrayType) {
    GenericArrayType g = (GenericArrayType) type;
    return new GenericArrayTypeImpl(g.getGenericComponentType());

  } else if (type instanceof WildcardType) {
    WildcardType w = (WildcardType) type;
    return new WildcardTypeImpl(w.getUpperBounds(), w.getLowerBounds());

  } else {
    // type is either serializable as-is or unsupported
    return type;
  }
}
 
开发者ID:odoo-mobile-intern,项目名称:odoo-work,代码行数:29,代码来源:$Gson$Types.java

示例7: isAssignableFrom

import java.lang.reflect.GenericArrayType; //导入方法依赖的package包/类
/**
 * Private helper function that performs some assignability checks for
 * the provided GenericArrayType.
 */
private static boolean isAssignableFrom(Type from, GenericArrayType to) {
  Type toGenericComponentType = to.getGenericComponentType();
  if (toGenericComponentType instanceof ParameterizedType) {
    Type t = from;
    if (from instanceof GenericArrayType) {
      t = ((GenericArrayType) from).getGenericComponentType();
    } else if (from instanceof Class<?>) {
      Class<?> classType = (Class<?>) from;
      while (classType.isArray()) {
        classType = classType.getComponentType();
      }
      t = classType;
    }
    return isAssignableFrom(t, (ParameterizedType) toGenericComponentType,
        new HashMap<String, Type>());
  }
  // No generic defined on "to"; therefore, return true and let other
  // checks determine assignability
  return true;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:TypeToken.java

示例8: getItemType

import java.lang.reflect.GenericArrayType; //导入方法依赖的package包/类
public TypeInfo getItemType() {
//      System.out.println("????? TypeInfo " + type);
        if (type instanceof Class && ((Class)type).isArray() && !byte[].class.equals(type)) {
            Type componentType = ((Class)type).getComponentType();
            Type genericComponentType = null;
            if (genericType!= null && genericType instanceof GenericArrayType) {
                GenericArrayType arrayType = (GenericArrayType) type;
                genericComponentType = arrayType.getGenericComponentType();
                componentType = arrayType.getGenericComponentType();
            }
            TypeInfo ti =new TypeInfo(tagName, componentType, annotations);
            if (genericComponentType != null) ti.setGenericType(genericComponentType);
            return ti;
        }
//        if (type instanceof Class && java.util.Collection.class.isAssignableFrom((Class)type)) {
        Type t = (genericType != null)? genericType : type;
        Type base = Utils.REFLECTION_NAVIGATOR.getBaseClass(t, Collection.class);
        if ( base != null)  {
            return new TypeInfo(tagName, Utils.REFLECTION_NAVIGATOR.getTypeArgument(base,0), annotations);
        }
        return null;
    }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:TypeInfo.java

示例9: ultimateComponentType

import java.lang.reflect.GenericArrayType; //导入方法依赖的package包/类
private static Type ultimateComponentType(GenericArrayType gat) {
  Type component = gat.getGenericComponentType();
  if (component instanceof GenericArrayType)
    return ultimateComponentType((GenericArrayType) component);
  else
    return component;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:8,代码来源:OpenTypeConverter.java

示例10: canonicalize

import java.lang.reflect.GenericArrayType; //导入方法依赖的package包/类
/**
 * Returns a type that is functionally equal but not necessarily equal
 * according to {@link Object#equals(Object) Object.equals()}.
 */
public static Type canonicalize(Type type) {
    if (type instanceof ParameterizedTypeImpl
            || type instanceof GenericArrayTypeImpl
            || type instanceof WildcardTypeImpl) {
        return type;

    } else if (type instanceof ParameterizedType) {
        ParameterizedType p = (ParameterizedType) type;
        return new ParameterizedTypeImpl(p.getOwnerType(),
                p.getRawType(), p.getActualTypeArguments());

    } else if (type instanceof GenericArrayType) {
        GenericArrayType g = (GenericArrayType) type;
        return new GenericArrayTypeImpl(g.getGenericComponentType());

    } else if (type instanceof Class && ((Class<?>) type).isArray()) {
        Class<?> c = (Class<?>) type;
        return new GenericArrayTypeImpl(c.getComponentType());

    } else if (type instanceof WildcardType) {
        WildcardType w = (WildcardType) type;
        return new WildcardTypeImpl(w.getUpperBounds(), w.getLowerBounds());

    } else {
        // type is either serializable as-is or unsupported
        return type;
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:33,代码来源:MoreTypes.java

示例11: getArrayType

import java.lang.reflect.GenericArrayType; //导入方法依赖的package包/类
public Type getArrayType() {
    Class<?> clazz = Cast.as(type, Class.class);
    if (clazz != null) {
        return clazz.getComponentType();
    }
    GenericArrayType gat = Cast.as(type, GenericArrayType.class);
    if (gat != null) {
        return gat.getGenericComponentType();
    }
    return null;
}
 
开发者ID:monPlan,项目名称:springboot-spwa-gae-demo,代码行数:12,代码来源:ParameterDescription.java

示例12: equals

import java.lang.reflect.GenericArrayType; //导入方法依赖的package包/类
@Override
public boolean equals(Object o) {
  if (o instanceof GenericArrayType) {
    GenericArrayType that = (GenericArrayType) o;

    Type thatComponentType = that.getGenericComponentType();
    return componentType == null ? thatComponentType == null : componentType.equals(thatComponentType);
  } else {
    return false;
  }
}
 
开发者ID:XDean,项目名称:Java-EX,代码行数:12,代码来源:GenericArrayTypeImpl.java

示例13: testResolveToGenericArrayType

import java.lang.reflect.GenericArrayType; //导入方法依赖的package包/类
public void testResolveToGenericArrayType() {
  GenericArrayType arrayType = (GenericArrayType)
      new Holder<List<int[][]>[]>() {}.getContentType();
  ParameterizedType listType = (ParameterizedType)
      arrayType.getGenericComponentType();
  assertEquals(List.class, listType.getRawType());
  assertEquals(Types.newArrayType(int[].class),
      listType.getActualTypeArguments()[0]);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:10,代码来源:TypeTokenResolutionTest.java

示例14: equals

import java.lang.reflect.GenericArrayType; //导入方法依赖的package包/类
@Override
public boolean equals(Object o) {
    if (o instanceof GenericArrayType) {
        GenericArrayType that = (GenericArrayType) o;

        Type thatComponentType = that.getGenericComponentType();
        return genericComponentType.equals(thatComponentType);
    } else
        return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:GenericArrayTypeImpl.java

示例15: equals

import java.lang.reflect.GenericArrayType; //导入方法依赖的package包/类
@Override
public boolean equals(Object o) {
    if (o instanceof GenericArrayType) {
        GenericArrayType that = (GenericArrayType) o;

        Type thatComponentType = that.getGenericComponentType();
        return genericComponentType == null ?
            thatComponentType == null :
            genericComponentType.equals(thatComponentType);
    } else
        return false;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:13,代码来源:GenericArrayTypeImpl.java


注:本文中的java.lang.reflect.GenericArrayType.getGenericComponentType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。