Added response data to operational datastore, refactored data validation
[packetcable.git] / packetcable-policy-server / src / main / java / org / opendaylight / controller / packetcable / provider / validation / impl / validators / qos / SubscribersValidator.java
1 /*
2  * Copyright (c) 2015 CableLabs and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.packetcable.provider.validation.impl.validators.qos;
10
11 import org.opendaylight.controller.packetcable.provider.validation.ValidationException;
12 import org.opendaylight.controller.packetcable.provider.validation.impl.validators.AbstractValidator;
13 import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.pcmm.qos.gates.apps.app.Subscribers;
14 import org.opendaylight.yang.gen.v1.urn.packetcable.rev151026.pcmm.qos.gates.apps.app.subscribers.Subscriber;
15
16 /**
17  * @author rvail
18  */
19 public class SubscribersValidator extends AbstractValidator<Subscribers> {
20
21     private final SubscriberValidator subscriberValidator = new SubscriberValidator();
22
23     @Override
24     public void validate(final Subscribers subscribers, final Extent extent) throws ValidationException {
25         if (subscribers == null) {
26             throw new ValidationException("subscribers must exist");
27         }
28
29         if (extent == Extent.NODE_AND_SUBTREE) {
30             for (Subscriber subscriber : subscribers.getSubscriber()) {
31                 validateChild(subscriberValidator , subscriber);
32             }
33         }
34
35         throwErrorsIfNeeded();
36     }
37
38 }