Class Type<T>

java.lang.Object
com.strobel.reflection.MemberInfo
com.strobel.reflection.Type<T>
All Implemented Interfaces:
AnnotatedElement, Type
Direct Known Subclasses:
ArrayType, BottomType, CapturedType, CompoundType, ErasedType, GenericParameter, GenericParameterBuilder, GenericType, NullType, PrimitiveType, ReflectedType, RuntimeType, TypeBuilder, TypeBuilderInstantiation, WildcardType

public abstract class Type<T> extends MemberInfo implements Type
  • Field Details

    • DefaultBinder

      public static final Binder DefaultBinder
      /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    • Delimiter

      public static final char Delimiter
      See Also:
    • Value

      public static final Missing Value
    • EmptyTypes

      public static final Type<?>[] EmptyTypes
    • Bottom

      @Deprecated public static final Type<?> Bottom
      Deprecated.
      Use bottomType() instead.
    • NullType

      @Deprecated public static final Type<?> NullType
      Deprecated.
      Use nullType() instead.
    • EmptyObjects

      protected static final Object[] EmptyObjects
    • EmptyStrings

      protected static final String[] EmptyStrings
    • EmptyMethods

      protected static final MethodInfo[] EmptyMethods
    • EmptyConstructors

      protected static final ConstructorInfo[] EmptyConstructors
    • EmptyFields

      protected static final FieldInfo[] EmptyFields
    • EmptyMembers

      protected static final MemberInfo[] EmptyMembers
    • DefaultLookup

      protected static final Set<BindingFlags> DefaultLookup
    • _interfaces

      private TypeList _interfaces
    • _erasedType

      private ErasedType<T> _erasedType
    • CACHE_LOCK

      static final Object CACHE_LOCK
      /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    • CACHE

      static final TypeCache CACHE
    • RESOLVER

      static final Resolver RESOLVER
    • PRIMITIVE_TYPES

      static final Type<?>[] PRIMITIVE_TYPES
    • TYPE_BINDER

      static final TypeBinder TYPE_BINDER
    • _cache

      private RuntimeTypeCache<T> _cache
      /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    • FilterNameIgnoreCase

      public static final MemberFilter FilterNameIgnoreCase
    • FilterName

      public static final MemberFilter FilterName
    • FilterRawMember

      public static final MemberFilter FilterRawMember
    • FilterMethodOverride

      public static final MemberFilter FilterMethodOverride
  • Constructor Details

    • Type

      protected Type()
      /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  • Method Details

    • bottomType

      public static Type<?> bottomType()
    • nullType

      public static Type<?> nullType()
    • unboundedWildcard

      public static WildcardType<?> unboundedWildcard()
    • getMemberType

      public MemberType getMemberType()
      /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      Specified by:
      getMemberType in class MemberInfo
    • isNested

      public boolean isNested()
    • isLocalClass

      public boolean isLocalClass()
    • isVisible

      public boolean isVisible()
    • isClass

      public final boolean isClass()
    • isInterface

      public final boolean isInterface()
    • isEnum

      public final boolean isEnum()
    • isAbstract

      public final boolean isAbstract()
    • isArray

      public boolean isArray()
    • isGenericType

      public boolean isGenericType()
    • isGenericTypeDefinition

      public boolean isGenericTypeDefinition()
    • isRawType

      public boolean isRawType()
    • isGenericParameter

      public boolean isGenericParameter()
    • isPrimitive

      public boolean isPrimitive()
    • hasElementType

      public boolean hasElementType()
    • getKind

      public TypeKind getKind()
    • getBaseType

      public Type<? super T> getBaseType()
    • getInterfaces

      public TypeList getInterfaces()
    • getExplicitInterfaces

      public TypeList getExplicitInterfaces()
    • getErasedClass

      public Class<T> getErasedClass()
    • newInstance

      public T newInstance(Object... arguments)
    • getDeclaringMethod

      public MethodBase getDeclaringMethod()
    • getUnderlyingType

      @NotNull public final Type<?> getUnderlyingType()
    • getUnderlyingTypeCore

      @NotNull protected Type<?> getUnderlyingTypeCore()
    • getElementType

      public Type<?> getElementType()
    • getGenericParameterPosition

      public int getGenericParameterPosition()
    • getTypeBindings

      protected TypeBindings getTypeBindings()
    • getTypeArguments

      public TypeList getTypeArguments()
    • getGenericTypeParameters

      public TypeList getGenericTypeParameters()
    • getGenericTypeDefinition

      public Type<?> getGenericTypeDefinition()
    • containsGenericParameters

      public boolean containsGenericParameters()
    • containsGenericParameter

      public boolean containsGenericParameter(Type<?> genericParameter)
    • isBoundedType

      public boolean isBoundedType()
    • isUnbounded

      public boolean isUnbounded()
    • hasExtendsBound

      public boolean hasExtendsBound()
    • hasSuperBound

      public boolean hasSuperBound()
    • getExtendsBound

      public Type<?> getExtendsBound()
    • getSuperBound

      public Type<?> getSuperBound()
    • isEquivalentTo

      public final boolean isEquivalentTo(MemberInfo m)
      Overrides:
      isEquivalentTo in class MemberInfo
    • isEquivalentTo

      public boolean isEquivalentTo(Type<?> other)
    • isSubTypeOf

      public boolean isSubTypeOf(Type<?> type)
    • isInstance

      public boolean isInstance(Object o)
    • implementsInterface

      public boolean implementsInterface(Type<?> interfaceType)
    • isAssignableFrom

      public boolean isAssignableFrom(Type<?> type)
    • getPackage

      public Package getPackage()
    • isCompoundType

      public boolean isCompoundType()
    • isWildcardType

      public boolean isWildcardType()
    • isSynthetic

      public boolean isSynthetic()
    • accept

      public <P,R> R accept(TypeVisitor<P,R> visitor, P parameter)
    • getAnnotation

      public <A extends Annotation> A getAnnotation(Class<A> annotationClass)
      /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      Specified by:
      getAnnotation in interface AnnotatedElement
      Overrides:
      getAnnotation in class MemberInfo
    • getAnnotations

      @NotNull public Annotation[] getAnnotations()
      Specified by:
      getAnnotations in interface AnnotatedElement
      Overrides:
      getAnnotations in class MemberInfo
    • getDeclaredAnnotations

      @NotNull public Annotation[] getDeclaredAnnotations()
      Specified by:
      getDeclaredAnnotations in interface AnnotatedElement
      Overrides:
      getDeclaredAnnotations in class MemberInfo
    • isAnnotationPresent

      public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass)
      Specified by:
      isAnnotationPresent in interface AnnotatedElement
      Overrides:
      isAnnotationPresent in class MemberInfo
    • getMember

      public final MemberList<?> getMember(String name)
      /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    • getMember

      public final MemberList<?> getMember(String name, MemberType memberType, MemberType... memberTypes)
    • getMember

      public MemberList<?> getMember(String name, Set<BindingFlags> bindingFlags, Set<MemberType> memberTypes)
    • getField

      public final FieldInfo getField(String name)
    • getField

      public FieldInfo getField(String name, Set<BindingFlags> bindingFlags)
    • getMethod

      public final MethodInfo getMethod(String name, Type<?>... parameterTypes)
    • getMethod

      public final MethodInfo getMethod(String name, Set<BindingFlags> bindingFlags, Type<?>... parameterTypes)
    • getMethod

      public MethodInfo getMethod(String name, Set<BindingFlags> bindingFlags, CallingConvention callingConvention, Type<?>... parameterTypes)
    • getConstructor

      public final ConstructorInfo getConstructor(Type<?>... parameterTypes)
    • getConstructor

      public final ConstructorInfo getConstructor(Set<BindingFlags> bindingFlags, Type<?>... parameterTypes)
    • getConstructor

      public ConstructorInfo getConstructor(Set<BindingFlags> bindingFlags, CallingConvention callingConvention, Type<?>... parameterTypes)
    • getMembers

      public final MemberList<?> getMembers()
    • getMembersOfType

      public final MemberList<?> getMembersOfType(Set<MemberType> memberTypes)
    • getMembers

      public final MemberList<?> getMembers(MemberType memberType, MemberType... memberTypes)
    • getMembers

      public final MemberList<?> getMembers(Set<BindingFlags> bindingFlags)
    • getMembers

      public final MemberList<?> getMembers(Set<BindingFlags> bindingFlags, MemberType memberType, MemberType... memberTypes)
    • getMembers

      public MemberList<?> getMembers(Set<BindingFlags> bindingFlags, Set<MemberType> memberTypes)
    • findMembers

      public MemberList<? extends MemberInfo> findMembers(Set<MemberType> memberTypes, Set<BindingFlags> bindingAttr, MemberFilter filter, Object filterCriteria)
    • getFields

      public final FieldList getFields()
    • getFields

      public FieldList getFields(Set<BindingFlags> bindingFlags)
    • getMethods

      public final MethodList getMethods()
    • getMethods

      public final MethodList getMethods(Set<BindingFlags> bindingFlags)
    • getMethods

      public MethodList getMethods(Set<BindingFlags> bindingFlags, CallingConvention callingConvention)
    • getConstructors

      public final ConstructorList getConstructors()
    • getConstructors

      public ConstructorList getConstructors(Set<BindingFlags> bindingFlags)
    • getNestedTypes

      public final TypeList getNestedTypes()
    • getNestedTypes

      public TypeList getNestedTypes(Set<BindingFlags> bindingFlags)
    • getNestedType

      public final Type<?> getNestedType(String fullName)
    • getNestedType

      public Type<?> getNestedType(String fullName, Set<BindingFlags> bindingFlags)
    • getEnumConstants

      public Object[] getEnumConstants()
    • getEnumNames

      public String[] getEnumNames()
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class MemberInfo
    • makeArrayType

      public final Type<T[]> makeArrayType()
      /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    • createArrayType

      protected Type<T[]> createArrayType()
    • makeGenericType

      public final <U extends T> Type<U> makeGenericType(TypeList typeArguments)
    • makeGenericType

      public final <U extends T> Type<U> makeGenericType(Type<?>... typeArguments)
    • getErasedType

      public final Type<?> getErasedType()
    • makeGenericTypeCore

      protected Type<?> makeGenericTypeCore(TypeList typeArguments)
    • substitute

      protected static Type<?> substitute(Type<?> type, TypeBindings typeBindings)
    • asSuperTypeOf

      public Type<?> asSuperTypeOf(@NotNull Type<?> type)
    • getRootElementType

      Type<?> getRootElementType()
      /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    • getMostSpecificType

      Type<?> getMostSpecificType(Type<?> t1, Type<?> t2)
    • toString

      public String toString()
      /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      Overrides:
      toString in class MemberInfo
    • getName

      public String getName()
      Specified by:
      getName in class MemberInfo
    • getClassFullName

      protected String getClassFullName()
    • getClassSimpleName

      protected String getClassSimpleName()
    • getShortName

      public String getShortName()
    • getFullName

      public String getFullName()
    • getInternalName

      public String getInternalName()
    • getGenericSignature

      public String getGenericSignature()
      Method that returns full generic signature of the type; suitable as signature for things like ASM package.
    • appendBriefDescription

      public StringBuilder appendBriefDescription(StringBuilder sb)
      Specified by:
      appendBriefDescription in class MemberInfo
    • appendSimpleDescription

      public StringBuilder appendSimpleDescription(StringBuilder sb)
      Specified by:
      appendSimpleDescription in class MemberInfo
    • appendErasedDescription

      public StringBuilder appendErasedDescription(StringBuilder sb)
      Specified by:
      appendErasedDescription in class MemberInfo
    • appendDescription

      public StringBuilder appendDescription(StringBuilder sb)
      Specified by:
      appendDescription in class MemberInfo
    • appendSignature

      public StringBuilder appendSignature(StringBuilder sb)
      Specified by:
      appendSignature in class MemberInfo
    • appendGenericSignature

      public StringBuilder appendGenericSignature(StringBuilder sb)
      Overrides:
      appendGenericSignature in class MemberInfo
    • invalidateCaches

      protected void invalidateCaches()
      Description copied from class: MemberInfo
      Invalidate any cached type/member information. This is not guaranteed to be thread-safe, should only be called when a partially constructed type/member definition changes (e.g., a TypeBuilder, MethodBuilder, etc.).
      Overrides:
      invalidateCaches in class MemberInfo
    • appendErasedSignature

      public StringBuilder appendErasedSignature(StringBuilder sb)
      Specified by:
      appendErasedSignature in class MemberInfo
    • _appendClassSignature

      protected StringBuilder _appendClassSignature(StringBuilder sb)
    • _appendErasedClassSignature

      protected StringBuilder _appendErasedClassSignature(StringBuilder sb)
    • _appendClassDescription

      protected StringBuilder _appendClassDescription(StringBuilder sb)
    • _appendClassName

      protected StringBuilder _appendClassName(StringBuilder sb, boolean fullName, boolean dottedName)
    • of

      public static <T> Type<T> of(Class<T> clazz)
    • forName

      public static Type<?> forName(String name)
    • forName

      public static Type<?> forName(String name, boolean throwOnError)
    • resolveClassType

      private static Type<?> resolveClassType(Class<?> actualClass)
    • getType

      public static <T> Type<T> getType(T object)
    • of

      static <T> Type<T> of(Type type)
    • tryFind

      static Type<?> tryFind(Type type)
    • makeExtendsWildcard

      public static <T> Type<? extends T> makeExtendsWildcard(Type<T> bound)
    • makeSuperWildcard

      public static <T> Type<? super T> makeSuperWildcard(Type<T> bound)
    • makeWildcard

      public static WildcardType<?> makeWildcard()
    • makeArrayType

      public static <T> Type<T[]> makeArrayType(Type<T> elementType)
    • makeCompoundType

      public static Type<?> makeCompoundType(TypeList bounds)
    • makeCompoundType

      public static Type<?> makeCompoundType(Type<?> baseType, TypeList interfaces)
    • makeCompoundTypeCore

      private static <T> Type<T> makeCompoundTypeCore(Type<T> baseType, TypeList interfaces)
    • list

      public static TypeList list(Class<?>... classes)
      /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    • list

      public static TypeList list(Type<?>... types)
    • list

      public static TypeList list(List<? extends Type<?>> types)
    • getCache

      final RuntimeTypeCache<T> getCache()
    • getDeclaredConstructors

      protected ConstructorList getDeclaredConstructors()
    • getDeclaredMethods

      protected MethodList getDeclaredMethods()
    • getDeclaredFields

      protected FieldList getDeclaredFields()
    • getDeclaredTypes

      protected TypeList getDeclaredTypes()
    • getMethodBaseCandidates

      private <M extends MethodBase> M[] getMethodBaseCandidates(MemberType type, String name, Set<BindingFlags> bindingFlags, CallingConvention callingConvention, Type<?>[] parameterTypes, boolean allowPrefixLookup)
    • getFieldCandidates

      private FieldInfo[] getFieldCandidates(String name, Set<BindingFlags> bindingFlags, boolean allowPrefixLookup)
    • getNestedTypeCandidates

      private Type<?>[] getNestedTypeCandidates(String fullName, Set<BindingFlags> bindingFlags, boolean allowPrefixLookup)
    • filterMethodBase

      boolean filterMethodBase(MethodBase method, Set<BindingFlags> methodFlags, Set<BindingFlags> bindingFlags, CallingConvention callingConventions, Type<?>... argumentTypes)
    • filterApplyType

      private boolean filterApplyType(Type<?> type, Set<BindingFlags> bindingFlags, String name, boolean prefixLookup)
    • filterApplyCore

      private boolean filterApplyCore(MemberInfo member, Set<BindingFlags> bindingFlags, boolean isPublic, boolean isPackagePrivate, boolean isStatic, String name, boolean prefixLookup)
    • filterApplyPrefixLookup

      private boolean filterApplyPrefixLookup(MemberInfo method, String name, boolean ignoreCase)
    • getFilterOptions

      private static Type.FilterOptions getFilterOptions(String name, Set<BindingFlags> bindingFlags, boolean allowPrefixLookup)
    • filterPreCalculate

      static Set<BindingFlags> filterPreCalculate(boolean isPublic, boolean isInherited, boolean isStatic)