Class SimpleRepositoryFindOneMethodHandler

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

public class SimpleRepositoryFindOneMethodHandler extends Object implements SimpleRepositoryMethodHandler
Handler for executing the "findOne" method in a simple repository. Implements the SimpleRepositoryMethodHandler interface.
Since:
1.0
Author:
Blyzhnytsia Team
  • Field Details

    • METHOD_NAME

      private static final String METHOD_NAME
      The name of the handled method.
      See Also:
    • LOOKS_LIKE_S_WITHOUT_REQUIRED_PARAMETER_ID

      private static final String LOOKS_LIKE_S_WITHOUT_REQUIRED_PARAMETER_ID
      Exception message for a method that looks like it is missing the required parameter ID.
      See Also:
    • ENTITY_NOT_FOUND

      private static final String ENTITY_NOT_FOUND
      Exception message for an entity not found by ID.
      See Also:
  • Constructor Details

    • SimpleRepositoryFindOneMethodHandler

      public SimpleRepositoryFindOneMethodHandler()
  • Method Details

    • isMethodHandle

      public boolean isMethodHandle(Method method)
      Checks if the given method is the "findOne" method.
      Specified by:
      isMethodHandle in interface SimpleRepositoryMethodHandler
      Parameters:
      method - The method to check.
      Returns:
      true if the method is "findOne", false otherwise.
    • execute

      public Object execute(Method method, Object[] parameters, RepositoryDetails repositoryDetails, MethodMetadata methodMetadata)
      Executes the "findOne" method, querying the entity by its primary key.
      Specified by:
      execute in interface SimpleRepositoryMethodHandler
      Parameters:
      method - The "findOne" 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 "findOne" method execution.
      Throws:
      EntityNotFoundException - If the entity is not found by the specified ID.
      IllegalArgumentException - If the method parameters are not as expected.