5e3f54221470906fc86df848efe60673e887975b
[controller.git] / opendaylight / netconf / config-netconf-connector / src / main / java / org / opendaylight / controller / netconf / confignetconfconnector / mapping / attributes / AttributeIfcSwitchStatement.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. 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.netconf.confignetconfconnector.mapping.attributes;
10
11 import org.opendaylight.controller.config.yangjmxgenerator.attribute.*;
12
13 public abstract class AttributeIfcSwitchStatement<T> {
14
15     public T switchAttribute(AttributeIfc attributeIfc) {
16
17         if (attributeIfc instanceof JavaAttribute) {
18             return caseJavaAttribute((JavaAttribute) attributeIfc);
19         } else if (attributeIfc instanceof DependencyAttribute) {
20             return caseDependencyAttribute((DependencyAttribute) attributeIfc);
21         } else if (attributeIfc instanceof ListAttribute) {
22             return caseListAttribute((ListAttribute) attributeIfc);
23         } else if (attributeIfc instanceof TOAttribute) {
24             return caseTOAttribute((TOAttribute) attributeIfc);
25         }
26
27         throw new IllegalArgumentException("Unknown attribute type " + attributeIfc.getClass() + ", " + attributeIfc);
28     }
29
30     protected abstract T caseJavaAttribute(JavaAttribute attributeIfc);
31
32     protected abstract T caseDependencyAttribute(DependencyAttribute attributeIfc);
33
34     protected abstract T caseTOAttribute(TOAttribute attributeIfc);
35
36     protected abstract T caseListAttribute(ListAttribute attributeIfc);
37 }