@Test public void build_shouldCopyAllFields() { Book bookToCopy = new Book(); bookToCopy.setIsbn(ISBN); bookToCopy.setAuthor(AUTHOR); bookToCopy.setTitle(TITLE); bookToCopy.setPrice(PRICE); bookToCopy.setCategory(CATEGORIES); Book copy = new BookBuilder(bookToCopy.getIsbn()).build(bookToCopy); assertEquals(ISBN, copy.getIsbn()); assertEquals(AUTHOR, copy.getAuthor()); assertEquals(TITLE, copy.getTitle()); assertEquals(PRICE, copy.getPrice()); assertEquals(CATEGORIES, copy.getCategory()); }
@Override @Nonnull public Book build() { Book book = new Book(); book.setIsbn(isbn); book.setAuthor(author); book.setTitle(title); book.setPrice(price); book.setCategory(categories); return book; }
BookBuilder implements DomainBuilder<Book> { @Override @Nonnull public Book build() { Book book = new Book(); book.setIsbn(isbn); book.setAuthor(author); book.setTitle(title); book.setPrice(price); book.setCategory(categories); return book; } }
BookBuilder implements DomainBuilder<Book> { @Override @Nonnull public Book build() { Book book = new Book(); book.setIsbn(isbn); book.setAuthor(author); book.setTitle(title); book.setPrice(price); book.setCategory(categories); return book; } BookBuilder(@Nonnull final String isbn); }
BookBuilder implements DomainBuilder<Book> { @Override @Nonnull public Book build() { Book book = new Book(); book.setIsbn(isbn); book.setAuthor(author); book.setTitle(title); book.setPrice(price); book.setCategory(categories); return book; } BookBuilder(@Nonnull final String isbn); BookBuilder author(@Nullable final String author); BookBuilder title(@Nullable final String title); BookBuilder price(@Nullable final BigDecimal price); BookBuilder categories(@Nonnull final Set<String> categories); @Override @Nonnull Book build(); @Override @Nonnull Book build(@Nonnull final Book book); }
BookBuilder implements DomainBuilder<Book> { @Override @Nonnull public Book build() { Book book = new Book(); book.setIsbn(isbn); book.setAuthor(author); book.setTitle(title); book.setPrice(price); book.setCategory(categories); return book; } BookBuilder(@Nonnull final String isbn); BookBuilder author(@Nullable final String author); BookBuilder title(@Nullable final String title); BookBuilder price(@Nullable final BigDecimal price); BookBuilder categories(@Nonnull final Set<String> categories); @Override @Nonnull Book build(); @Override @Nonnull Book build(@Nonnull final Book book);  }