public final class TypeUtils extends Object
Modifier and Type | Method and Description |
---|---|
static List<Property> |
allProperties(TypeDef typeDef)
All properties (including inherited).
|
static String |
fullyQualifiedNameDiff(String left,
String right) |
static TypeParamDef |
getParameterDefinition(TypeRef typeRef,
Collection<TypeParamDef> parameters) |
static boolean |
hasMethod(TypeDef typeDef,
String method)
Check if method exists on the specified type.
|
static boolean |
hasProperty(TypeDef typeDef,
String property)
Checks if property exists on the specified type.
|
static boolean |
isAbstract(TypeRef typeRef)
Checks a
TypeRef is of an abstract type. |
static boolean |
isArray(TypeRef type)
Checks if a
TypeRef is an array. |
static boolean |
isBoolean(TypeRef type)
|
static boolean |
isCollection(TypeRef type)
Checks if a
TypeRef is a Collection . |
static boolean |
isConcrete(TypeRef typeRef)
Checks if
TypeRef is of an concrete |
static boolean |
isInstanceOf(TypeRef type,
TypeDef targetType,
Function<TypeRef,Boolean> function)
|
static boolean |
isList(TypeRef type)
|
static boolean |
isMap(TypeRef type)
|
static boolean |
isOptional(TypeRef type)
|
static boolean |
isOptionalDouble(TypeRef type)
Checks if a
TypeRef is a OptionalDouble . |
static boolean |
isOptionalInt(TypeRef type)
Checks if a
TypeRef is a OptionalInt . |
static boolean |
isOptionalLong(TypeRef type)
Checks if a
TypeRef is a OptionalLong . |
static boolean |
isPrimitive(TypeRef type)
Checks if a
TypeRef is a primitive type. |
static boolean |
isSet(TypeRef type)
|
static int |
modifiersToInt(Collection<Modifier> modifiers) |
static int |
modifiersToInt(Modifier... modifiers) |
static TypeParamDef |
newTypeParamDef(String letter)
Creates a new TypeParamDef.
|
static TypeParamRef |
newTypeParamRef(String letter)
Creates a new generic TypeParamRef.
|
static String |
toClassName(Object o)
A utility that tries to get a fully qualified class name from an unknown object.
|
static TypeDef |
typeExtends(TypeDef base,
ClassRef superClass)
Sets one
TypeDef as a super class of an other. |
static TypeDef |
typeGenericOf(TypeDef base,
TypeParamDef... parameters)
Sets one
TypeDef as a generic of an other. |
static TypeDef |
typeImplements(TypeDef base,
ClassRef... superClass)
Sets one
TypeDef as an interface of an other. |
static Set<TypeDef> |
unrollHierarchy(TypeDef typeDef)
Unrolls the hierararchy of a specified type.
|
static TypeDef |
unwrapGeneric(TypeDef base)
Removes parameters from a TypeDef.
|
static void |
visitParents(TypeDef type,
List<TypeDef> types) |
static void |
visitParents(TypeDef type,
List<TypeDef> types,
List<TypeDef> visited) |
public static boolean isInstanceOf(TypeRef type, TypeDef targetType, Function<TypeRef,Boolean> function)
type
- The type to compare.targetType
- The target type.function
- public static TypeParamDef getParameterDefinition(TypeRef typeRef, Collection<TypeParamDef> parameters)
public static TypeParamRef newTypeParamRef(String letter)
letter
- The letter of the type.public static TypeParamDef newTypeParamDef(String letter)
letter
- The letter of the type.public static TypeDef unwrapGeneric(TypeDef base)
base
- The base type.public static TypeDef typeGenericOf(TypeDef base, TypeParamDef... parameters)
TypeDef
as a generic of an other.base
- The base type.parameters
- The parameter types.public static TypeDef typeExtends(TypeDef base, ClassRef superClass)
TypeDef
as a super class of an other.base
- The base type.superClass
- The super type.public static TypeDef typeImplements(TypeDef base, ClassRef... superClass)
TypeDef
as an interface of an other.base
- The base type.superClass
- The super type.public static int modifiersToInt(Modifier... modifiers)
public static int modifiersToInt(Collection<Modifier> modifiers)
public static boolean isAbstract(TypeRef typeRef)
TypeRef
is of an abstract type.typeRef
- The type to check.public static boolean isConcrete(TypeRef typeRef)
TypeRef
is of an concretetypeRef
- The type to check.public static boolean isPrimitive(TypeRef type)
TypeRef
is a primitive type.type
- The type to check.public static boolean isMap(TypeRef type)
type
- The type to check.public static boolean isList(TypeRef type)
type
- The type to check.public static boolean isSet(TypeRef type)
type
- The type to check.public static boolean isCollection(TypeRef type)
TypeRef
is a Collection
.type
- The type to check.public static boolean isBoolean(TypeRef type)
type
- The type to check.Boolean
or boolean.public static boolean isArray(TypeRef type)
TypeRef
is an array.type
- The type to check.public static boolean isOptional(TypeRef type)
type
- The type to check.Optional
.public static boolean isOptionalInt(TypeRef type)
TypeRef
is a OptionalInt
.type
- The type to check.OptionalInt
.public static boolean isOptionalDouble(TypeRef type)
TypeRef
is a OptionalDouble
.type
- The type to check.OptionalDouble
.public static boolean isOptionalLong(TypeRef type)
TypeRef
is a OptionalLong
.type
- The type to check.OptionalLong
.public static boolean hasMethod(TypeDef typeDef, String method)
typeDef
- The type.method
- The method name.public static boolean hasProperty(TypeDef typeDef, String property)
typeDef
- The type.property
- The property name.public static List<Property> allProperties(TypeDef typeDef)
typeDef
- The type.public static Set<TypeDef> unrollHierarchy(TypeDef typeDef)
typeDef
- The specified type.public static String toClassName(Object o)
o
- The object.Copyright © 2019 JBoss by Red Hat. All rights reserved.