Package org.daiitech.naftah.builtin.lang
Class BuiltinFunction
java.lang.Object
org.daiitech.naftah.builtin.lang.BuiltinFunction
- All Implemented Interfaces:
Serializable,JvmExecutable
Representation of a builtin function.
This class wraps a Method along with additional metadata
about the function's provider and function information.
It supports serialization by storing the method's class and method names
and restoring the Method reference upon deserialization.
- Author:
- Chakib Daii
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final StringThe fully qualified name of the class declaring the method.private final NaftahFunctionFunction information for this function.private MethodThe reflected method instance.private final StringThe name of the method.private final Class<?>[]The method parameter types.private final NaftahFunctionProviderProvider information for this function.private static final long -
Constructor Summary
ConstructorsConstructorDescriptionBuiltinFunction(Method method, NaftahFunctionProvider providerInfo, NaftahFunction functionInfo) Constructs aBuiltinFunctionwith the given method and metadata. -
Method Summary
Modifier and TypeMethodDescriptionReturns the underlying reflectiveExecutableinstance represented by this object.Returns the function-specific information associated with this function.Returns the reflectedMethodinstance representing this builtin function.Returns the provider information associated with this function.static BuiltinFunctionof(Method method, NaftahFunctionProvider providerInfo, NaftahFunction functionInfo) Static factory method to create a newBuiltinFunctioninstance.private voidCustom deserialization logic.toString()Returns a string representation of this builtin function.private voidCustom serialization logic.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
methodName
The name of the method. -
methodParameterTypes
The method parameter types. -
className
The fully qualified name of the class declaring the method. -
providerInfo
Provider information for this function. -
functionInfo
Function information for this function. -
method
The reflected method instance. Marked transient because it is not serializable and restored after deserialization.
-
-
Constructor Details
-
BuiltinFunction
public BuiltinFunction(Method method, NaftahFunctionProvider providerInfo, NaftahFunction functionInfo) Constructs aBuiltinFunctionwith the given method and metadata.- Parameters:
method- the reflected method representing this builtin functionproviderInfo- the provider information for the functionfunctionInfo- the function-specific information
-
-
Method Details
-
of
public static BuiltinFunction of(Method method, NaftahFunctionProvider providerInfo, NaftahFunction functionInfo) Static factory method to create a newBuiltinFunctioninstance.- Parameters:
method- the reflected method representing this builtin functionproviderInfo- the provider information for the functionfunctionInfo- the function-specific information- Returns:
- a new
BuiltinFunctioninstance
-
getMethod
Returns the reflectedMethodinstance representing this builtin function.- Returns:
- the method instance
-
getProviderInfo
Returns the provider information associated with this function.- Returns:
- the function provider information
-
getFunctionInfo
Returns the function-specific information associated with this function.- Returns:
- the function information
-
getExecutable
Returns the underlying reflectiveExecutableinstance represented by this object.This may correspond to a Java method, constructor, or other callable element recognized by the JVM.
- Specified by:
getExecutablein interfaceJvmExecutable- Returns:
- the associated
Executableinstance
-
writeObject
Custom serialization logic. Writes the non-transient fields using default serialization.- Parameters:
oos- the output stream to write to- Throws:
IOException- if an I/O error occurs
-
readObject
Custom deserialization logic. Reads the non-transient fields using default deserialization, then restores the transientmethodfield by locating the method by name in the deserialized class.- Parameters:
ois- the input stream to read from- Throws:
IOException- if an I/O error occursClassNotFoundException- if the class for the method cannot be found
-
toString
Returns a string representation of this builtin function. The format is <دالة functionName>. -
toDetailedString
-