Class JvmFunction
- All Implemented Interfaces:
Serializable,JvmExecutable
This class wraps a Method along with its containing class,
and stores information about whether the method is static and invocable.
It also supports serialization, recreating the transient Method
upon deserialization by matching the method name.
- Author:
- Chakib Daii
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Class<?>The class that declares the method.private final booleanWhether the method is invocable.private final booleanWhether the method is static.private MethodThe reflected method instance.private final StringThe name of the method.private final Class<?>[]The method parameter types.private final StringFully qualified call signature of the method.private static final long -
Constructor Summary
ConstructorsConstructorDescriptionJvmFunction(String qualifiedCall, Class<?> clazz, Method method, boolean isStatic, boolean isInvocable) Constructs a newJvmFunction. -
Method Summary
Modifier and TypeMethodDescriptionClass<?>getClazz()Gets the class declaring the method.Returns the underlying reflectiveExecutableinstance represented by this object.Gets the reflected method.Gets the method's name.Class<?>[]Returns the parameter types accepted by this method.Gets the fully qualified call signature.booleanChecks if the method is invocable.booleanisStatic()Checks if the method is static.static JvmFunctionFactory method to create aJvmFunctionfrom a class and method.private voidCustom deserialization logic to restore the transientMethodby searching methods with matching name and parameter types in the class.Returns a detailed, Arabic-formatted string representation of thisJvmFunction, including metadata about the method, such as return type, parameters, modifiers, and annotations.toString()Returns a concise string representation of thisJvmFunction, formatted in Arabic as<دالة qualifiedCall>.private voidCustom serialization logic to write the object's non-transient fields.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
qualifiedCall
Fully qualified call signature of the method. -
clazz
The class that declares the method. -
methodName
The name of the method. -
methodParameterTypes
The method parameter types. -
isStatic
private final boolean isStaticWhether the method is static. -
isInvocable
private final boolean isInvocableWhether the method is invocable. -
method
The reflected method instance. Marked transient for serialization.
-
-
Constructor Details
-
JvmFunction
public JvmFunction(String qualifiedCall, Class<?> clazz, Method method, boolean isStatic, boolean isInvocable) Constructs a newJvmFunction.- Parameters:
qualifiedCall- the fully qualified method call signatureclazz- the class declaring the methodmethod- the reflected methodisStatic- true if the method is staticisInvocable- true if the method is invocable
-
-
Method Details
-
of
Factory method to create aJvmFunctionfrom a class and method.- Parameters:
qualifiedCall- the fully qualified method call signatureclazz- the class declaring the methodmethod- the reflected method- Returns:
- a new
JvmFunctioninstance
-
getQualifiedCall
Gets the fully qualified call signature.- Returns:
- the qualified call string
-
getClazz
Gets the class declaring the method.- Returns:
- the declaring class
-
getMethod
Gets the reflected method.- Returns:
- the method instance
-
getMethodName
Gets the method's name.- Returns:
- the method name
-
getMethodParameterTypes
Returns the parameter types accepted by this method.- Returns:
- an array of
Classobjects representing the method's parameter types
-
isStatic
public boolean isStatic()Checks if the method is static.- Returns:
- true if static, false otherwise
-
isInvocable
public boolean isInvocable()Checks if the method is invocable.- Returns:
- true if invocable, false otherwise
-
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 to write the object's non-transient fields.- Parameters:
oos- the object output stream- Throws:
IOException- if an I/O error occurs
-
readObject
Custom deserialization logic to restore the transientMethodby searching methods with matching name and parameter types in the class.- Parameters:
ois- the object input stream- Throws:
IOException- if an I/O error occursClassNotFoundException- if the class of a serialized object cannot be found
-
toString
Returns a concise string representation of thisJvmFunction, formatted in Arabic as<دالة qualifiedCall>.This is intended for short, human-readable descriptions, using the Arabic label "دالة" (which means "function" or "method").
-
toDetailedString
Returns a detailed, Arabic-formatted string representation of thisJvmFunction, including metadata about the method, such as return type, parameters, modifiers, and annotations.The output is structured in a human-readable Arabic format and includes phonetic transliterations (into Arabic script) for class names, return types, modifiers, and annotations using
ClassUtils.getQualifiedName(String)orScriptUtils.transliterateToArabicScriptDefault(String...).The following information is included:
- Qualified method name — including both the fully qualified and transliterated form
- Return type — full Java type name with its Arabic transliteration
- Parameters — each parameter type with its fully qualified name and transliteration
- Modifiers — Java keywords (e.g.,
public static) with their Arabic transliteration - Annotations — fully qualified annotation names with transliterations
Example output:
تفاصيل الدالة: - الاسم المؤهل: com.example.MyClass::greet - كوم:إِكْزامْبِل:ماي_كْلاس::غْرِيتْ - نوع الإرجاع: java.lang.String - جافا:لانغ:سترينج - المعاملات: - java.lang.String - جافا:لانغ:سترينج - المُعدّلات: public static - بَبْلِكْ سْتَاتِكْ - التعليقات التوضيحية: - @java.lang.Deprecated - جافا:لانغ:دِبْرِكَيْتِدْ
- Returns:
- a formatted, multi-line Arabic string describing the method's structure and metadata
-