@Override public GetBookResult execute(GetBookCommand command) { validateCommand(command); Book book = jpacrudOperationDAO.getById(Book.class, command.getBookId()); if (book == null || !book.getBookId().equals(command.getBookId())) { throw new RuntimeException("Book id not valid"); } return new GetBookResult(book); }
private void validateCommand(GetBookCommand command) { checkNotNull(command, "GetBookCommand must not be null"); checkNotNull(command.getBookId(), "Book id must not be null"); }