public class TypeUtils extends Object
Modifier and Type | Method and Description |
---|---|
static int[] |
add(int[] array,
int element) |
static boolean |
equals(Type t1,
Type t2)
Check equality of types.
|
static boolean |
isAssignable(Type type,
Type toType)
Checks if the subject type may be implicitly cast to the target type
following the Java generics rules.
|
static Type[] |
normalizeUpperBounds(Type[] bounds)
This method strips out the redundant upper bound types in type
variable types and wildcard types (or it would with wildcard types if
multiple upper bounds were allowed).
|
static String |
toString(Type type) |
public static boolean isAssignable(Type type, Type toType)
Checks if the subject type may be implicitly cast to the target type following the Java generics rules.
type
- the subject type to be assigned to the target typetoType
- the target typetrue
if type
is assignable to toType
.public static Type[] normalizeUpperBounds(Type[] bounds)
This method strips out the redundant upper bound types in type variable types and wildcard types (or it would with wildcard types if multiple upper bounds were allowed).
Example, with the variable type declaration:
<K extends java.util.Collection<String> & java.util.List<String>>
since List
is a subinterface of Collection
,
this method will return the bounds as if the declaration had been:
<K extends java.util.List<String>>
bounds
- an array of types representing the upper bounds of either
WildcardType
or TypeVariable
, not null
.bounds
minus the
redundant types.public static boolean equals(Type t1, Type t2)
t1
- the first typet2
- the second typepublic static int[] add(int[] array, int element)
Copyright © 2018–2021 SmallRye. All rights reserved.