4bef131b150cc0057bd6fb610e8e2f7b7cdc2e82
[packetcable.git] / packetcable-policy-server / src / main / java / org / opendaylight / controller / packetcable / provider / validation / impl / validators / qos / GatesValidator.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.impl.validators.AbstractValidator;
12 import org.opendaylight.yang.gen.v1.urn.packetcable.rev161219.pcmm.qos.gates.apps.app.subscribers.subscriber.Gates;
13 import org.opendaylight.yang.gen.v1.urn.packetcable.rev161219.pcmm.qos.gates.apps.app.subscribers.subscriber.gates.Gate;
14
15 /**
16  * @author rvail
17  */
18 public class GatesValidator extends AbstractValidator<Gates> {
19
20     private final GateValidator gateValidator = new GateValidator();
21
22     @Override
23     protected void doValidate(final Gates gates, final Extent extent) {
24         if (gates == null) {
25             getErrorMessages().add("gates must exist");
26             return;
27         }
28
29         if (extent == Extent.NODE_AND_SUBTREE) {
30             if (gates.getGate() != null) {
31                 for (Gate gate : gates.getGate()) {
32                     validateChild(gateValidator, gate);
33                 }
34             }
35         }
36     }
37 }