// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Book.java
// public class Book extends ValueObject {
// 
//   public final String bookId;
//   public final String isbn;
//   public final String title;
//   public final String description;
// 
//   public Book(String bookId, String isbn, String title, String description) {
//     this.bookId = bookId;
//     this.isbn = isbn;
//     this.title = title;
//     this.description = description;
//   }
// 
// }
// 
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Product.java
// public class Product extends ValueObject {
// 
//   public final String productId;
//   public final Book book;
//   public final long price;
//   public final String publisherContractId;
// 
//   public Product(String productId, Book book, long price, String publisherContractId) {
//     this.productId = productId;
//     this.book = book;
//     this.price = price;
//     this.publisherContractId = publisherContractId;
//   }
// 
// }


import se.citerus.cqrs.bookstore.productcatalog.domain.Book;
import se.citerus.cqrs.bookstore.productcatalog.domain.Product;
package se.citerus.cqrs.bookstore.productcatalog.api;


public class ProductDtoFactory {

  public static ProductDto fromProduct(Product product) {
    return toProduct(product, toBook(product.book));
  }

  private static ProductDto toProduct(Product product, BookDto bookDto) {
    ProductDto productDto = new ProductDto();
    productDto.productId = product.productId;
    productDto.price = product.price;
    productDto.publisherContractId = product.publisherContractId;
    productDto.book = bookDto;
    return productDto;
  }

// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Book.java
// public class Book extends ValueObject {
// 
//   public final String bookId;
//   public final String isbn;
//   public final String title;
//   public final String description;
// 
//   public Book(String bookId, String isbn, String title, String description) {
//     this.bookId = bookId;
//     this.isbn = isbn;
//     this.title = title;
//     this.description = description;
//   }
// 
// }
// 
// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/domain/Product.java
// public class Product extends ValueObject {
// 
//   public final String productId;
//   public final Book book;
//   public final long price;
//   public final String publisherContractId;
// 
//   public Product(String productId, Book book, long price, String publisherContractId) {
//     this.productId = productId;
//     this.book = book;
//     this.price = price;
//     this.publisherContractId = publisherContractId;
//   }
// 
// }


// Path: product-catalog-context/src/main/java/se/citerus/cqrs/bookstore/productcatalog/api/ProductDtoFactory.java
import se.citerus.cqrs.bookstore.productcatalog.domain.Book;
import se.citerus.cqrs.bookstore.productcatalog.domain.Product;

package se.citerus.cqrs.bookstore.productcatalog.api;


public class ProductDtoFactory {

  public static ProductDto fromProduct(Product product) {
    return toProduct(product, toBook(product.book));
  }

  private static ProductDto toProduct(Product product, BookDto bookDto) {
    ProductDto productDto = new ProductDto();
    productDto.productId = product.productId;
    productDto.price = product.price;
    productDto.publisherContractId = product.publisherContractId;
    productDto.book = bookDto;
    return productDto;
  }

  private static BookDto toBook(Book book) {