ProductPojo.java
864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package fi.codecrew.moya.rest.v2.pojo;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;
import com.wordnik.swagger.annotations.ApiModel;
import fi.codecrew.moya.model.Product;
@XmlRootElement()
@ApiModel(description = "Product")
public class ProductPojo {
public Integer id;
public String description;
public BigDecimal price;
public String name;
public static ProductPojo convert(Product prod) {
ProductPojo ret = new ProductPojo();
ret.id = prod.getId();
ret.name = prod.getName();
ret.price = prod.getPrice();
ret.description = prod.getDescription();
return ret;
}
public static List<ProductPojo> convert(List<Product> prods) {
ArrayList<ProductPojo> ret = new ArrayList<>();
for (Product p : prods) {
ret.add(convert(p));
}
return ret;
}
}