Package org.daiitech.naftah.builtin.lang
Class JvmClassInitializer
java.lang.Object
org.daiitech.naftah.builtin.lang.JvmClassInitializer
- All Implemented Interfaces:
Serializable,JvmExecutable
Represents a Java class
Constructor that can be invoked dynamically.
This class serves as a reflective wrapper around a Constructor<?>,
storing metadata about its declaring class, parameter types, and whether
it is invocable. It also provides serialization support, automatically
restoring the transient Constructor instance upon deserialization
by matching parameter types.
Arabic terminology:
- المنشئ — Constructor
- المُعدّلات — Modifiers
- المعاملات — Parameters
- Author:
- Chakib Daii
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Class<?>The class declaring this constructor.private Constructor<?>The reflected constructor instance (transient for serialization).private final Class<?>[]The parameter types accepted by this constructor.private final booleanWhether this constructor is invocable (accessible and valid).private final StringThe fully qualified signature identifying this constructor.private static final long -
Constructor Summary
ConstructorsConstructorDescriptionJvmClassInitializer(String qualifiedName, Class<?> clazz, Constructor<?> constructor, boolean isInvocable) Creates a newJvmClassInitializerwrapper. -
Method Summary
Modifier and TypeMethodDescriptionClass<?>getClazz()Gets the class declaring the method.Constructor<?>Gets the class constructor.Class<?>[]Returns the parameter types accepted by this constructor.Returns the underlying reflectiveExecutableinstance represented by this object.Gets the class qualified name.booleanChecks if the method is invocable.static JvmClassInitializerof(String qualifiedName, Class<?> clazz, Constructor<?> constructor) Factory method for creating aJvmClassInitializerinstance.private voidCustom deserialization logic for restoring the transientConstructor.Returns a detailed, Arabic-formatted string representation of this constructor, including its class, parameters, modifiers, and annotations.toString()Returns a concise Arabic-labeled string representation of this constructor.private voidCustom serialization logic for writing non-transient fields.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
clazz
The class declaring this constructor. -
qualifiedName
The fully qualified signature identifying this constructor. -
constructorParameterTypes
The parameter types accepted by this constructor. -
isInvocable
private final boolean isInvocableWhether this constructor is invocable (accessible and valid). -
constructor
The reflected constructor instance (transient for serialization).
-
-
Constructor Details
-
JvmClassInitializer
public JvmClassInitializer(String qualifiedName, Class<?> clazz, Constructor<?> constructor, boolean isInvocable) Creates a newJvmClassInitializerwrapper.- Parameters:
qualifiedName- the fully qualified constructor signatureclazz- the class declaring the constructorconstructor- the reflected constructor instanceisInvocable- whether the constructor can be invoked
-
-
Method Details
-
of
public static JvmClassInitializer of(String qualifiedName, Class<?> clazz, Constructor<?> constructor) Factory method for creating aJvmClassInitializerinstance.- Parameters:
qualifiedName- the fully qualified constructor signatureclazz- the declaring classconstructor- the reflected constructor- Returns:
- a new
JvmClassInitializerinstance
-
getClazz
Gets the class declaring the method.- Returns:
- the class declaring this constructor
-
getQualifiedName
Gets the class qualified name.- Returns:
- the fully qualified name of this constructor
-
getConstructor
Gets the class constructor.- Returns:
- the reflected
Constructorinstance
-
isInvocable
public boolean isInvocable()Checks if the method is invocable.- Returns:
trueif this constructor can be invoked, otherwisefalse
-
getConstructorParameterTypes
Returns the parameter types accepted by this constructor.- Returns:
- an array of
Classobjects representing the constructor's parameter types
-
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 for writing non-transient fields.- Parameters:
oos- the object output stream- Throws:
IOException- if an I/O error occurs
-
readObject
Custom deserialization logic for restoring the transientConstructor.After reading object data, this method searches the declaring class for a constructor with matching parameter types and restores it.
- Parameters:
ois- the object input stream- Throws:
IOException- if an I/O error occursClassNotFoundException- if a class cannot be found during deserialization
-
toString
Returns a concise Arabic-labeled string representation of this constructor.Format:
<منشئ qualifiedName> -
toDetailedString
Returns a detailed, Arabic-formatted string representation of this constructor, including its class, parameters, modifiers, and annotations.Example output:
تفاصيل المنشئ: - الاسم المؤهل: com.example.MyClass - كوم:إِكْزامْبِل:ماي_كْلاس - المعاملات: - java.lang.String - جافا:لانغ:سترينج - المُعدّلات: public - بَبْلِكْ - التعليقات التوضيحية: - @java.lang.Deprecated - جافا:لانغ:دِبْرِكَيْتِدْ
- Returns:
- an Arabic, multi-line description of the constructor’s metadata
-