Class Types


  • public class Types
    extends Object
    • Constructor Detail

      • Types

        public Types()
    • Method Detail

      • findParameterizedType

        public ParameterizedType findParameterizedType​(Class<?> klass,
                                                       Class<?> parameterizedClass)
        This method helps reconstructing the resulting ParameterizedType for a specific generic type across its hierarchy. Example: Let's create some interface Converter[X, Y] and try to determine the actual type arguments for that interface from classes/interfaces which inherit from it (directly or indirectly).
        • Converter[X, Y] will yield Converter[X, Y]
        • StringConverter[Z] extends Converter[Z, String] will yield Converter[Z, String]
        • AbstractStringConverter[A] implements StringConverter[A] will yield Converter[A, String]
        • UUIDStringConverter extends AbstractStringConverter[UUID] will yield Converter[UUID, String]
        For the last example (UUIDStringConverter), nowhere in its hierarchy is a type directly implementing Converter[UUID, String] but this method is capable of reconstructing that information.
      • resolveArgumentTypes

        private Type[] resolveArgumentTypes​(Type type,
                                            Class<?> parameterizedClass)
      • resolveArgumentTypes

        private Type[] resolveArgumentTypes​(Class<?> type,
                                            Class<?> parameterizedClass)