public interface TypeInfoFactory extends Serializable
TypeInfo
For getting TypeInfo representing a Type, use create(Type) and its overloads
For mutating an existed TypeInfo, use toArray(TypeInfo), attachParam(TypeInfo, TypeInfo...). These methods will not modify the original TypeInfo
This class is serializable, but cached TypeInfo (if implementation has a cache) will not be de/serialized
| Modifier and Type | Field and Description |
|---|---|
static TypeInfo[] |
EMPTY_ARRAY |
static TypeInfoFactory |
GLOBAL
TypeInfoFactory used by scope independent actions.
|
static TypeInfoFactory |
NO_CACHE
TypeInfoFactory used by very few actions with the intention of not caching any used types
This factory does not cache
TypeInfo. |
| Modifier and Type | Method and Description |
|---|---|
default TypeInfoFactory |
associate(ScriptableObject topScope)
Associate this TypeInfoFactory object with the given top-level scope.
|
TypeInfo |
attachParam(TypeInfo base,
List<TypeInfo> params)
In general, implementations are recommended, but not required, to return a
ParameterizedTypeInfo. |
default TypeInfo |
attachParam(TypeInfo base,
TypeInfo... params) |
TypeInfo |
create(Class<?> clazz) |
TypeInfo |
create(GenericArrayType genericArrayType) |
TypeInfo |
create(ParameterizedType parameterizedType) |
default TypeInfo |
create(Type type)
|
TypeInfo |
create(TypeVariable<?> typeVariable) |
TypeInfo |
create(WildcardType wildcardType) |
default <T extends Type> |
createArray(T[] types) |
default <T extends Type> |
createList(T[] types) |
static TypeInfoFactory |
get(Scriptable scope)
Search for TypeInfoFactory in the given scope.
|
default Map<VariableTypeInfo,TypeInfo> |
getConsolidationMapping(Class<?> from) |
static TypeInfoFactory |
getOrElse(Scriptable scope,
TypeInfoFactory fallback)
Search for TypeInfoFactory in the given scope.
|
static TypeInfo |
matchPredefined(Class<?> clazz) |
TypeInfo |
toArray(TypeInfo component) |
static final TypeInfoFactory GLOBAL
This factory will cache TypeInfo. TypeInfo created from simple types like TypeInfoFactory.class will be kept in a cache, so that when the same type is passed to this
factory, no new TypeInfo is created.
This factory is weakly referencing cached types. It holds a WeakReference to the type for each cached type, and will not prevent cached
types from being unloaded
For actions with scope available, the TypeInfoFactory can be obtained via get(Scriptable).
static final TypeInfoFactory NO_CACHE
This factory does not cache TypeInfo. If the same type is passed to this factory
multiple times, the return result may or may not be the exact same object
static final TypeInfo[] EMPTY_ARRAY
TypeInfo create(GenericArrayType genericArrayType)
TypeInfo create(TypeVariable<?> typeVariable)
TypeInfo create(ParameterizedType parameterizedType)
TypeInfo create(WildcardType wildcardType)
TypeInfo toArray(TypeInfo component)
component paramTypeInfo.isArray(),
TypeInfo.getComponentType()TypeInfo attachParam(TypeInfo base, List<TypeInfo> params)
ParameterizedTypeInfo.
Default implementations in Rhino will return a TypeInfo representing a parameterized type
with raw type being base param, and parameters being params param. If the
base param itself is already a ParameterizedTypeInfo, the raw type will then
be ParameterizedTypeInfo.rawType() of base
ParameterizedTypeInfodefault Map<VariableTypeInfo,TypeInfo> getConsolidationMapping(Class<?> from)
TypeInfo.consolidate(Map)default TypeInfo create(Type type)
TypeInfo from Type.
Implementations are recommended, but not required, to maintain the uniqueness of simple
types like Class, to reduce allocation
There's no guarantee that created TypeInfo will keep all their original
information. For example, WildcardType might be mapped to one of its bounds, instead
of a WildcardTypeInfo
Implementations should return TypeInfo.NONE if it's unable to parse the Type it received
default TypeInfoFactory associate(ScriptableObject topScope)
NOTE: If you're about associate a custom TypeInfoFactory to a scope, call this method
before initStandardObjects(...) or initSafeStandardObjects(...)
topScope - scope to associate this TypeInfoFactory object with.this if no previous TypeInfoFactory object was associated with the scope and
this TypeInfoFactory is successfully associated, or the old associated factory otherwise.IllegalArgumentException - if provided scope is not top scopeget(Scriptable scope)static TypeInfoFactory get(Scriptable scope)
scope - scope to search for TypeInfoFactory object.IllegalArgumentException - if the top scope of provided scope have no associated
TypeInfoFactory.associate(ScriptableObject topScope)static TypeInfoFactory getOrElse(Scriptable scope, TypeInfoFactory fallback)
fallback is
returned insteadscope - scope to search for TypeInfoFactory object.fallback if none was foundget(Scriptable),
associate(ScriptableObject topScope)Copyright © 2025 HtmlUnit. All rights reserved.