- 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)preInitHookbinds rawClassinstances toTypeFactory#RAW_TYPESAnnotatedElementBase(AnnotatedElement, Consumer)bindsAnnotatedElementBase.annotatedElementDeclaredElementBase(AnnotatedElement, Consumer, Type, TypeTemplate)binds:DeclaredElementBase.typeDeclaredElementBase.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, typeFields 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.voidDestroys 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.voidObserves 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 voidseal()Unsupported, usesealHierarchy(Iterable)to provide hierarchy when sealing.(package private) voidsealHierarchy(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
declaringTypeMethods inherited from class iu.type.AnnotatedElementBase
annotation, annotations, hasAnnotation, permittedMethods inherited from class iu.type.ElementBase
checkSealed, postInitMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface edu.iu.type.IuAnnotatedElement
annotation, annotations, hasAnnotation, permitted, permittedMethods inherited from interface edu.iu.type.IuDeclaredElement
declaringTypeMethods inherited from interface edu.iu.type.IuType
annotatedConstructors, annotatedFields, annotatedMethods, annotatedProperties, autoboxClass, autoboxDefault, constructor, constructor, method, method, subMethods 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 tothisafter 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 tothisafter binding the annotated element but before initializing and memberstype- generic type; must not be a classerasedType- pre-calculated raw type template; aTypeTemplatecannot 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:
sealin classElementBase- Throws:
UnsupportedOperationException- when invoked
-
sealHierarchy
Sealshierarchy()and resolves inherited elements.- Parameters:
hierarchy- Resolved type hierarchy
-
subscribe
Description copied from interface:IuTypeSubscribes a new instance reference. -
observe
Description copied from interface:IuTypeObserves 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
InstanceReferencemay useIuType.subscribe(InstanceReference)to be notified when new instances are observed.Once all
InstanceReferences 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:IuTypeDestroys 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:IuParameterizedElementGets type parameters by name.- Specified by:
typeParametersin interfaceIuParameterizedElement- Specified by:
typeParametersin interfaceParameterizedFacade- Returns:
- map of type parameter facades
-
name
Description copied from interface:IuNamedElementGets the name.- Specified by:
namein interfaceIuNamedElement<D>- Returns:
- name
-
reference
Description copied from interface:IuTypeGets the reference used to obtain this type. -
deref
Description copied from interface:IuTypeGets the generic type. -
erase
Description copied from interface:IuTypeGets theerasedfacade, which describing theClassrepresenting the erasure of the generic type.The
IuType.deref()of the erased facade must return aClass. -
erasedClass
Description copied from interface:IuTypeGet the type erasure class.Shorthand for
IuType.erase().IuType.deref()- Specified by:
erasedClassin interfaceIuType<D,T> - Returns:
- type erasure class
- See Also:
-
referTo
Description copied from interface:IuTypeRefers 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:IuTypeGets enclosed types.- Specified by:
enclosedTypesin interfaceIuType<D,T> - Returns:
- enclosed types
-
constructors
Description copied from interface:IuTypeGets all constructors defined by this type.- Specified by:
constructorsin interfaceIuType<D,T> - Returns:
- constructors
-
hierarchy
Description copied from interface:IuTypeIterates the type hierarchy, from most specific to least specific.- All
Class.getGenericInterfaces() Class.getGenericSuperclass()- Iterate
IuType.hierarchy()untilObjectis reached
This type described by this facade is not included.
Objectis always the last element. - All
-
field
Description copied from interface:IuTypeGets 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:IuTypeGets all fields defined by this type, followed by all fields defined by all types in this type's hierarchy, inIuType.hierarchy()order.- Specified by:
fieldsin interfaceIuType<D,T> - Returns:
- fields declared by this type and its hierarchy, in this followed by
IuType.hierarchy()order
-
property
Description copied from interface:IuTypeGets a property declared by this type. -
properties
Description copied from interface:IuTypeGets all properties defined by this type, followed by all properties defined by all types in this type's hierarchy, inIuType.hierarchy()order.- Specified by:
propertiesin interfaceIuType<D,T> - Returns:
- properties declared by this type and its hierarchy, in this followed
by
IuType.hierarchy()order
-
methods
Description copied from interface:IuTypeGets all methods defined by this type.The result
iteratesall methods declared on all classes in the type erasure's hierarchy with private erasure for duplicately defined methods. -
toString
-