- All Superinterfaces:
Copyable<TypeResolver>
- All Known Implementing Classes:
TypeResolverWrapper
TypeResolver provides dynamic mapping of Java types to engine's internal Type.
In the engine, all fact types are represented by a String identifier and an associated Java
class. This allows instances of the same Java class to be treated as having different logical types.
-
Method Summary
Modifier and TypeMethodDescriptiondefault <T> Type<T>Declares and registers newTypewith the given Java class name.<T> Type<T>Declares and registers newTypewith the given type name and Java class<T> Type<T>Declares and registers newTypewith the given logical type name and Java class name.Collection<Type<?>>Returns a collection of all known types.default <T> Type<T>getOrDeclare(Class<T> cl) default <T> Type<T>getOrDeclare(String typeName) default <T> Type<T>getOrDeclare(String typeName, Class<T> javaType) default <T> Type<T>getOrDeclare(String typeName, String javaType) <T> Type<T>getType(int typeId) <T> Type<T><T> Type<T>voidwrapType(TypeWrapper<?> typeWrapper) Wraps a given TypeWrapper instance and delegates the calls to another Type implementation.
-
Method Details
-
getType
- Type Parameters:
T- type parameter- Parameters:
name- type's declared name- Returns:
- existing
Typeornullif not found
-
getType
- Type Parameters:
T- type parameter- Parameters:
typeId- type id- Returns:
- existing
Type - Throws:
NoSuchElementException- if not found
-
getKnownTypes
Collection<Type<?>> getKnownTypes()Returns a collection of all known types.- Returns:
- a collection of Type instances representing the known types
-
wrapType
Wraps a given TypeWrapper instance and delegates the calls to another Type implementation.- Parameters:
typeWrapper- the TypeWrapper instance to be wrapped
-
declare
Declares and registers new
Typewith the given Java class name. The logical name of the resulting type will beClass.getName()- Type Parameters:
T- java class type parameter- Parameters:
type- Java class- Returns:
- new internal type
- Throws:
IllegalStateException- if such type name has been already declared
-
declare
Declares and registers new
Typewith the given type name and Java class- Type Parameters:
T- java class type parameter- Parameters:
typeName- logical type namejavaType- Java class- Returns:
- new internal type
- Throws:
IllegalStateException- if such type name has been already declared
-
declare
Declares and registers new
Typewith the given logical type name and Java class name. The existence of the corresponding Java class will be checked lazily, when the engine requires access to the class's properties.- Type Parameters:
T- java class type parameter- Parameters:
typeName- logical type namejavaType- Java class name- Returns:
- new logical type
- Throws:
IllegalStateException- if such type name has been already declared
-
getOrDeclare
-
getOrDeclare
-
getOrDeclare
-
getOrDeclare
-
resolve
- Type Parameters:
T- type parameter- Parameters:
o- object to resolve- Returns:
- Type of the argument or null if object's type is unknown
-