Interface Type<T>
- Type Parameters:
T- Java type associated with this type
- All Known Implementing Classes:
TypeWrapper
An engine's internal type which is assigned to every fact before it gets into the session's working memory. It allows for dynamic, real-time field declarations either as functional interfaces or via the Java Reflection API.
-
Method Summary
Modifier and TypeMethodDescriptiondefault TypeFielddeclareBooleanField(String name, Predicate<T> function) Method declares a primitivebooleanfield.default TypeFielddeclareDoubleField(String name, ToDoubleFunction<T> function) Method declares a primitivedoublefield.<V> TypeFielddeclareField(String name, Class<V> type, Function<T, V> function) Field declaration with aFunctionas value reader.default TypeFielddeclareIntField(String name, ToIntFunction<T> function) Method declares a primitiveintfield.default TypeFielddeclareLongField(String name, ToLongFunction<T> function) Method declares a primitivelongfield.Method returns ALL known fields, both explicitly declared and resolved.getField(int id) Returns a declared field with the given name, or null if no such field is found or resolvedReturns a declared field with the given name, or null if no such field is found or resolvedintgetId()Each type is assigned a unique auto-increment int identifier which developers can use in SPI implementations, for example in sharding/partitioning data collections.There can be only one Type with the given name, but there could be many types associated with a specific Java Class.
-
Method Details
-
getId
int getId()Each type is assigned a unique auto-increment int identifier which developers can use in SPI implementations, for example in sharding/partitioning data collections.
- Returns:
- unique type identifier.
-
getJavaType
There can be only one Type with the given name, but there could be many types associated with a specific Java Class. This method returns the associated Java type.
- Returns:
- Java Class associated with the type.
-
getDeclaredFields
Collection<TypeField> getDeclaredFields()Method returns ALL known fields, both explicitly declared and resolved.
- Returns:
- Collection of declared fields
- See Also:
-
getField
Returns a declared field with the given name, or null if no such field is found or resolved
- Parameters:
name- field name- Returns:
- a declared field or null
-
getField
Returns a declared field with the given name, or null if no such field is found or resolved
- Parameters:
id- field name- Returns:
- a declared field or null
-
declareField
Field declaration with a
Functionas value reader.- Type Parameters:
V- field value generic type- Parameters:
name- field nametype- field value classfunction- the function that will be used to read field's value- Returns:
- a newly created field or an existing one if already declared/resolved
-
declareIntField
Method declares a primitive
intfield.- Parameters:
name- field namefunction- field functional interface- Returns:
- a newly created field or an existing one if already declared/resolved
-
declareLongField
Method declares a primitive
longfield.- Parameters:
name- field namefunction- field functional interface- Returns:
- a newly created field or an existing one if already declared/resolved
-
declareDoubleField
Method declares a primitive
doublefield.- Parameters:
name- field namefunction- field functional interface- Returns:
- a newly created field or an existing one if already declared/resolved
-
declareBooleanField
Method declares a primitive
booleanfield.- Parameters:
name- field namefunction- field functional interface- Returns:
- a newly created field or an existing one if already declared/resolved
-