- All Superinterfaces:
Copyable<TypeResolver>
TypeResolver provides dynamic mapping of Java types to the 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.
This interface extends Copyable, allowing a TypeResolver to create copies of itself.
The copies must inherit the original declared types but must not have a reverse effect — changes,
such as new types or field declarations, in the copies must not be reflected in the original type resolver.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a new type to the type resolver and overrides any previous association between the type's logical name and the type itself.default <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.Collection<Type<?>>getKnownTypes(Class<?> javaClass) Returns a collection of all known types that have the same Java type as specified by the argument.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><T> Type<T>
-
Method Details
-
getType
- Type Parameters:
T- type parameter- Parameters:
name- type's logical name- Returns:
- existing
Typeornullif not found
-
getKnownTypes
Collection<Type<?>> getKnownTypes()Returns a collection of all known types.- Returns:
- a collection of Type instances representing the known types
-
getKnownTypes
Returns a collection of all known types that have the same Java type as specified by the argument.- Parameters:
javaClass- the class of the Java type to find known types for- Returns:
- a collection of Type instances representing the known types with the specified Java type
-
addType
Adds a new type to the type resolver and overrides any previous association between the type's logical name and the type itself.- Parameters:
type- The type to be added to the resolver.- Since:
- 4.0.0
-
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
-