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 Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
Message indicating the failure to invoke a class method with specified parameters.private static final String
Message indicating that a class method is found and will be invoked with specified parameters.List of custom repository implementations.static final String
Message indicating that the implementation for a specific method is not resolved.private static final String
Message indicating an attempt to find a custom repository implementation for a specific method.Fields inherited from interface io.github.blyznytsiaorg.bibernate.dao.method.handler.SimpleRepositoryMethodHandler
CANNOT_FIND_RESULT_FOR_S_IN_METHOD_S, CANNOT_RETURN_S_SHOULD_BE_OPTIONAL_S_OR_S, EXPECTED_SINGLE_RESULT, HANDLE_METHOD, LOOKS_LIKE_METHOD_WITHOUT_REQUIRED_PARAMETER_ID, NOT_SUPPORTED_RETURN_TYPE_FOR_METHOD_NAME
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionexecute
(Method method, Object[] parameters, RepositoryDetails repositoryDetails, MethodMetadata methodMetadata) Executes the custom method in the custom repository implementation.private static Object
invokeMethod
(Object[] parameters, Object customRepository, Method customRepositoryMethod) Invokes the specified method on the custom repository implementation with the given parameters.boolean
isMethodHandle
(Method method) Checks if the given method is handled by any of the custom repository implementations.
-
Field Details
-
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
Message indicating that a class method is found and will be invoked with specified parameters.- See Also:
-
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
Message indicating that the implementation for a specific method is not resolved.- See Also:
-
customRepositoryImplementations
List of custom repository implementations.
-
-
Constructor Details
-
SimpleRepositoryMethodCustomImplHandler
public SimpleRepositoryMethodCustomImplHandler()
-
-
Method Details
-
isMethodHandle
Checks if the given method is handled by any of the custom repository implementations.- Specified by:
isMethodHandle
in interfaceSimpleRepositoryMethodHandler
- 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 interfaceSimpleRepositoryMethodHandler
- 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.
-