Add support for multiple choice case statements within one augument in config yang...
[controller.git] / opendaylight / config / yang-jmx-generator / src / main / java / org / opendaylight / controller / config / yangjmxgenerator / attribute / AbstractAttribute.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 package org.opendaylight.controller.config.yangjmxgenerator.attribute;
9
10 import org.opendaylight.controller.config.yangjmxgenerator.TypeProviderWrapper;
11 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
12
13 public abstract class AbstractAttribute implements AttributeIfc {
14     private final String attributeYangName, upperCaseCammelCase,
15             lowerCaseCammelCase;
16     protected final DataSchemaNode node;
17
18     private static String getLocalName(DataSchemaNode attrNode) {
19         return attrNode.getQName().getLocalName();
20     }
21
22     AbstractAttribute(DataSchemaNode attrNode) {
23         this.attributeYangName = getLocalName(attrNode);
24         this.node = attrNode;
25         this.upperCaseCammelCase = TypeProviderWrapper.findJavaNamePrefix(node);
26         this.lowerCaseCammelCase = TypeProviderWrapper.findJavaParameter(node);
27     }
28
29     @Override
30     public String getAttributeYangName() {
31         return attributeYangName;
32     }
33
34     @Override
35     public boolean equals(Object o) {
36         if (this == o)
37             return true;
38         if (!(o instanceof AbstractAttribute))
39             return false;
40
41         AbstractAttribute that = (AbstractAttribute) o;
42
43         if (attributeYangName != null ? !attributeYangName
44                 .equals(that.attributeYangName)
45                 : that.attributeYangName != null)
46             return false;
47
48         return true;
49     }
50
51     @Override
52     public int hashCode() {
53         return attributeYangName != null ? attributeYangName.hashCode() : 0;
54     }
55
56     /**
57      *
58      * @return Yang name converted to cammel case, starting with a capital
59      *         letter. For details see
60      *         {@link ModuleMXBeanEntry#findJavaNamePrefix(org.opendaylight.yangtools.yang.model.api.SchemaNode)}
61      */
62     @Override
63     public String getUpperCaseCammelCase() {
64         return upperCaseCammelCase;
65     }
66
67     public String getLowerCaseCammelCase() {
68         return lowerCaseCammelCase;
69     }
70 }