public class HierarchyDiscovery
extends java.lang.Object
Constructor and Description |
---|
HierarchyDiscovery(java.lang.reflect.Type type)
Constructs a new
HierarchyDiscovery instance. |
HierarchyDiscovery(java.lang.reflect.Type type,
TypeResolver resolver) |
Modifier and Type | Method and Description |
---|---|
protected void |
discoverFromClass(java.lang.Class<?> clazz,
boolean rawGeneric) |
protected void |
discoverInterfaces(java.lang.Class<?> clazz,
boolean rawGeneric) |
protected void |
discoverTypes(java.lang.reflect.Type type,
boolean rawGeneric) |
static HierarchyDiscovery |
forNormalizedType(java.lang.reflect.Type type)
Performs base type normalization before hierarchy discovery is performed.
|
TypeResolver |
getResolver() |
java.util.Set<java.lang.reflect.Type> |
getTypeClosure() |
java.util.Map<java.lang.Class<?>,java.lang.reflect.Type> |
getTypeMap() |
protected java.lang.reflect.Type |
processAndResolveType(java.lang.reflect.Type superclass,
java.lang.Class<?> rawSuperclass) |
java.lang.reflect.Type |
resolveType(java.lang.reflect.Type type) |
public HierarchyDiscovery(java.lang.reflect.Type type)
HierarchyDiscovery
instance.type
- the type whose hierarchy will be discoveredpublic HierarchyDiscovery(java.lang.reflect.Type type, TypeResolver resolver)
public static HierarchyDiscovery forNormalizedType(java.lang.reflect.Type type)
Type normalization only affects parameterized types (e.g. public class Foo<T extends Serializable>) that are used in form of a raw type (e.g. Foo.class). During the process of type normalization, this raw type (Foo.class is instance of Class>) is replaced by a canonical version of the type which in this case would be the parameterized type of Foo<T extends Serializable>
Base type normalization means that only the base type, which is the input for hierarchy discovery, is normalized. Other types discovered during hierarchy discovery are never normalized even if a raw form of a parameterized type is discovered.
A user of this class should recognize whether base type normalization is required and set the normalize parameter accordingly.
In the realm of CDI there is only a single use-case for base type normalization. That is resolving bean types of a bean defined as a class (managed and session beans). Here, e.g. discovered Foo.class needs to be normalized as the correct CDI bean type is Foo<T extends Serializable>, not Foo.class.
In other cases, the complete generic information of the base type is known and thus base type normalization should not be used so that it does not cover intentionally declared raw types (e.g. an injection point with a raw type should be recognized as an injection point with a raw type, not it's canonical version). This covers:
public java.util.Set<java.lang.reflect.Type> getTypeClosure()
public java.util.Map<java.lang.Class<?>,java.lang.reflect.Type> getTypeMap()
protected void discoverTypes(java.lang.reflect.Type type, boolean rawGeneric)
protected void discoverFromClass(java.lang.Class<?> clazz, boolean rawGeneric)
protected void discoverInterfaces(java.lang.Class<?> clazz, boolean rawGeneric)
protected java.lang.reflect.Type processAndResolveType(java.lang.reflect.Type superclass, java.lang.Class<?> rawSuperclass)
public java.lang.reflect.Type resolveType(java.lang.reflect.Type type)
public TypeResolver getResolver()
Copyright © 2014. All Rights Reserved.