com.google.gson.reflect.TypeToken.isAssignableFrom()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(77)

本文整理了Java中com.google.gson.reflect.TypeToken.isAssignableFrom()方法的一些代码示例,展示了TypeToken.isAssignableFrom()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TypeToken.isAssignableFrom()方法的具体详情如下:
包路径:com.google.gson.reflect.TypeToken
类名称:TypeToken
方法名:isAssignableFrom

TypeToken.isAssignableFrom介绍

[英]Check if this type is assignable from the given type token.
[中]检查此类型是否可从给定的类型令牌分配。

代码示例

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Check if this type is assignable from the given class object.
 *
 * @deprecated this implementation may be inconsistent with javac for types
 *     with wildcards.
 */
@Deprecated
public boolean isAssignableFrom(Class<?> cls) {
 return isAssignableFrom((Type) cls);
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Check if this type is assignable from the given type token.
 *
 * @deprecated this implementation may be inconsistent with javac for types
 *     with wildcards.
 */
@Deprecated
public boolean isAssignableFrom(TypeToken<?> token) {
 return isAssignableFrom(token.getType());
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * 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;
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Check if this type is assignable from the given Type.
 *
 * @deprecated this implementation may be inconsistent with javac for types
 *     with wildcards.
 */
@Deprecated
public boolean isAssignableFrom(Type from) {
 if (from == null) {
  return false;
 }
 if (type.equals(from)) {
  return true;
 }
 if (type instanceof Class<?>) {
  return rawType.isAssignableFrom($Gson$Types.getRawType(from));
 } else if (type instanceof ParameterizedType) {
  return isAssignableFrom(from, (ParameterizedType) type,
    new HashMap<String, Type>());
 } else if (type instanceof GenericArrayType) {
  return rawType.isAssignableFrom($Gson$Types.getRawType(from))
    && isAssignableFrom(from, (GenericArrayType) type);
 } else {
  throw buildUnexpectedTypeError(
    type, Class.class, ParameterizedType.class, GenericArrayType.class);
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

if (isAssignableFrom(itype, to, new HashMap<String, Type>(typeVarMap))) {
  return true;
return isAssignableFrom(sType, to, new HashMap<String, Type>(typeVarMap));

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.google.gson

/**
 * Check if this type is assignable from the given class object.
 *
 * @deprecated this implementation may be inconsistent with javac for types
 *     with wildcards.
 */
@Deprecated
public boolean isAssignableFrom(Class<?> cls) {
 return isAssignableFrom((Type) cls);
}

代码示例来源:origin: eatnumber1/google-gson

/**
 * Check if this type is assignable from the given class object.
 *
 * @deprecated this implementation may be inconsistent with javac for types
 *     with wildcards.
 */
@Deprecated
public boolean isAssignableFrom(Class<?> cls) {
 return isAssignableFrom((Type) cls);
}

代码示例来源:origin: Odoo-mobile/framework

/**
 * Check if this type is assignable from the given class object.
 *
 * @deprecated this implementation may be inconsistent with javac for types
 *     with wildcards.
 */
@Deprecated
public boolean isAssignableFrom(Class<?> cls) {
 return isAssignableFrom((Type) cls);
}

代码示例来源:origin: com.google/gson

/**
 * Check if this type is assignable from the given class object.
 *
 * @deprecated this implementation may be inconsistent with javac for types
 *     with wildcards.
 */
@Deprecated
public boolean isAssignableFrom(Class<?> cls) {
 return isAssignableFrom((Type) cls);
}

代码示例来源:origin: Nextdoor/bender

/**
 * Check if this type is assignable from the given class object.
 *
 * @deprecated this implementation may be inconsistent with javac for types
 *     with wildcards.
 */
@Deprecated
public boolean isAssignableFrom(Class<?> cls) {
 return isAssignableFrom((Type) cls);
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
 * Check if this type is assignable from the given class object.
 *
 * @deprecated this implementation may be inconsistent with javac for types
 *     with wildcards.
 */
@Deprecated
public boolean isAssignableFrom(Class<?> cls) {
 return isAssignableFrom((Type) cls);
}

代码示例来源:origin: fesch/CanZE

/**
 * Check if this type is assignable from the given class object.
 *
 * @deprecated this implementation may be inconsistent with javac for types
 *     with wildcards.
 */
@Deprecated
public boolean isAssignableFrom(Class<?> cls) {
 return isAssignableFrom((Type) cls);
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.google.gson

/**
 * Check if this type is assignable from the given type token.
 *
 * @deprecated this implementation may be inconsistent with javac for types
 *     with wildcards.
 */
@Deprecated
public boolean isAssignableFrom(TypeToken<?> token) {
 return isAssignableFrom(token.getType());
}

代码示例来源:origin: Odoo-mobile/framework

/**
 * Check if this type is assignable from the given type token.
 *
 * @deprecated this implementation may be inconsistent with javac for types
 *     with wildcards.
 */
@Deprecated
public boolean isAssignableFrom(TypeToken<?> token) {
 return isAssignableFrom(token.getType());
}

代码示例来源:origin: fesch/CanZE

/**
 * Check if this type is assignable from the given type token.
 *
 * @deprecated this implementation may be inconsistent with javac for types
 *     with wildcards.
 */
@Deprecated
public boolean isAssignableFrom(TypeToken<?> token) {
 return isAssignableFrom(token.getType());
}

代码示例来源:origin: com.google/gson

/**
 * Check if this type is assignable from the given type token.
 *
 * @deprecated this implementation may be inconsistent with javac for types
 *     with wildcards.
 */
@Deprecated
public boolean isAssignableFrom(TypeToken<?> token) {
 return isAssignableFrom(token.getType());
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
 * Check if this type is assignable from the given type token.
 *
 * @deprecated this implementation may be inconsistent with javac for types
 *     with wildcards.
 */
@Deprecated
public boolean isAssignableFrom(TypeToken<?> token) {
 return isAssignableFrom(token.getType());
}

代码示例来源:origin: Nextdoor/bender

/**
 * Check if this type is assignable from the given type token.
 *
 * @deprecated this implementation may be inconsistent with javac for types
 *     with wildcards.
 */
@Deprecated
public boolean isAssignableFrom(TypeToken<?> token) {
 return isAssignableFrom(token.getType());
}

代码示例来源:origin: eatnumber1/google-gson

/**
 * Check if this type is assignable from the given type token.
 *
 * @deprecated this implementation may be inconsistent with javac for types
 *     with wildcards.
 */
@Deprecated
public boolean isAssignableFrom(TypeToken<?> token) {
 return isAssignableFrom(token.getType());
}

代码示例来源:origin: Nextdoor/bender

/**
 * 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;
}

相关文章