Interface SimpleRepositoryMethodHandler

All Known Implementing Classes:
SimpleRepositoryFindByIdMethodHandler, SimpleRepositoryFindOneMethodHandler, SimpleRepositoryMethodCustomImplHandler, SimpleRepositoryMethodDeleteAllHandler, SimpleRepositoryMethodDeleteHandler, SimpleRepositoryMethodFindAllHandler, SimpleRepositoryMethodFindByHandler, SimpleRepositoryMethodHqlQueryHandler, SimpleRepositoryMethodNativeQueryHandler, SimpleRepositoryMethodSaveAllHandler, SimpleRepositoryMethodSaveHandler, SimpleRepositoryMethodUpdateHandler

public interface SimpleRepositoryMethodHandler
Interface for handling the execution of repository methods. Implementations of this interface define how to identify and execute specific repository methods.

Example:

Suppose we have a repository method findById that retrieves an entity by its primary key. An implementation of this interface could identify this method and execute it by delegating to the appropriate data access layer for retrieving the entity from the database.

 public class UserRepositoryMethodHandler implements SimpleRepositoryMethodHandler {

     // Implementation of isMethodHandle method
     public boolean isMethodHandle(Method method) {
         return method.getName().equals("findById");
     }

     // Implementation of execute method
     public Object execute(Method method, Object[] parameters, RepositoryDetails repositoryDetails,
                           MethodMetadata methodMetadata) {
         // Implementation to retrieve entity by primary key from database
     }
 }
 
Since:
1.0
Author:
Blyzhnytsia Team
  • Field Details

    • HANDLE_METHOD

      static final String HANDLE_METHOD
      Log message template for handling a method.
      See Also:
    • LOOKS_LIKE_METHOD_WITHOUT_REQUIRED_PARAMETER_ID

      static final String LOOKS_LIKE_METHOD_WITHOUT_REQUIRED_PARAMETER_ID
      Error message template for a method without the required parameter ID.
      See Also:
    • CANNOT_RETURN_S_SHOULD_BE_OPTIONAL_S_OR_S

      static final String CANNOT_RETURN_S_SHOULD_BE_OPTIONAL_S_OR_S
      Error message template for an invalid return type. It should be Optional or Type.
      See Also:
    • NOT_SUPPORTED_RETURN_TYPE_FOR_METHOD_NAME

      static final String NOT_SUPPORTED_RETURN_TYPE_FOR_METHOD_NAME
      Error message template for an unsupported return type for a method.
      See Also:
    • EXPECTED_SINGLE_RESULT

      static final String EXPECTED_SINGLE_RESULT
      Error message template for an expected single result but found multiple in method.
      See Also:
    • CANNOT_FIND_RESULT_FOR_S_IN_METHOD_S

      static final String CANNOT_FIND_RESULT_FOR_S_IN_METHOD_S
      Error message template for being unable to find a result for entityClass in method with parameters.
      See Also:
  • Method Details

    • isMethodHandle

      boolean isMethodHandle(Method method)
      Checks if the given method can be handled by this handler.
      Parameters:
      method - The method to check.
      Returns:
      true if this handler can handle the method, false otherwise.
    • execute

      Object execute(Method method, Object[] parameters, RepositoryDetails repositoryDetails, MethodMetadata methodMetadata)
      Executes the given repository method using the provided parameters, repository details, and method metadata.
      Parameters:
      method - The repository 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 repository method execution.