Util

class Util

Types

GenericArrayTypeImpl
Link copied to clipboard
class GenericArrayTypeImpl : GenericArrayType
ParameterizedTypeImpl
Link copied to clipboard
class ParameterizedTypeImpl : ParameterizedType
WildcardTypeImpl
Link copied to clipboard

The WildcardType interface supports multiple upper bounds and multiple lower bounds. We only support what the Java 6 language needs - at most one bound. If a lower bound is set, the upper bound must be Object.class.

class WildcardTypeImpl : WildcardType

Functions

boxIfPrimitive
Link copied to clipboard
open fun <T> boxIfPrimitive(type: Class<T>): Class<T>
canonicalize
Link copied to clipboard

Returns a type that is functionally equal but not necessarily equal according to .

open fun canonicalize(type: Type): Type
checkNotPrimitive
Link copied to clipboard
open fun checkNotPrimitive(type: Type)
declaringClassOf
Link copied to clipboard

Returns the declaring class of {@code typeVariable} , or {@code null} if it was not declared by a class.

open fun declaringClassOf(typeVariable: TypeVariable<out Any>): Class<out Any>
generatedAdapter
Link copied to clipboard

Loads the generated JsonAdapter for classes annotated JsonClass . This works because it uses the same naming conventions as {@code JsonClassCodeGenProcessor} .

open fun generatedAdapter(moshi: Moshi, type: Type, rawType: Class<out Any>): JsonAdapter<out Any>
getGenericSupertype
Link copied to clipboard

Returns the generic supertype for {@code supertype} . For example, given a class {@code * IntegerSet} , the result for when supertype is {@code Set.class} is {@code Set} and the result when the supertype is {@code Collection.class} is {@code Collection} .

open fun getGenericSupertype(context: Type, rawType: Class<out Any>, toResolve: Class<out Any>): Type
hashCodeOrZero
Link copied to clipboard
open fun hashCodeOrZero(o: Any): Int
hasNullable
Link copied to clipboard

Returns true if {@code annotations} has any annotation whose simple name is Nullable.

open fun hasNullable(annotations: Array<Annotation>): Boolean
indexOf
Link copied to clipboard
open fun indexOf(array: Array<Any>, toFind: Any): Int
isAnnotationPresent
Link copied to clipboard
open fun isAnnotationPresent(annotations: Set<out Annotation>, annotationClass: Class<out Annotation>): Boolean
isKotlin
Link copied to clipboard
open fun isKotlin(targetClass: Class<out Any>): Boolean
isPlatformType
Link copied to clipboard

Returns true if {@code rawType} is built in. We don't reflect on private fields of platform types because they're unspecified and likely to be different on Java vs. Android.

open fun isPlatformType(rawType: Class<out Any>): Boolean
jsonAnnotations
Link copied to clipboard
open fun jsonAnnotations(annotations: Array<Annotation>): Set<out Annotation>
open fun jsonAnnotations(annotatedElement: AnnotatedElement): Set<out Annotation>
lookupDefaultsConstructor
Link copied to clipboard

Reflectively looks up the defaults constructor of a kotlin class.

open fun <T> lookupDefaultsConstructor(targetClass: Class<T>): Constructor<T>
missingProperty
Link copied to clipboard
open fun missingProperty(propertyName: String, jsonName: String, reader: JsonReader): JsonDataException
removeSubtypeWildcard
Link copied to clipboard

If type is a "? extends X" wildcard, returns X; otherwise returns type unchanged.

open fun removeSubtypeWildcard(type: Type): Type
resolve
Link copied to clipboard
open fun resolve(context: Type, contextRawType: Class<out Any>, toResolve: Type): Type
resolveTypeVariable
Link copied to clipboard
open fun resolveTypeVariable(context: Type, contextRawType: Class<out Any>, unknown: TypeVariable<out Any>): Type
rethrowCause
Link copied to clipboard

Throws the cause of {@code e} , wrapping it if it is checked.

open fun rethrowCause(e: InvocationTargetException): RuntimeException
typeAnnotatedWithAnnotations
Link copied to clipboard
open fun typeAnnotatedWithAnnotations(type: Type, annotations: Set<out Annotation>): String
typesMatch
Link copied to clipboard
open fun typesMatch(pattern: Type, candidate: Type): Boolean
typeToString
Link copied to clipboard
open fun typeToString(type: Type): String
unexpectedNull
Link copied to clipboard
open fun unexpectedNull(propertyName: String, jsonName: String, reader: JsonReader): JsonDataException

Properties

DEFAULT_CONSTRUCTOR_MARKER
Link copied to clipboard
val DEFAULT_CONSTRUCTOR_MARKER: Class<out Any>
EMPTY_TYPE_ARRAY
Link copied to clipboard
val EMPTY_TYPE_ARRAY: Array<Type>
NO_ANNOTATIONS
Link copied to clipboard
val NO_ANNOTATIONS: Set<Annotation>