Class Types

java.lang.Object
io.sundr.model.utils.Types

public final class Types extends Object
  • Field Details

    • PACKAGE

      public static final String PACKAGE
      See Also:
    • CLASS_NAME

      public static final String CLASS_NAME
      See Also:
    • F

      public static final TypeParamDef F
    • I

      public static final TypeParamDef I
    • O

      public static final TypeParamDef O
    • B

      public static final TypeParamDef B
    • T

      public static final TypeParamDef T
    • T_REF

      public static final TypeParamRef T_REF
    • N

      public static final TypeParamDef N
    • N_REF

      public static final TypeParamRef N_REF
    • V

      public static final TypeParamDef V
    • VOID

      public static final VoidRef VOID
    • Q

      public static final WildcardRef Q
    • TYPE

      public static final TypeDef TYPE
    • CLASS

      public static final TypeDef CLASS
    • CLASS_REF_NO_ARG

      public static final ClassRef CLASS_REF_NO_ARG
    • ARRAY

      public static final TypeDef ARRAY
    • TYPE_VARIABLE

      public static final TypeDef TYPE_VARIABLE
    • GENERIC_ARRAY_TYPE

      public static final TypeDef GENERIC_ARRAY_TYPE
    • PARAMETERIZED_TYPE

      public static final TypeDef PARAMETERIZED_TYPE
    • OBJECT

      public static final TypeDef OBJECT
    • OBJECT_REF

      public static final ClassRef OBJECT_REF
    • STRING

      public static final TypeDef STRING
    • STRING_REF

      public static final ClassRef STRING_REF
    • BOOLEAN

      public static final TypeDef BOOLEAN
    • BOOLEAN_REF

      public static final TypeRef BOOLEAN_REF
    • BYTE

      public static final TypeDef BYTE
    • BYTE_REF

      public static final ClassRef BYTE_REF
    • CHARACTER

      public static final TypeDef CHARACTER
    • CHARACTER_REF

      public static final ClassRef CHARACTER_REF
    • SHORT

      public static final TypeDef SHORT
    • SHORT_REF

      public static final ClassRef SHORT_REF
    • INT

      public static final TypeDef INT
    • INT_REF

      public static final ClassRef INT_REF
    • LONG

      public static final TypeDef LONG
    • LONG_REF

      public static final ClassRef LONG_REF
    • DOUBLE

      public static final TypeDef DOUBLE
    • DOUBLE_REF

      public static final ClassRef DOUBLE_REF
    • FLOAT

      public static final TypeDef FLOAT
    • FLOAT_REF

      public static final ClassRef FLOAT_REF
    • OPTIONAL

      public static final TypeDef OPTIONAL
    • OPTIONAL_REF

      public TypeRef OPTIONAL_REF
    • PRIMITIVE_BOOLEAN_REF

      public static final PrimitiveRef PRIMITIVE_BOOLEAN_REF
    • PRIMITIVE_BYTE_REF

      public static final PrimitiveRef PRIMITIVE_BYTE_REF
    • PRIMITIVE_CHAR_REF

      public static final PrimitiveRef PRIMITIVE_CHAR_REF
    • PRIMITIVE_SHORT_REF

      public static final PrimitiveRef PRIMITIVE_SHORT_REF
    • PRIMITIVE_INT_REF

      public static final PrimitiveRef PRIMITIVE_INT_REF
    • PRIMITIVE_LONG_REF

      public static final PrimitiveRef PRIMITIVE_LONG_REF
    • PRIMITIVE_DOUBLE_REF

      public static final PrimitiveRef PRIMITIVE_DOUBLE_REF
    • PRIMITIVE_FLOAT_REF

      public static final PrimitiveRef PRIMITIVE_FLOAT_REF
    • PRIMITIVE_TYPES

      public static TypeRef[] PRIMITIVE_TYPES
    • BOXED_PRIMITIVE_TYPES

      public static TypeRef[] BOXED_PRIMITIVE_TYPES
    • BOXED_PARSE_METHOD

      public static String[] BOXED_PARSE_METHOD
  • Method Details

    • box

      public static TypeRef box(TypeRef ref)
    • isInstanceOf

      public static boolean isInstanceOf(TypeRef type, TypeDef targetType, Function<TypeRef,Boolean> function)
      Checks if a TypeDef is an instance of an other TypeDef.
      Parameters:
      type - The type to compare.
      targetType - The target type.
      function -
      Returns:
      true if match, false otherwise.
    • getParameterDefinition

      public static TypeParamDef getParameterDefinition(TypeRef typeRef, Collection<TypeParamDef> parameters)
    • newTypeParamRef

      public static TypeParamRef newTypeParamRef(String letter)
      Creates a new generic TypeParamRef.
      Parameters:
      letter - The letter of the type.
      Returns:
      The param reference.
    • newTypeParamDef

      public static TypeParamDef newTypeParamDef(String letter)
      Creates a new TypeParamDef.
      Parameters:
      letter - The letter of the type.
      Returns:
      The param definition.
    • unwrapGeneric

      public static TypeDef unwrapGeneric(TypeDef base)
      Removes parameters from a TypeDef.
      Parameters:
      base - The base type.
      Returns:
      The unwraped TypeDef.
    • typeGenericOf

      public static TypeDef typeGenericOf(TypeDef base, TypeParamDef... parameters)
      Sets one TypeDef as a generic of an other.
      Parameters:
      base - The base type.
      parameters - The parameter types.
      Returns:
      The generic type.
    • typeExtends

      public static TypeDef typeExtends(TypeDef base, ClassRef superClass)
      Sets one TypeDef as a super class of an other.
      Parameters:
      base - The base type.
      superClass - The super type.
      Returns:
      The updated type definition.
    • typeImplements

      public static TypeDef typeImplements(TypeDef base, ClassRef... superClass)
      Sets one TypeDef as an interface of an other.
      Parameters:
      base - The base type.
      superClass - The super type.
      Returns:
      The updated type definition.
    • fullyQualifiedNameDiff

      public static String fullyQualifiedNameDiff(String left, String right)
    • isEnum

      public static boolean isEnum(TypeRef typeRef)
      Checks a TypeRef is an enum.
      Parameters:
      typeRef - The type to check.
      Returns:
      True if its an enum type.
    • isAbstract

      public static boolean isAbstract(TypeRef typeRef)
      Checks a TypeRef is of an abstract type.
      Parameters:
      typeRef - The type to check.
      Returns:
      True if its an abstract type.
    • isConcrete

      public static boolean isConcrete(TypeRef typeRef)
      Checks if TypeRef is of an concrete
      Parameters:
      typeRef - The type to check.
      Returns:
      True if its an concrete type.
    • isPrimitive

      public static boolean isPrimitive(TypeRef type)
      Checks if a TypeRef is a primitive type.
      Parameters:
      type - The type to check.
      Returns:
      True if its a primitive type.
    • isMap

      public static boolean isMap(TypeRef type)
      Checks if a TypeRef is a Map.
      Parameters:
      type - The type to check.
      Returns:
      True if its a Map.
    • isList

      public static boolean isList(TypeRef type)
      Checks if a TypeRef is a List.
      Parameters:
      type - The type to check.
      Returns:
      True if its a List.
    • isSet

      public static boolean isSet(TypeRef type)
      Checks if a TypeRef is a Set.
      Parameters:
      type - The type to check.
      Returns:
      True if its a Set.
    • isCollection

      public static boolean isCollection(TypeRef type)
      Checks if a TypeRef is a Collection.
      Parameters:
      type - The type to check.
      Returns:
      True if its a Collection.
    • isBoolean

      public static boolean isBoolean(TypeRef type)
      Checks if a TypeRef is a Boolean or boolean.
      Parameters:
      type - The type to check.
      Returns:
      True if its a Boolean or boolean.
    • isArray

      public static boolean isArray(TypeRef type)
      Checks if a TypeRef is an array.
      Parameters:
      type - The type to check.
      Returns:
      True if its an array.B
    • isOptional

      public static boolean isOptional(TypeRef type)
      Checks if a TypeRef is a Optional.
      Parameters:
      type - The type to check.
      Returns:
      True if its a Optional.
    • isOptionalInt

      public static boolean isOptionalInt(TypeRef type)
      Checks if a TypeRef is a OptionalInt.
      Parameters:
      type - The type to check.
      Returns:
      True if its a OptionalInt.
    • isOptionalDouble

      public static boolean isOptionalDouble(TypeRef type)
      Checks if a TypeRef is a OptionalDouble.
      Parameters:
      type - The type to check.
      Returns:
      True if its a OptionalDouble.
    • isOptionalLong

      public static boolean isOptionalLong(TypeRef type)
      Checks if a TypeRef is a OptionalLong.
      Parameters:
      type - The type to check.
      Returns:
      True if its a OptionalLong.
    • isJdkType

      public static boolean isJdkType(TypeRef type)
      Check if type is an internal JDK type.
      Returns:
      true if jdk type, false otherwise.
    • hasMethod

      public static boolean hasMethod(TypeDef typeDef, String method)
      Check if method exists on the specified type.
      Parameters:
      typeDef - The type.
      method - The method name.
      Returns:
      True if method is found, false otherwise.
    • hasProperty

      public static boolean hasProperty(TypeDef typeDef, String property)
      Checks if property exists on the specified type.
      Parameters:
      typeDef - The type.
      property - The property name.
      Returns:
      True if method is found, false otherwise.
    • allProperties

      public static List<Property> allProperties(TypeDef typeDef)
      All properties (including inherited).
      Parameters:
      typeDef - The type.
      Returns:
      A list with all properties.
    • unrollHierarchy

      public static Set<TypeDef> unrollHierarchy(TypeDef typeDef)
      Unrolls the hierararchy of a specified type.
      Parameters:
      typeDef - The specified type.
      Returns:
      A set that contains all the hierarching (including the specified type).
    • toClassName

      public static String toClassName(Object o)
      A utility that tries to get a fully qualified class name from an unknown object.
      Parameters:
      o - The object.
      Returns:
      The classname if found or the string representation of the object.
    • visitParents

      public static void visitParents(TypeDef type, List<TypeDef> types)
    • visitParents

      public static void visitParents(TypeDef type, List<TypeDef> types, List<TypeDef> visited)
    • parsePackage

      public static Optional<String> parsePackage(String content)
    • parseName

      public static Optional<String> parseName(String content)
    • parseFullyQualifiedName

      public static String parseFullyQualifiedName(String content)