b16edab2913608d32b319df3e9f8fbb5827cd60b
[packetcable.git] / packetcable-policy-server / src / main / java / org / opendaylight / controller / packetcable / provider / validation / impl / validators / ccaps / AmIdValidator.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.ccaps;
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.rev151101.ccap.attributes.AmId;
14
15 /**
16  * @author rvail
17  */
18 public class AmIdValidator extends AbstractValidator<AmId> {
19
20     private static final String AM_TYPE = "amId.am-type";
21     private static final String AM_TAG = "amId.am-tag";
22
23     @Override
24     public void validate(final AmId amId, Extent extent) throws ValidationException {
25
26         if (amId == null) {
27             throw new ValidationException("amId must exist");
28         }
29
30         mustExist(amId.getAmTag(), AM_TAG);
31         mustExist(amId.getAmType(), AM_TYPE);
32
33         throwErrorsIfNeeded();
34     }
35 }