src/main/java/com/loyalty/homework/services/MessageService.java
@NonNull
    public Reply replyToReply(@NonNull final String postId, @NonNull final String replyId, @NonNull final Reply reply) {
        Validate.notEmpty(postId, "PostId id of post can not be empty");
        Validate.notEmpty(replyId, "Reply id of parent reply can not be empty");
        final Reply parentReply = replyDAO.getReply(postId, replyId);
        if (parentReply == null) {
            throw new IllegalStateException("Something very wrong the parent reply does not exist: " + replyId);
        }
        final Reply replyToSave = new Reply();
        replyToSave.setRootMessageId(postId);
        replyToSave.setMessage(reply.getMessage());
        replyToSave.setMessageDepth(parentReply.getMessageDepth() + 1);
        replyToSave.setMessageId(parentReply.getMessageId() + "_" + replyToSave.getMessageId());
        replyToSave.setCity(reply.getCity());
        replyToSave.setUserName(reply.getUserName() == null || reply.getUserName().trim().isEmpty() ? "anoymous" : reply.getUserName());
        replyDAO.save(replyToSave);
        return replyToSave;
    }
/**
     * Service all that creates a reply that is to another reply
     *
     * @param postId  the root post being replied to
     * @param replyId the reply that is being replied to
     * @param reply   the reply
     * @return the unique id associated with the reply
     */
Service all that creates a reply that is to another reply
@param postId  the root post being replied to
@param replyId the reply that is being replied to
@param reply   the reply
@return the unique id associated with the reply
Service all that creates a reply that is to another reply @param postId the root post being replied to @param replyId the reply that is being replied to @param reply the reply @return the unique id associated with the reply
@NonNull
    public Reply replyToReply(@NonNull final String postId, @NonNull final String replyId, @NonNull final Reply reply) {
        Validate.notEmpty(postId, "PostId id of post can not be empty");
        Validate.notEmpty(replyId, "Reply id of parent reply can not be empty");
        final Reply parentReply = replyDAO.getReply(postId, replyId);
        if (parentReply == null) {
            throw new IllegalStateException("Something very wrong the parent reply does not exist: " + replyId);
        }
        final Reply replyToSave = new Reply();
        replyToSave.setRootMessageId(postId);
        replyToSave.setMessage(reply.getMessage());
        replyToSave.setMessageDepth(parentReply.getMessageDepth() + 1);
        replyToSave.setMessageId(parentReply.getMessageId() + "_" + replyToSave.getMessageId());
        replyToSave.setCity(reply.getCity());
        replyToSave.setUserName(reply.getUserName() == null || reply.getUserName().trim().isEmpty() ? "anoymous" : reply.getUserName());
        replyDAO.save(replyToSave);
        return replyToSave;
    }
@ NonNull public Reply replyToReply ( @ NonNull final String postId , @ NonNull final String replyId , @ NonNull final Reply reply ) { Validate . notEmpty ( postId , "PostId id of post can not be empty" ) ; Validate . notEmpty ( replyId , "Reply id of parent reply can not be empty" ) ; final Reply parentReply = replyDAO . getReply ( postId , replyId ) ; if ( parentReply == null ) { throw new IllegalStateException ( "Something very wrong the parent reply does not exist: " + replyId ) ; } final Reply replyToSave = new Reply ( ) ; replyToSave . setRootMessageId ( postId ) ; replyToSave . setMessage ( reply . getMessage ( ) ) ; replyToSave . setMessageDepth ( parentReply . getMessageDepth ( ) + 1 ) ; replyToSave . setMessageId ( parentReply . getMessageId ( ) + "_" + replyToSave . getMessageId ( ) ) ; replyToSave . setCity ( reply . getCity ( ) ) ; replyToSave . setUserName ( reply . getUserName ( ) == null || reply . getUserName ( ) . trim ( ) . isEmpty ( ) ? "anoymous" : reply . getUserName ( ) ) ; replyDAO . save ( replyToSave ) ; return replyToSave ; }
Service all that creates a reply that is to another reply
 @param postId  the root post being replied to
 @param replyId the reply that is being replied to
 @param reply   the reply
 @return the unique id associated with the reply
Service all that creates a reply that is to another reply @param postId the root post being replied to @param replyId the reply that is being replied to @param reply the reply @return the unique id associated with the reply