當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。