Class Types


  • public final class Types
    extends Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static List<io.sundr.model.Property> allProperties​(io.sundr.model.TypeDef typeDef)
      All properties (including inherited).
      static io.sundr.model.TypeRef box​(io.sundr.model.TypeRef ref)  
      static String fullyQualifiedNameDiff​(String left, String right)  
      static io.sundr.model.TypeParamDef getParameterDefinition​(io.sundr.model.TypeRef typeRef, Collection<io.sundr.model.TypeParamDef> parameters)  
      static boolean hasMethod​(io.sundr.model.TypeDef typeDef, String method)
      Check if method exists on the specified type.
      static boolean hasProperty​(io.sundr.model.TypeDef typeDef, String property)
      Checks if property exists on the specified type.
      static boolean isAbstract​(io.sundr.model.TypeRef typeRef)
      Checks a TypeRef is of an abstract type.
      static boolean isArray​(io.sundr.model.TypeRef type)
      Checks if a TypeRef is an array.
      static boolean isBoolean​(io.sundr.model.TypeRef type)
      Checks if a TypeRef is a Boolean or boolean.
      static boolean isCollection​(io.sundr.model.TypeRef type)
      Checks if a TypeRef is a Collection.
      static boolean isConcrete​(io.sundr.model.TypeRef typeRef)
      Checks if TypeRef is of an concrete
      static boolean isEnum​(io.sundr.model.TypeRef typeRef)
      Checks a TypeRef is an enum.
      static boolean isInstanceOf​(io.sundr.model.TypeRef type, io.sundr.model.TypeDef targetType, Function<io.sundr.model.TypeRef,​Boolean> function)
      Checks if a TypeDef is an instance of an other TypeDef.
      static boolean isJdkType​(io.sundr.model.TypeRef type)
      Check if type is an internal JDK type.
      static boolean isList​(io.sundr.model.TypeRef type)
      Checks if a TypeRef is a List.
      static boolean isMap​(io.sundr.model.TypeRef type)
      Checks if a TypeRef is a Map.
      static boolean isOptional​(io.sundr.model.TypeRef type)
      Checks if a TypeRef is a Optional.
      static boolean isOptionalDouble​(io.sundr.model.TypeRef type)
      Checks if a TypeRef is a OptionalDouble.
      static boolean isOptionalInt​(io.sundr.model.TypeRef type)
      Checks if a TypeRef is a OptionalInt.
      static boolean isOptionalLong​(io.sundr.model.TypeRef type)
      Checks if a TypeRef is a OptionalLong.
      static boolean isPrimitive​(io.sundr.model.TypeRef type)
      Checks if a TypeRef is a primitive type.
      static boolean isSet​(io.sundr.model.TypeRef type)
      Checks if a TypeRef is a Set.
      static io.sundr.model.TypeParamDef newTypeParamDef​(String letter)
      Creates a new TypeParamDef.
      static io.sundr.model.TypeParamRef newTypeParamRef​(String letter)
      Creates a new generic TypeParamRef.
      static String parseFullyQualifiedName​(String content)  
      static Optional<String> parseName​(String content)  
      static Optional<String> parsePackage​(String content)  
      static String toClassName​(Object o)
      A utility that tries to get a fully qualified class name from an unknown object.
      static io.sundr.model.TypeDef typeExtends​(io.sundr.model.TypeDef base, io.sundr.model.ClassRef superClass)
      Sets one TypeDef as a super class of an other.
      static io.sundr.model.TypeDef typeGenericOf​(io.sundr.model.TypeDef base, io.sundr.model.TypeParamDef... parameters)
      Sets one TypeDef as a generic of an other.
      static io.sundr.model.TypeDef typeImplements​(io.sundr.model.TypeDef base, io.sundr.model.ClassRef... superClass)
      Sets one TypeDef as an interface of an other.
      static Set<io.sundr.model.TypeDef> unrollHierarchy​(io.sundr.model.TypeDef typeDef)
      Unrolls the hierararchy of a specified type.
      static io.sundr.model.TypeDef unwrapGeneric​(io.sundr.model.TypeDef base)
      Removes parameters from a TypeDef.
      static void visitParents​(io.sundr.model.TypeDef type, List<io.sundr.model.TypeDef> types)  
      static void visitParents​(io.sundr.model.TypeDef type, List<io.sundr.model.TypeDef> types, List<io.sundr.model.TypeDef> visited)  
    • Field Detail

      • F

        public static final io.sundr.model.TypeParamDef F
      • I

        public static final io.sundr.model.TypeParamDef I
      • O

        public static final io.sundr.model.TypeParamDef O
      • B

        public static final io.sundr.model.TypeParamDef B
      • T

        public static final io.sundr.model.TypeParamDef T
      • T_REF

        public static final io.sundr.model.TypeParamRef T_REF
      • N

        public static final io.sundr.model.TypeParamDef N
      • N_REF

        public static final io.sundr.model.TypeParamRef N_REF
      • V

        public static final io.sundr.model.TypeParamDef V
      • VOID

        public static final io.sundr.model.VoidRef VOID
      • Q

        public static final io.sundr.model.WildcardRef Q
      • TYPE

        public static final io.sundr.model.TypeDef TYPE
      • CLASS

        public static final io.sundr.model.TypeDef CLASS
      • CLASS_REF_NO_ARG

        public static final io.sundr.model.ClassRef CLASS_REF_NO_ARG
      • ARRAY

        public static final io.sundr.model.TypeDef ARRAY
      • TYPE_VARIABLE

        public static final io.sundr.model.TypeDef TYPE_VARIABLE
      • GENERIC_ARRAY_TYPE

        public static final io.sundr.model.TypeDef GENERIC_ARRAY_TYPE
      • PARAMETERIZED_TYPE

        public static final io.sundr.model.TypeDef PARAMETERIZED_TYPE
      • OBJECT

        public static final io.sundr.model.TypeDef OBJECT
      • OBJECT_REF

        public static final io.sundr.model.ClassRef OBJECT_REF
      • STRING

        public static final io.sundr.model.TypeDef STRING
      • STRING_REF

        public static final io.sundr.model.ClassRef STRING_REF
      • BOOLEAN

        public static final io.sundr.model.TypeDef BOOLEAN
      • BOOLEAN_REF

        public static final io.sundr.model.TypeRef BOOLEAN_REF
      • BYTE

        public static final io.sundr.model.TypeDef BYTE
      • BYTE_REF

        public static final io.sundr.model.ClassRef BYTE_REF
      • CHARACTER

        public static final io.sundr.model.TypeDef CHARACTER
      • CHARACTER_REF

        public static final io.sundr.model.ClassRef CHARACTER_REF
      • SHORT

        public static final io.sundr.model.TypeDef SHORT
      • SHORT_REF

        public static final io.sundr.model.ClassRef SHORT_REF
      • INT

        public static final io.sundr.model.TypeDef INT
      • INT_REF

        public static final io.sundr.model.ClassRef INT_REF
      • LONG

        public static final io.sundr.model.TypeDef LONG
      • LONG_REF

        public static final io.sundr.model.ClassRef LONG_REF
      • DOUBLE

        public static final io.sundr.model.TypeDef DOUBLE
      • DOUBLE_REF

        public static final io.sundr.model.ClassRef DOUBLE_REF
      • FLOAT

        public static final io.sundr.model.TypeDef FLOAT
      • FLOAT_REF

        public static final io.sundr.model.ClassRef FLOAT_REF
      • OPTIONAL

        public static final io.sundr.model.TypeDef OPTIONAL
      • OPTIONAL_REF

        public io.sundr.model.TypeRef OPTIONAL_REF
      • PRIMITIVE_BOOLEAN_REF

        public static final io.sundr.model.PrimitiveRef PRIMITIVE_BOOLEAN_REF
      • PRIMITIVE_BYTE_REF

        public static final io.sundr.model.PrimitiveRef PRIMITIVE_BYTE_REF
      • PRIMITIVE_CHAR_REF

        public static final io.sundr.model.PrimitiveRef PRIMITIVE_CHAR_REF
      • PRIMITIVE_SHORT_REF

        public static final io.sundr.model.PrimitiveRef PRIMITIVE_SHORT_REF
      • PRIMITIVE_INT_REF

        public static final io.sundr.model.PrimitiveRef PRIMITIVE_INT_REF
      • PRIMITIVE_LONG_REF

        public static final io.sundr.model.PrimitiveRef PRIMITIVE_LONG_REF
      • PRIMITIVE_DOUBLE_REF

        public static final io.sundr.model.PrimitiveRef PRIMITIVE_DOUBLE_REF
      • PRIMITIVE_FLOAT_REF

        public static final io.sundr.model.PrimitiveRef PRIMITIVE_FLOAT_REF
      • PRIMITIVE_TYPES

        public static io.sundr.model.TypeRef[] PRIMITIVE_TYPES
      • BOXED_PRIMITIVE_TYPES

        public static io.sundr.model.TypeRef[] BOXED_PRIMITIVE_TYPES
      • BOXED_PARSE_METHOD

        public static String[] BOXED_PARSE_METHOD
    • Method Detail

      • box

        public static io.sundr.model.TypeRef box​(io.sundr.model.TypeRef ref)
      • isInstanceOf

        public static boolean isInstanceOf​(io.sundr.model.TypeRef type,
                                           io.sundr.model.TypeDef targetType,
                                           Function<io.sundr.model.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 io.sundr.model.TypeParamDef getParameterDefinition​(io.sundr.model.TypeRef typeRef,
                                                                         Collection<io.sundr.model.TypeParamDef> parameters)
      • newTypeParamRef

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

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

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

        public static io.sundr.model.TypeDef typeGenericOf​(io.sundr.model.TypeDef base,
                                                           io.sundr.model.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 io.sundr.model.TypeDef typeExtends​(io.sundr.model.TypeDef base,
                                                         io.sundr.model.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 io.sundr.model.TypeDef typeImplements​(io.sundr.model.TypeDef base,
                                                            io.sundr.model.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​(io.sundr.model.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​(io.sundr.model.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​(io.sundr.model.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​(io.sundr.model.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​(io.sundr.model.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​(io.sundr.model.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​(io.sundr.model.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​(io.sundr.model.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​(io.sundr.model.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​(io.sundr.model.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​(io.sundr.model.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​(io.sundr.model.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​(io.sundr.model.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​(io.sundr.model.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​(io.sundr.model.TypeRef type)
        Check if type is an internal JDK type.
        Returns:
        true if jdk type, false otherwise.
      • hasMethod

        public static boolean hasMethod​(io.sundr.model.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​(io.sundr.model.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<io.sundr.model.Property> allProperties​(io.sundr.model.TypeDef typeDef)
        All properties (including inherited).
        Parameters:
        typeDef - The type.
        Returns:
        A list with all properties.
      • unrollHierarchy

        public static Set<io.sundr.model.TypeDef> unrollHierarchy​(io.sundr.model.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​(io.sundr.model.TypeDef type,
                                        List<io.sundr.model.TypeDef> types)
      • visitParents

        public static void visitParents​(io.sundr.model.TypeDef type,
                                        List<io.sundr.model.TypeDef> types,
                                        List<io.sundr.model.TypeDef> visited)
      • parseFullyQualifiedName

        public static String parseFullyQualifiedName​(String content)