- Type Parameters:
T- the Java type associated with this logical type
- All Known Implementing Classes:
TypeWrapper
SessionOps.insertAs(String, Object) method, or implicit,
through the fact's Java type.
Each logical type is uniquely identified by its logical name, retrievable via the getName()
method, and is associated with a specific Java type, obtainable through the getJavaClass() method.
This mechanism allows for facts of the same Java type to be differentiated based on their logical names.
Each type inherits public fields and getters from its associated Java class, while also supporting the declaration of custom fields for use in rule conditions.
-
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.Returns a declared field with the given name.There can be only one Type with the given name, but there could be many types associated with a specific Java Class.Deprecated.getName()Returns logical name of the typestatic StringlogicalNameOf(Class<?> cl) Deprecated.use thegetJavaClass()method instead
-
Method Details
-
getName
String getName()Returns logical name of the type- Returns:
- logical name
-
resolveJavaType
Deprecated.use thegetJavaClass()method instead- Returns:
- the resolved Java Class associated with the type.
-
getJavaClass
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:
- the Java Class associated with the type.
-
getJavaType
Deprecated.use thegetJavaClass()method insteadThere 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:
- name of the Java Class associated with the type.
-
getField
Returns a declared field with the given name. If no such field was explicitly declared, an attempt will be made to resolve the respective field/getter of the declared Java class. If no such field or getter is found, the method will throw
IllegalArgumentExceptionEmpty field name has a special meaning of the
"this"value, i.e. such field's values represent the type's instances themself.- Parameters:
name- field name or empty string if the field denotes the type'sthisvalue- Returns:
- declared or resolved field
- Throws:
IllegalArgumentException- if no field with such name could be found or resolved
-
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
-
logicalNameOf
-
getJavaClass()method instead