Added Product mapping and validation
This commit is contained in:
@@ -1,14 +1,44 @@
|
||||
package de.rwu.easydrop.service.mapping;
|
||||
|
||||
import de.rwu.easydrop.api.dto.ProductDTO;
|
||||
import de.rwu.easydrop.model.Product;
|
||||
|
||||
/**
|
||||
* Maps between Product, ProductDAO and ProductDTO.
|
||||
*
|
||||
* TODO implement
|
||||
* @since 0.2.0
|
||||
*
|
||||
* @see Product
|
||||
* @see ProductDTO
|
||||
* @see ProductDAO
|
||||
*/
|
||||
public class ProductMapper {
|
||||
public final class ProductMapper {
|
||||
|
||||
/**
|
||||
* Private constructor to prevent unwanted instantiation.
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
private ProductMapper() throws UnsupportedOperationException {
|
||||
throw new UnsupportedOperationException("This is a mapping class, don't instantiate it.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Product object from a corresponding DTO.
|
||||
*
|
||||
* @param dto Product Data Transfer Object
|
||||
* @return Product
|
||||
*/
|
||||
public static Product mapProductFromDTO(final ProductDTO dto) {
|
||||
Product product = new Product();
|
||||
|
||||
product.setAvailable(dto.isAvailable());
|
||||
product.setCurrentPrice(dto.getCurrentPrice());
|
||||
product.setDataOrigin(dto.getDataOrigin());
|
||||
product.setDeliveryPrice(dto.getDeliveryPrice());
|
||||
product.setMerchant(dto.getMerchant());
|
||||
product.setProductId(dto.getProductId());
|
||||
|
||||
return product;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Maps different formats of corresponding objects.
|
||||
*
|
||||
* TODO implement
|
||||
* @since 0.2.0
|
||||
*/
|
||||
package de.rwu.easydrop.service.mapping;
|
||||
|
||||
Reference in New Issue
Block a user