Class SimpleRepositoryMethodCustomImplHandler

java.lang.Object
io.github.blyznytsiaorg.bibernate.dao.method.handler.SimpleRepositoryMethodCustomImplHandler
All Implemented Interfaces:
SimpleRepositoryMethodHandler

public class SimpleRepositoryMethodCustomImplHandler extends Object implements SimpleRepositoryMethodHandler
Handler for executing custom methods in a custom repository implementation. Implements the SimpleRepositoryMethodHandler interface.
Since:
1.0
Author:
Blyzhnytsia Team
  • Field Details

    • TRY_TO_FIND_OUT_CUSTOM_REPOSITORY_IMPLEMENTATION_FOR_S_METHOD

      private static final String TRY_TO_FIND_OUT_CUSTOM_REPOSITORY_IMPLEMENTATION_FOR_S_METHOD
      Message indicating an attempt to find a custom repository implementation for a specific method.
      See Also:
    • CLASS_METHOD_FOUND_WILL_INVOKE_IT_WITH_PARAMETERS

      private static final String CLASS_METHOD_FOUND_WILL_INVOKE_IT_WITH_PARAMETERS
      Message indicating that a class method is found and will be invoked with specified parameters.
      See Also:
    • CANNOT_INVOKE_CLASS_METHOD_WITH_PARAMETERS_MESSAGE

      private static final String CANNOT_INVOKE_CLASS_METHOD_WITH_PARAMETERS_MESSAGE
      Message indicating the failure to invoke a class method with specified parameters.
      See Also:
    • IMPLEMENTATION_FOR_METHOD_S_NOT_RESOLVED

      public static final String IMPLEMENTATION_FOR_METHOD_S_NOT_RESOLVED
      Message indicating that the implementation for a specific method is not resolved.
      See Also:
    • customRepositoryImplementations

      private final List<Object> customRepositoryImplementations
      List of custom repository implementations.
  • Constructor Details

    • SimpleRepositoryMethodCustomImplHandler

      public SimpleRepositoryMethodCustomImplHandler()
  • Method Details

    • isMethodHandle

      public boolean isMethodHandle(Method method)
      Checks if the given method is handled by any of the custom repository implementations.
      Specified by:
      isMethodHandle in interface SimpleRepositoryMethodHandler
      Parameters:
      method - The method to check.
      Returns:
      true if the method is handled, false otherwise.
    • execute

      public Object execute(Method method, Object[] parameters, RepositoryDetails repositoryDetails, MethodMetadata methodMetadata)
      Executes the custom method in the custom repository implementation.
      Specified by:
      execute in interface SimpleRepositoryMethodHandler
      Parameters:
      method - The method to execute.
      parameters - The parameters for the method invocation.
      repositoryDetails - Details about the repository, including its name, primary key type, entity type, etc.
      methodMetadata - Metadata for the repository method, including its name, return type, and parameters.
      Returns:
      The result of the custom method execution.
      Throws:
      IllegalArgumentException - If the custom method implementation for the given method is not found.
    • invokeMethod

      private static Object invokeMethod(Object[] parameters, Object customRepository, Method customRepositoryMethod)
      Invokes the specified method on the custom repository implementation with the given parameters.
      Parameters:
      parameters - The parameters for the method invocation.
      customRepository - The custom repository implementation instance.
      customRepositoryMethod - The method to invoke.
      Returns:
      The result of the method invocation.
      Throws:
      BibernateGeneralException - If an error occurs during method invocation.