Package io.sundr.model.utils
Class Types
- java.lang.Object
-
- io.sundr.model.utils.Types
-
public final class Types extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static io.sundr.model.TypeDefARRAYstatic io.sundr.model.TypeParamDefBstatic io.sundr.model.TypeDefBOOLEANstatic io.sundr.model.TypeRefBOOLEAN_REFstatic String[]BOXED_PARSE_METHODstatic io.sundr.model.TypeRef[]BOXED_PRIMITIVE_TYPESstatic io.sundr.model.TypeDefBYTEstatic io.sundr.model.ClassRefBYTE_REFstatic io.sundr.model.TypeDefCHARACTERstatic io.sundr.model.ClassRefCHARACTER_REFstatic io.sundr.model.TypeDefCLASSstatic StringCLASS_NAMEstatic io.sundr.model.ClassRefCLASS_REF_NO_ARGstatic io.sundr.model.TypeDefDOUBLEstatic io.sundr.model.ClassRefDOUBLE_REFstatic io.sundr.model.TypeParamDefFstatic io.sundr.model.TypeDefFLOATstatic io.sundr.model.ClassRefFLOAT_REFstatic io.sundr.model.TypeDefGENERIC_ARRAY_TYPEstatic io.sundr.model.TypeParamDefIstatic io.sundr.model.TypeDefINTstatic io.sundr.model.ClassRefINT_REFstatic io.sundr.model.TypeDefLONGstatic io.sundr.model.ClassRefLONG_REFstatic io.sundr.model.TypeParamDefNstatic io.sundr.model.TypeParamRefN_REFstatic io.sundr.model.TypeParamDefOstatic io.sundr.model.TypeDefOBJECTstatic io.sundr.model.ClassRefOBJECT_REFstatic io.sundr.model.TypeDefOPTIONALio.sundr.model.TypeRefOPTIONAL_REFstatic StringPACKAGEstatic io.sundr.model.TypeDefPARAMETERIZED_TYPEstatic io.sundr.model.PrimitiveRefPRIMITIVE_BOOLEAN_REFstatic io.sundr.model.PrimitiveRefPRIMITIVE_BYTE_REFstatic io.sundr.model.PrimitiveRefPRIMITIVE_CHAR_REFstatic io.sundr.model.PrimitiveRefPRIMITIVE_DOUBLE_REFstatic io.sundr.model.PrimitiveRefPRIMITIVE_FLOAT_REFstatic io.sundr.model.PrimitiveRefPRIMITIVE_INT_REFstatic io.sundr.model.PrimitiveRefPRIMITIVE_LONG_REFstatic io.sundr.model.PrimitiveRefPRIMITIVE_SHORT_REFstatic io.sundr.model.TypeRef[]PRIMITIVE_TYPESstatic io.sundr.model.WildcardRefQstatic io.sundr.model.TypeDefSHORTstatic io.sundr.model.ClassRefSHORT_REFstatic io.sundr.model.TypeDefSTRINGstatic io.sundr.model.ClassRefSTRING_REFstatic io.sundr.model.TypeParamDefTstatic io.sundr.model.TypeParamRefT_REFstatic io.sundr.model.TypeDefTYPEstatic io.sundr.model.TypeDefTYPE_VARIABLEstatic io.sundr.model.TypeParamDefVstatic io.sundr.model.VoidRefVOID
-
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.TypeRefbox(io.sundr.model.TypeRef ref)static StringfullyQualifiedNameDiff(String left, String right)static io.sundr.model.TypeParamDefgetParameterDefinition(io.sundr.model.TypeRef typeRef, Collection<io.sundr.model.TypeParamDef> parameters)static booleanhasMethod(io.sundr.model.TypeDef typeDef, String method)Check if method exists on the specified type.static booleanhasProperty(io.sundr.model.TypeDef typeDef, String property)Checks if property exists on the specified type.static booleanisAbstract(io.sundr.model.TypeRef typeRef)Checks aTypeRefis of an abstract type.static booleanisArray(io.sundr.model.TypeRef type)Checks if aTypeRefis an array.static booleanisBoolean(io.sundr.model.TypeRef type)Checks if aTypeRefis aBooleanor boolean.static booleanisCollection(io.sundr.model.TypeRef type)Checks if aTypeRefis aCollection.static booleanisConcrete(io.sundr.model.TypeRef typeRef)Checks ifTypeRefis of an concretestatic booleanisEnum(io.sundr.model.TypeRef typeRef)Checks aTypeRefis an enum.static booleanisInstanceOf(io.sundr.model.TypeRef type, io.sundr.model.TypeDef targetType, Function<io.sundr.model.TypeRef,Boolean> function)Checks if aTypeDefis an instance of an otherTypeDef.static booleanisJdkType(io.sundr.model.TypeRef type)Check if type is an internal JDK type.static booleanisList(io.sundr.model.TypeRef type)Checks if aTypeRefis aList.static booleanisMap(io.sundr.model.TypeRef type)Checks if aTypeRefis aMap.static booleanisOptional(io.sundr.model.TypeRef type)Checks if aTypeRefis aOptional.static booleanisOptionalDouble(io.sundr.model.TypeRef type)Checks if aTypeRefis aOptionalDouble.static booleanisOptionalInt(io.sundr.model.TypeRef type)Checks if aTypeRefis aOptionalInt.static booleanisOptionalLong(io.sundr.model.TypeRef type)Checks if aTypeRefis aOptionalLong.static booleanisPrimitive(io.sundr.model.TypeRef type)Checks if aTypeRefis a primitive type.static booleanisSet(io.sundr.model.TypeRef type)Checks if aTypeRefis aSet.static io.sundr.model.TypeParamDefnewTypeParamDef(String letter)Creates a new TypeParamDef.static io.sundr.model.TypeParamRefnewTypeParamRef(String letter)Creates a new generic TypeParamRef.static StringparseFullyQualifiedName(String content)static Optional<String>parseName(String content)static Optional<String>parsePackage(String content)static StringtoClassName(Object o)A utility that tries to get a fully qualified class name from an unknown object.static io.sundr.model.TypeDeftypeExtends(io.sundr.model.TypeDef base, io.sundr.model.ClassRef superClass)Sets oneTypeDefas a super class of an other.static io.sundr.model.TypeDeftypeGenericOf(io.sundr.model.TypeDef base, io.sundr.model.TypeParamDef... parameters)Sets oneTypeDefas a generic of an other.static io.sundr.model.TypeDeftypeImplements(io.sundr.model.TypeDef base, io.sundr.model.ClassRef... superClass)Sets oneTypeDefas 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.TypeDefunwrapGeneric(io.sundr.model.TypeDef base)Removes parameters from a TypeDef.static voidvisitParents(io.sundr.model.TypeDef type, List<io.sundr.model.TypeDef> types)static voidvisitParents(io.sundr.model.TypeDef type, List<io.sundr.model.TypeDef> types, List<io.sundr.model.TypeDef> visited)
-
-
-
Field Detail
-
PACKAGE
public static final String PACKAGE
- See Also:
- Constant Field Values
-
CLASS_NAME
public static final String CLASS_NAME
- See Also:
- Constant Field Values
-
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 aTypeDefis an instance of an otherTypeDef.- 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 oneTypeDefas 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 oneTypeDefas 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 oneTypeDefas an interface of an other.- Parameters:
base- The base type.superClass- The super type.- Returns:
- The updated type definition.
-
isEnum
public static boolean isEnum(io.sundr.model.TypeRef typeRef)
Checks aTypeRefis 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 aTypeRefis 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 ifTypeRefis 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 aTypeRefis 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 aTypeRefis aMap.- Parameters:
type- The type to check.- Returns:
- True if its a Map.
-
isList
public static boolean isList(io.sundr.model.TypeRef type)
Checks if aTypeRefis aList.- Parameters:
type- The type to check.- Returns:
- True if its a List.
-
isSet
public static boolean isSet(io.sundr.model.TypeRef type)
Checks if aTypeRefis aSet.- Parameters:
type- The type to check.- Returns:
- True if its a Set.
-
isCollection
public static boolean isCollection(io.sundr.model.TypeRef type)
Checks if aTypeRefis aCollection.- Parameters:
type- The type to check.- Returns:
- True if its a Collection.
-
isBoolean
public static boolean isBoolean(io.sundr.model.TypeRef type)
Checks if aTypeRefis aBooleanor boolean.- Parameters:
type- The type to check.- Returns:
- True if its a
Booleanor boolean.
-
isArray
public static boolean isArray(io.sundr.model.TypeRef type)
Checks if aTypeRefis 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 aTypeRefis aOptional.- Parameters:
type- The type to check.- Returns:
- True if its a
Optional.
-
isOptionalInt
public static boolean isOptionalInt(io.sundr.model.TypeRef type)
Checks if aTypeRefis aOptionalInt.- Parameters:
type- The type to check.- Returns:
- True if its a
OptionalInt.
-
isOptionalDouble
public static boolean isOptionalDouble(io.sundr.model.TypeRef type)
Checks if aTypeRefis aOptionalDouble.- Parameters:
type- The type to check.- Returns:
- True if its a
OptionalDouble.
-
isOptionalLong
public static boolean isOptionalLong(io.sundr.model.TypeRef type)
Checks if aTypeRefis aOptionalLong.- 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)
-
-