blob: f26e95b75e0483a3cd7edc6a1da9957eadf1e9f4 (
plain)
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
|
package org.onap.nbi.apis.serviceorder.serviceordervalidator;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import org.onap.nbi.apis.serviceorder.model.ActionType;
import org.onap.nbi.apis.serviceorder.model.ServiceOrder;
import org.onap.nbi.apis.serviceorder.model.ServiceOrderItem;
import org.springframework.util.StringUtils;
public class ServiceOrderValidator implements ConstraintValidator<ValidServiceOrder, ServiceOrder> {
@Override
public boolean isValid(ServiceOrder serviceOrder, ConstraintValidatorContext context) {
for (ServiceOrderItem serviceOrderItem : serviceOrder.getOrderItem()) {
if (ActionType.ADD != serviceOrderItem.getAction()
&& StringUtils.isEmpty(serviceOrderItem.getService().getId())) {
return false;
}
}
return true;
}
}
|