Annotation Interface NaftahFn


@Target(METHOD) @Retention(RUNTIME) public @interface NaftahFn
Annotation to mark a method as a Naftah built-in function.

This annotation provides metadata about the function, including its name, description, usage, return type, parameter types, and exceptions it may throw.

مثال على الاستخدام:

 
 @NaftahFn(
 name = "جمع",
 description = "يحسب مجموع رقمين",
 usage = "جمع(int أ, int ب)",
 returnType = int.class,
 parameterTypes = {int.class, int.class},
 exceptionTypes = {}
 )
 public int جمع(int أ, int ب) { ... }
 
 
Author:
Chakib Daii
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    A brief description of what the function does.
    The function name as exposed to the Naftah environment.
    The usage string or signature for the function.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Alternative names (aliases) by which the function may also be referenced.
    Class<?>[]
    The array of exception type classes that the function may throw.
    Class<?>[]
    The array of parameter type classes accepted by the function.
    The return type class of the function.
    boolean
    flags that the function aliases should be bound with the provider's name.
    boolean
    flags that the function names should be bound with the provider's name.
  • Element Details

    • name

      String name
      The function name as exposed to the Naftah environment.
      Returns:
      the function name
    • description

      String description
      A brief description of what the function does.
      Returns:
      the function description
    • usage

      String usage
      The usage string or signature for the function.
      Returns:
      the usage information
    • useQualifiedName

      boolean useQualifiedName
      flags that the function names should be bound with the provider's name.
      Returns:
      true if we should use qualified name; false if not
      Default:
      false
    • useQualifiedAliases

      boolean useQualifiedAliases
      flags that the function aliases should be bound with the provider's name.
      Returns:
      true if we should use qualified name; false if not
      Default:
      false
    • aliases

      String[] aliases
      Alternative names (aliases) by which the function may also be referenced.

      Aliases can be used to access the same function under different identifiers, typically for backwards compatibility or syntactic sugar.

      Returns:
      an array of alias names, or an empty array if none
      Default:
      {}
    • returnType

      Class<?> returnType
      The return type class of the function. Defaults to Void.class if no return value.
      Returns:
      the return type class
      Default:
      java.lang.Void.class
    • parameterTypes

      Class<?>[] parameterTypes
      The array of parameter type classes accepted by the function.
      Returns:
      array of parameter types
      Default:
      {}
    • exceptionTypes

      Class<?>[] exceptionTypes
      The array of exception type classes that the function may throw.
      Returns:
      array of exception types
      Default:
      {}