class ApproximatingTypeEnvironment extends Object implements TypeEnvironment
TypeEnvironment that approximates the unresolved components of a generic simple
type or collection to their nearest upper binding. The returned type is always fully resolved.
The concept of "type approximation" is not really sound in general. This class just does what we need
within the Hibernate Annotations environment. It's more or less a hack. The idea is that certain
types can provide useful information even if they're not fully resolved in the environment. This class
tries to turn those types into the nearest fully resolved type that still carries that information.
For example:T becomes Object.T extends Foo becomes Foo.List<T> becomes List<Object>.List<T extends Foo> becomes List<Foo>.T extends Foo becomes an array of Foo.If a type variable has multiple upper bounds, it will be approximated to
Object.
Lower bounds are ignored.Wildcards are generally not approximated.
Class<?> stays Class<?>.
A wildcard within a generic collection is approximated to its upper binding. List<?> becomes
List<Object>Note that
Class<T> is Class<Object>.
That would be wrong in any situation. All parametric types that are not type variables, collections or
arrays are coarsely approximated to Object.class.| 构造器和说明 |
|---|
ApproximatingTypeEnvironment() |
public Type bind(Type type)
TypeEnvironmentType is a Class,
then it's guaranteed to be a regular Java Class. In all
other cases, this method might return a custom implementation of some
interface that extends Type. Be sure not to mix these
objects with Java's implementations of Type to avoid
potential identity problems.
This class does not support bindings involving inner classes or
upper/lower bounds.bind 在接口中 TypeEnvironmentCopyright © 2020. All rights reserved.