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>.
An array of 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.
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public Type | bind(final Type type)
Implements org. |
| private Type | |
| private Type | |
| public String |
| ApproximatingTypeEnvironment | back to summary |
|---|---|
| pack-priv ApproximatingTypeEnvironment() | |
| bind | back to summary |
|---|---|
| public Type bind(final Type type) Implements org. Doc from org. Binds as many generic components of the given type as possible in this context. Warning if the returned This class does not support bindings involving inner classes or upper/lower bounds.
| |
| coarseApproximation | back to summary |
|---|---|
| private Type coarseApproximation(final Type type) | |
| fineApproximation | back to summary |
|---|---|
| private Type fineApproximation(final Type type) | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |