f806601822e22c7ecbb4a513b8b8340f2c58ab52
[packetcable.git] / packetcable-policy-server / src / main / java / org / opendaylight / controller / packetcable / provider / validation / impl / validators / qos / AppValidator.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.rev161017.pcmm.qos.gates.apps.App;
13
14 /**
15  * @author rvail
16  */
17 public class AppValidator extends AbstractValidator<App> {
18
19     private static final String APP_ID = "app.appId";
20     private static final String SUBSCRIBERS = "app.subscribers";
21
22     private final SubscribersValidator subscribersValidator = new SubscribersValidator();
23
24     @Override
25     protected void doValidate(final App app, final Extent extent) {
26         if (app == null) {
27             getErrorMessages().add("app must exist");
28             return;
29         }
30
31         mustExist(app.getAppId(), APP_ID);
32         mustExist(app.getSubscribers(), SUBSCRIBERS);
33
34         if (extent == Extent.NODE_AND_SUBTREE) {
35             validateChild(subscribersValidator, app.getSubscribers());
36         }
37     }
38 }