Class CommentRepositoryAdapterImpl
java.lang.Object
com.example.blogs.app.api.comment.repository.adapter.CommentRepositoryAdapterImpl
- All Implemented Interfaces:
CommentRepositoryAdapter
@Component
public class CommentRepositoryAdapterImpl
extends Object
implements CommentRepositoryAdapter
Wraps comment repository operations with exception translation for consistent error handling.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteById(Long commentId) Deletes a comment by its ID with exception translation.booleanexistsById(Long commentId) Checks if a comment exists with the specified ID.booleanexistsByIdAndAuthorId(Long commentId, Long authorId) Checks if a comment exists with the specified ID and author ID.findAllByPostId(Long postId) Retrieves all comments associated with a specific post with exception translation.Retrieves a comment by its ID with exception translation.save(CommentEntity commentEntity) Saves a comment entity to the database with exception translation.
-
Constructor Details
-
CommentRepositoryAdapterImpl
public CommentRepositoryAdapterImpl()
-
-
Method Details
-
findAllByPostId
Retrieves all comments associated with a specific post with exception translation. Wraps repository exceptions in a domain-specific exception for consistent error handling.- Specified by:
findAllByPostIdin interfaceCommentRepositoryAdapter- Parameters:
postId- the ID of the post- Returns:
- list of comments for the post
- Throws:
FailedToFindCommentsByPostIdException- if the repository operation fails
-
save
Saves a comment entity to the database with exception translation. Wraps repository exceptions in a domain-specific exception for consistent error handling.- Specified by:
savein interfaceCommentRepositoryAdapter- Parameters:
commentEntity- the comment entity to save- Returns:
- the saved comment entity with generated ID
- Throws:
FailedToCreateCommentException- if the save operation fails
-
existsById
Checks if a comment exists with the specified ID. Wraps repository exceptions in a domain-specific exception for consistent error handling.- Specified by:
existsByIdin interfaceCommentRepositoryAdapter- Parameters:
commentId- the ID of the comment- Returns:
- true if a comment with the given ID exists, false otherwise
- Throws:
FailedToCheckCommentExistenceException- if the check operation fails
-
existsByIdAndAuthorId
Checks if a comment exists with the specified ID and author ID. Wraps repository exceptions in a domain-specific exception for consistent error handling.- Specified by:
existsByIdAndAuthorIdin interfaceCommentRepositoryAdapter- Parameters:
commentId- the ID of the commentauthorId- the ID of the author- Returns:
- true if a comment with the given ID and author exists, false otherwise
- Throws:
FailedToCheckCommentExistenceException- if the check operation fails
-
deleteById
Deletes a comment by its ID with exception translation. Wraps repository exceptions in a domain-specific exception for consistent error handling.- Specified by:
deleteByIdin interfaceCommentRepositoryAdapter- Parameters:
commentId- the ID of the comment to delete- Throws:
FailedToDeleteCommentException- if the delete operation fails
-
findById
Retrieves a comment by its ID with exception translation. Wraps repository exceptions in domain-specific exceptions for consistent error handling.- Specified by:
findByIdin interfaceCommentRepositoryAdapter- Parameters:
commentId- the ID of the comment to retrieve- Returns:
- the comment entity if found
- Throws:
CommentNotFoundException- if the comment does not existFailedToFindCommentByIdException- if the retrieval operation fails
-