模块 wjybxx.base

类 TypeParameterMatcher

java.lang.Object
cn.wjybxx.base.reflect.TypeParameterMatcher

public abstract class TypeParameterMatcher extends Object
类型参数匹配器
作者:
wjybxx date 2023/4/1
  • 构造器详细资料

    • TypeParameterMatcher

      public TypeParameterMatcher()
  • 方法详细资料

    • matchInstance

      public abstract boolean matchInstance(@Nonnull Object instance)
      查询实例是否与泛型参数匹配
      参数:
      instance - 待检测对象
      返回:
      true/false
    • matchType

      public abstract boolean matchType(Class<?> type)
      查询指定类是否是泛型参数的子类
      参数:
      type - 待检查的类型
    • findTypeMatcher

      public static <T> TypeParameterMatcher findTypeMatcher(@Nonnull T instance, @Nonnull Class<? super T> superClazzOrInterface, @Nonnull String typeParamName)
      查找指定泛型参数对应的类型匹配器。
      类型参数:
      T - 约束必须有继承关系或实现关系
      参数:
      instance - superClazzOrInterface的子类实例
      superClazzOrInterface - 泛型参数typeParamName存在的类,class或interface
      typeParamName - 泛型参数名字
      返回:
      如果定义的泛型存在,则返回对应的泛型clazz