static void ensureRegistered() { if (Types.Object != Type.CACHE.find(java.lang.Object.class)) { throw new IllegalStateException("Standard Java types were not successfully registered!"); } } }
static void ensureRegistered() { if (Void != Type.CACHE.find(java.lang.Void.TYPE)) { throw new IllegalStateException("Primitive types were not successfully registered!"); } }
static void ensureRegistered() { if (Types.Object != Type.CACHE.find(java.lang.Object.class)) { throw new IllegalStateException("Standard Java types were not successfully registered!"); } } }
static void ensureRegistered() { if (Void != Type.CACHE.find(java.lang.Void.TYPE)) { throw new IllegalStateException("Primitive types were not successfully registered!"); } }
static void ensureRegistered() { if (Types.Object != Type.CACHE.find(java.lang.Object.class)) { throw new IllegalStateException("Standard Java types were not successfully registered!"); } } }
static void ensureRegistered() { if (Void != Type.CACHE.find(java.lang.Void.TYPE)) { throw new IllegalStateException("Primitive types were not successfully registered!"); } }
static Type<?> tryFind(final java.lang.reflect.Type type) { if (type instanceof Class<?>) { final Class<?> classType = (Class<?>) type; if (classType.isPrimitive() || classType == Void.class) { return of(classType); } synchronized (CACHE_LOCK) { return CACHE.find(classType); } } return null; }
static Type<?> tryFind(final java.lang.reflect.Type type) { if (type instanceof Class<?>) { final Class<?> classType = (Class<?>)type; if (classType.isPrimitive() || classType == Void.class) { return of(classType); } synchronized (CACHE_LOCK) { return CACHE.find(classType); } } return null; }
static Type<?> tryFind(final java.lang.reflect.Type type) { if (type instanceof Class<?>) { final Class<?> classType = (Class<?>)type; if (classType.isPrimitive() || classType == Void.class) { return of(classType); } synchronized (CACHE_LOCK) { return CACHE.find(classType); } } return null; }
public static <T> Type<T> of(final Class<T> clazz) { synchronized (CACHE_LOCK) { final Type<T> reflectedType = CACHE.find(clazz); if (reflectedType != null) { return reflectedType; } int arrayDepth = 0; Class<?> actualClass = clazz; while (actualClass.isArray()) { actualClass = actualClass.getComponentType(); ++arrayDepth; } Type<?> resolvedType = resolveClassType(actualClass); if (resolvedType == null) { throw Error.couldNotResolveType(clazz); } while (arrayDepth > 0) { resolvedType = resolvedType.makeArrayType(); --arrayDepth; } return (Type<T>)resolvedType; } }
public static <T> Type<T> of(final Class<T> clazz) { synchronized (CACHE_LOCK) { final Type<T> reflectedType = CACHE.find(clazz); if (reflectedType != null) { return reflectedType; } int arrayDepth = 0; Class<?> actualClass = clazz; while (actualClass.isArray()) { actualClass = actualClass.getComponentType(); ++arrayDepth; } Type<?> resolvedType = resolveClassType(actualClass); if (resolvedType == null) { throw Error.couldNotResolveType(clazz); } while (arrayDepth > 0) { resolvedType = resolvedType.makeArrayType(); --arrayDepth; } return (Type<T>) resolvedType; } }
public static <T> Type<T> of(final Class<T> clazz) { synchronized (CACHE_LOCK) { final Type<T> reflectedType = CACHE.find(clazz); if (reflectedType != null) { return reflectedType; } int arrayDepth = 0; Class<?> actualClass = clazz; while (actualClass.isArray()) { actualClass = actualClass.getComponentType(); ++arrayDepth; } Type<?> resolvedType = resolveClassType(actualClass); if (resolvedType == null) { throw Error.couldNotResolveType(clazz); } while (arrayDepth > 0) { resolvedType = resolvedType.makeArrayType(); --arrayDepth; } return (Type<T>)resolvedType; } }
@Override public Type<?> visitClassType(final Type<?> type, final TypeBindings bindings) { if (bindings.containsGenericParameter(type)) { return bindings.getBoundType(type); } final TypeBindings oldTypeBindings = type.getTypeBindings(); final TypeBindings newTypeBindings = visitTypeBindings(oldTypeBindings, bindings); if (oldTypeBindings != newTypeBindings) { final Type<?> cachedType = Type.CACHE.find( Type.CACHE.key( type.getErasedClass(), newTypeBindings.getBoundTypes() ) ); if (cachedType != null) { return cachedType; } final GenericType genericType = new GenericType( type.getGenericTypeDefinition(), newTypeBindings ); Type.CACHE.add(genericType); return genericType; } return type; }
@Override public Type<?> visitClassType(final Type<?> type, final TypeBindings bindings) { if (bindings.containsGenericParameter(type)) { return bindings.getBoundType(type); } final TypeBindings oldTypeBindings = type.getTypeBindings(); final TypeBindings newTypeBindings = visitTypeBindings(oldTypeBindings, bindings); if (oldTypeBindings != newTypeBindings) { final Type<?> cachedType = Type.CACHE.find( Type.CACHE.key( type.getErasedClass(), newTypeBindings.getBoundTypes() ) ); if (cachedType != null) { return cachedType; } final GenericType genericType = new GenericType( type.getGenericTypeDefinition(), newTypeBindings ); Type.CACHE.add(genericType); return genericType; } return type; }