Class HierarchyDiscovery
- java.lang.Object
-
- org.jboss.weld.util.reflection.HierarchyDiscovery
-
public class HierarchyDiscovery extends Object
Utility class that discovers transitive type closure of a given type.- Author:
- Weld Community, Ales Justin, Marko Luksa, Jozef Hartinger
-
-
Constructor Summary
Constructors Constructor Description HierarchyDiscovery(Type type)
Constructs a newHierarchyDiscovery
instance.HierarchyDiscovery(Type type, TypeResolver resolver)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
discoverFromClass(Class<?> clazz, boolean rawGeneric)
protected void
discoverInterfaces(Class<?> clazz, boolean rawGeneric)
protected void
discoverTypes(Type type, boolean rawGeneric)
static HierarchyDiscovery
forNormalizedType(Type type)
Performs base type normalization before hierarchy discovery is performed.TypeResolver
getResolver()
Set<Type>
getTypeClosure()
Map<Class<?>,Type>
getTypeMap()
protected Type
processAndResolveType(Type superclass, Class<?> rawSuperclass)
Type
resolveType(Type type)
-
-
-
Constructor Detail
-
HierarchyDiscovery
public HierarchyDiscovery(Type type)
Constructs a newHierarchyDiscovery
instance.- Parameters:
type
- the type whose hierarchy will be discovered
-
HierarchyDiscovery
public HierarchyDiscovery(Type type, TypeResolver resolver)
-
-
Method Detail
-
forNormalizedType
public static HierarchyDiscovery forNormalizedType(Type type)
Performs base type normalization before hierarchy discovery is performed.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:
- type closure of an injection point or delegate
- type closure of a producer field type
- type closure of a producer method return type
- type closure of a parameter type (observer, initializer, producer and disposer methods)
- type closure of an event
-
discoverTypes
protected void discoverTypes(Type type, boolean rawGeneric)
-
discoverFromClass
protected void discoverFromClass(Class<?> clazz, boolean rawGeneric)
-
discoverInterfaces
protected void discoverInterfaces(Class<?> clazz, boolean rawGeneric)
-
processAndResolveType
protected Type processAndResolveType(Type superclass, Class<?> rawSuperclass)
-
getResolver
public TypeResolver getResolver()
-
-