Class TypeUtil
- java.lang.Object
-
- com.azure.android.core.rest.implementation.TypeUtil
-
public final class TypeUtil extends java.lang.Object
Utility type exposing methods to deal withType
.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.reflect.ParameterizedType
createParameterizedType(java.lang.reflect.Type rawClass, java.lang.reflect.Type... genericTypes)
Create a parameterized type from a raw class and its type arguments.static java.util.List<java.lang.Class<?>>
getAllClasses(java.lang.Class<?> clazz)
Find all super classes including provided class.static java.lang.Class<?>
getRawClass(java.lang.reflect.Type type)
Get the raw class for a given type.static java.lang.reflect.Type
getRestResponseBodyType(java.lang.reflect.Type restResponseReturnType)
Returns the body type expected in the rest response.static java.lang.reflect.Type
getSuperType(java.lang.reflect.Type type)
Get the super type for a given type.static java.lang.reflect.Type
getSuperType(java.lang.reflect.Type subType, java.lang.Class<?> rawSuperType)
Get the super type for a type in its super type chain, which has a raw class that matches the specified class.static java.lang.reflect.Type
getTypeArgument(java.lang.reflect.Type type)
Get the generic argument, or the first if the type has more than one.static java.lang.reflect.Type[]
getTypeArguments(java.lang.reflect.Type type)
Get the generic arguments for a type.static boolean
isTypeOrSubTypeOf(java.lang.reflect.Type subType, java.lang.reflect.Type superType)
Determines if a type is the same or a subtype for another type.static boolean
restResponseTypeExpectsBody(java.lang.reflect.ParameterizedType restResponseReturnType)
Returns whether the rest response expects to have any body (by checking if the body parameter type is set to Void, in which case no body is expected).
-
-
-
Method Detail
-
getAllClasses
public static java.util.List<java.lang.Class<?>> getAllClasses(java.lang.Class<?> clazz)
Find all super classes including provided class.- Parameters:
clazz
- the raw class to find super types for- Returns:
- the list of super classes
-
getTypeArguments
public static java.lang.reflect.Type[] getTypeArguments(java.lang.reflect.Type type)
Get the generic arguments for a type.- Parameters:
type
- the type to get arguments- Returns:
- the generic arguments, empty if type is not parameterized
-
getTypeArgument
public static java.lang.reflect.Type getTypeArgument(java.lang.reflect.Type type)
Get the generic argument, or the first if the type has more than one.- Parameters:
type
- the type to get arguments- Returns:
- the generic argument, null if type is not parameterized
-
getRawClass
public static java.lang.Class<?> getRawClass(java.lang.reflect.Type type)
Get the raw class for a given type.- Parameters:
type
- the input type- Returns:
- the raw class
-
getSuperType
public static java.lang.reflect.Type getSuperType(java.lang.reflect.Type type)
Get the super type for a given type.- Parameters:
type
- the input type- Returns:
- the direct super type
-
getSuperType
public static java.lang.reflect.Type getSuperType(java.lang.reflect.Type subType, java.lang.Class<?> rawSuperType)
Get the super type for a type in its super type chain, which has a raw class that matches the specified class.- Parameters:
subType
- the sub type to find super type forrawSuperType
- the raw class for the super type- Returns:
- the super type that matches the requirement
-
isTypeOrSubTypeOf
public static boolean isTypeOrSubTypeOf(java.lang.reflect.Type subType, java.lang.reflect.Type superType)
Determines if a type is the same or a subtype for another type.- Parameters:
subType
- the supposed sub typesuperType
- the supposed super type- Returns:
- true if the first type is the same or a subtype for the second type
-
createParameterizedType
public static java.lang.reflect.ParameterizedType createParameterizedType(java.lang.reflect.Type rawClass, java.lang.reflect.Type... genericTypes)
Create a parameterized type from a raw class and its type arguments.- Parameters:
rawClass
- the raw class to construct the parameterized typegenericTypes
- the generic arguments- Returns:
- the parameterized type
-
restResponseTypeExpectsBody
public static boolean restResponseTypeExpectsBody(java.lang.reflect.ParameterizedType restResponseReturnType)
Returns whether the rest response expects to have any body (by checking if the body parameter type is set to Void, in which case no body is expected).- Parameters:
restResponseReturnType
- The RestResponse subtype containing the type arguments we are inspecting.- Returns:
- True if a body is expected, false if a Void body is expected.
-
getRestResponseBodyType
public static java.lang.reflect.Type getRestResponseBodyType(java.lang.reflect.Type restResponseReturnType)
Returns the body type expected in the rest response.- Parameters:
restResponseReturnType
- The RestResponse subtype containing the type arguments we are inspecting.- Returns:
- The type of the body.
-
-