- Type Parameters:
D
- declaring typeT
- raw or generic type
- All Implemented Interfaces:
IuAnnotatedElement
,IuDeclaredElement<D>
,IuNamedElement<D>
,IuParameterizedElement
,IuType<D,
,T> ParameterizedFacade
TypeFacade
.
Each template is a standalone representation of a single generic type, potentially paired with a raw template representing its erasure.
Note that TypeTemplate
is not sterotyped as a hash key, but
IuType
is. This hash key behavior comes from same-instance identity
default Object.hashCode()
and Object.equals(Object)
implementations of
instances managed by TypeFactory
. Since ClassLoading data is loaded
exactly once and remains static once loaded, type introspection instances
match that load-once static behavior. It is expected that each raw type
(primitive, class, interface, enum, record, etc) has exactly one
TypeTemplate
instance, and that each TypeTemplate
instance
backed by a generic type contains a TypeFacade
backed by a singleton
raw type instances representing its type erasure
. This
behavior mirrors the hash key behavior of Type
, so internal checks
for equality (and inequality) may use == (and !=).
Note also that Java does not constrain the number of Type
instances,
and considers those instances other than Class
to be disposable.
TypeFactory
does not manage TypeTemplate
instances for
generic type markers once returned to the application.
Initialization Order
Type templates are initialized in two phases, managed by TypeFactory
.
- Declared elements
- Inherited elements
Declared Elements
Resolved in order upon instantiation:
ElementBase(Consumer)
preInitHook
binds rawClass
instances toTypeFactory
#RAW_TYPES
AnnotatedElementBase(AnnotatedElement, Consumer)
bindsAnnotatedElementBase.annotatedElement
DeclaredElementBase(AnnotatedElement, Consumer, Type, TypeTemplate)
binds:DeclaredElementBase.type
DeclaredElementBase.declaringType()
, potentially null or unsealed
- Apply actual type arguments from
ParameterizedType
erase()
constructors()
Inherited Elements
Resolved by sealHierarchy(Iterable)
, order incidental
-
Field Summary
Fields inherited from class iu.type.DeclaredElementBase
declaringType, type
Fields inherited from class iu.type.AnnotatedElementBase
annotatedElement
-
Constructor Summary
ConstructorsConstructorDescriptionTypeTemplate
(Class<T> rawClass, Consumer<TypeTemplate<?, ?>> preInitHook) Raw class constructor intended for use only byTypeFactory
.TypeTemplate
(Consumer<TypeTemplate<?, ?>> preInitHook, Type type, TypeTemplate<D, T> erasedType) Generic type constructor intended for use only byTypeFactory
. -
Method Summary
Modifier and TypeMethodDescriptionIterable
<? extends IuConstructor<T>> Gets all constructors defined by this type.deref()
Gets the generic type.void
Destroys an instance.Iterable
<TypeFacade<T, ?>> Gets enclosed types.erase()
Get the type erasure class.<F> FieldFacade
<? super T, F> Gets a field declared by this type.Iterable
<FieldFacade<? super T, ?>> fields()
Gets all fields defined by this type, followed by all fields defined by all types in this type's hierarchy, inIuType.hierarchy()
order.Iterable
<TypeFacade<?, ? super T>> Iterates the type hierarchy, from most specific to least specific.Iterable
<MethodFacade<? super T, ?>> methods()
Gets all methods defined by this type.name()
Gets the name.void
Observes a new instance.Iterable
<PropertyFacade<? super T, ?>> Gets all properties defined by this type, followed by all properties defined by all types in this type's hierarchy, inIuType.hierarchy()
order.<P> PropertyFacade
<? super T, P> Gets a property declared by this type.IuTypeReference
<T, ?> Gets the reference used to obtain this type.Refers to a type in the the described type's hierarchy.(package private) final void
seal()
Unsupported, usesealHierarchy(Iterable)
to provide hierarchy when sealing.(package private) void
sealHierarchy
(Iterable<? extends IuType<?, ? super T>> hierarchy) Sealshierarchy()
and resolves inherited elements.subscribe
(InstanceReference<T> instanceReference) Subscribes a new instance reference.toString()
Map
<String, TypeFacade<?, ?>> Gets type parameters by name.Methods inherited from class iu.type.DeclaredElementBase
declaringType
Methods inherited from class iu.type.AnnotatedElementBase
annotation, annotations, hasAnnotation, permitted
Methods inherited from class iu.type.ElementBase
checkSealed, postInit
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface edu.iu.type.IuAnnotatedElement
annotation, annotations, hasAnnotation, permitted, permitted
Methods inherited from interface edu.iu.type.IuDeclaredElement
declaringType
Methods inherited from interface edu.iu.type.IuType
annotatedConstructors, annotatedFields, annotatedMethods, annotatedProperties, autoboxClass, autoboxDefault, constructor, constructor, method, method, sub
Methods inherited from interface iu.type.ParameterizedFacade
typeParameter
-
Constructor Details
-
TypeTemplate
TypeTemplate(Class<T> rawClass, Consumer<TypeTemplate<?, ?>> preInitHook) Raw class constructor intended for use only byTypeFactory
.- Parameters:
rawClass
- raw classpreInitHook
- receives a handle tothis
after binding the annotated element but before initializing and members
-
TypeTemplate
TypeTemplate(Consumer<TypeTemplate<?, ?>> preInitHook, Type type, TypeTemplate<D, T> erasedType) Generic type constructor intended for use only byTypeFactory
.- Parameters:
preInitHook
- receives a handle tothis
after binding the annotated element but before initializing and memberstype
- generic type; must not be a classerasedType
- pre-calculated raw type template; aTypeTemplate
cannot be created for a generic type without a fully-formed instance of its type erasure, provided as an argument to this parameter
-
-
Method Details
-
seal
Unsupported, usesealHierarchy(Iterable)
to provide hierarchy when sealing.- Overrides:
seal
in classElementBase
- Throws:
UnsupportedOperationException
- when invoked
-
sealHierarchy
Sealshierarchy()
and resolves inherited elements.- Parameters:
hierarchy
- Resolved type hierarchy
-
subscribe
Description copied from interface:IuType
Subscribes a new instance reference. -
observe
Description copied from interface:IuType
Observes a new instance.Observing an instance registers it with the implementation module as an available target for type introspection, for example, for resource binding. Implementors of
InstanceReference
may useIuType.subscribe(InstanceReference)
to be notified when new instances are observed.Once all
InstanceReference
s have been notified, all methods annotated by @PostConstruct will be invoked on the instance.Observing an instance that is already observed has no effect, nor does observing an instance of a type that has no subscribers. All instances provided via
IuExecutable.exec(Object...)
are observed automatically. This method is a no-op for those instances, however it is up to implementors to ensure @PostConstruct methods do not result in errors or repeat initialization steps when invoked repeatedly. -
destroy
Description copied from interface:IuType
Destroys an instance.Invokes all @PreDestroy methods on an instance. If the instance was
observed
, its state will be reverted and no futures actions will be taken on it.This method may be invoked to close the lifecycle of instances created via
IuExecutable.exec(Object...)
.Destroying an instance that is already destroyed should have no effect, but it is up to implementors to ensure @PreDestroy methods do not result in errors or other side-effects when invoked repeatedly.
-
typeParameters
Description copied from interface:IuParameterizedElement
Gets type parameters by name.- Specified by:
typeParameters
in interfaceIuParameterizedElement
- Specified by:
typeParameters
in interfaceParameterizedFacade
- Returns:
- map of type parameter facades
-
name
Description copied from interface:IuNamedElement
Gets the name.- Specified by:
name
in interfaceIuNamedElement<D>
- Returns:
- name
-
reference
Description copied from interface:IuType
Gets the reference used to obtain this type. -
deref
Description copied from interface:IuType
Gets the generic type. -
erase
Description copied from interface:IuType
Gets theerased
facade, which describing theClass
representing the erasure of the generic type.The
IuType.deref()
of the erased facade must return aClass
. -
erasedClass
Description copied from interface:IuType
Get the type erasure class.Shorthand for
IuType.erase()
.IuType.deref()
- Specified by:
erasedClass
in interfaceIuType<D,
T> - Returns:
- type erasure class
- See Also:
-
referTo
Description copied from interface:IuType
Refers to a type in the the described type's hierarchy.When the referent type declares type parameters, the resolved generic types associated with those parameters are described by the returned facade.
-
enclosedTypes
Description copied from interface:IuType
Gets enclosed types.- Specified by:
enclosedTypes
in interfaceIuType<D,
T> - Returns:
- enclosed types
-
constructors
Description copied from interface:IuType
Gets all constructors defined by this type.- Specified by:
constructors
in interfaceIuType<D,
T> - Returns:
- constructors
-
hierarchy
Description copied from interface:IuType
Iterates the type hierarchy, from most specific to least specific.- All
Class.getGenericInterfaces()
Class.getGenericSuperclass()
- Iterate
IuType.hierarchy()
untilObject
is reached
This type described by this facade is not included.
Object
is always the last element. - All
-
field
Description copied from interface:IuType
Gets a field declared by this type.When a private field has the same name as a different field declared by a super class, the "inherited" field is shadowed by this method. To retrieve all fields, including those shadowed by a superclass, use
IuType.fields()
. -
fields
Description copied from interface:IuType
Gets all fields defined by this type, followed by all fields defined by all types in this type's hierarchy, inIuType.hierarchy()
order.- Specified by:
fields
in interfaceIuType<D,
T> - Returns:
- fields declared by this type and its hierarchy, in this followed by
IuType.hierarchy()
order
-
property
Description copied from interface:IuType
Gets a property declared by this type. -
properties
Description copied from interface:IuType
Gets all properties defined by this type, followed by all properties defined by all types in this type's hierarchy, inIuType.hierarchy()
order.- Specified by:
properties
in interfaceIuType<D,
T> - Returns:
- properties declared by this type and its hierarchy, in this followed
by
IuType.hierarchy()
order
-
methods
Description copied from interface:IuType
Gets all methods defined by this type.The result
iterates
all methods declared on all classes in the type erasure's hierarchy with private erasure for duplicately defined methods. -
toString
-