2 * Copyright (c) 2015 CableLabs and others. All rights reserved.
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
9 package org.opendaylight.controller.packetcable.provider.validation.impl.validators.qos.classifier;
11 import org.opendaylight.controller.packetcable.provider.validation.impl.validators.AbstractValidator;
12 import org.opendaylight.yang.gen.v1.urn.packetcable.rev170224.classifier.attributes.classifiers.classifier.container.ClassifierChoice;
13 import org.opendaylight.yang.gen.v1.urn.packetcable.rev170224.classifier.attributes.classifiers.classifier.container.classifier.choice.ExtClassifierChoice;
14 import org.opendaylight.yang.gen.v1.urn.packetcable.rev170224.classifier.attributes.classifiers.classifier.container.classifier.choice.Ipv6ClassifierChoice;
15 import org.opendaylight.yang.gen.v1.urn.packetcable.rev170224.classifier.attributes.classifiers.classifier.container.classifier.choice.QosClassifierChoice;
20 public class ClassifierChoiceValidator extends AbstractValidator<ClassifierChoice> {
22 private final ClassifierValidator classifierValidator = new ClassifierValidator();
23 private final ExtClassifierValidator extClassifierValidator = new ExtClassifierValidator();
24 private final Ipv6ClassifierValidator ipv6ClassifierValidator = new Ipv6ClassifierValidator();
27 protected void doValidate(final ClassifierChoice choice, final Extent extent) {
29 getErrorMessages().add("classifier-choice must exist");
33 // Determine what type this choice is then validate it
34 if (choice instanceof QosClassifierChoice) {
35 validateChild(classifierValidator, ((QosClassifierChoice) choice).getClassifier());
37 else if (choice instanceof ExtClassifierChoice) {
38 validateChild(extClassifierValidator, ((ExtClassifierChoice) choice).getExtClassifier());
40 else if (choice instanceof Ipv6ClassifierChoice) {
41 validateChild(ipv6ClassifierValidator, ((Ipv6ClassifierChoice) choice).getIpv6Classifier());
44 throw new IllegalStateException("Unknown ClassifierChoice Type: " + choice.getClass().getName());