-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCatalogService.java
More file actions
31 lines (26 loc) · 889 Bytes
/
CatalogService.java
File metadata and controls
31 lines (26 loc) · 889 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
package org.javaee7.chapter06;
import javax.validation.Valid;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.validation.executable.ValidateOnExecution;
import org.javaee7.beans.Order;
import org.javaee7.interfaces.Widget;
/**
*
* @author Juneau
*/
public class CatalogService {
@ValidateOnExecution(type=javax.validation.executable.ExecutableType.NON_GETTER_METHODS)
public Order placeOrder(
@NotNull @Size(min = 3, max = 20) String customerNumber,
@NotNull @Valid Widget widget,
@Min(1) int quantity) {
Order order = new Order();
order.setCustomerNumber(customerNumber);
order.setProduct(widget);
order.setQuantity(quantity);
// Send the order to the database
return order;
}
}