Fix checkstyle warnings in yang-jmx-generator.
[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         }
39         if (!(o instanceof AbstractAttribute)) {
40             return false;
41         }
42
43         AbstractAttribute that = (AbstractAttribute) o;
44
45         if (attributeYangName != null ? !attributeYangName
46                 .equals(that.attributeYangName)
47                 : that.attributeYangName != null) {
48             return false;
49         }
50
51         return true;
52     }
53
54     @Override
55     public int hashCode() {
56         return attributeYangName != null ? attributeYangName.hashCode() : 0;
57     }
58
59     /**
60      *
61      * @return Yang name converted to cammel case, starting with a capital
62      *         letter. For details see
63      *         {@link ModuleMXBeanEntry#findJavaNamePrefix(org.opendaylight.yangtools.yang.model.api.SchemaNode)}
64      */
65     @Override
66     public String getUpperCaseCammelCase() {
67         return upperCaseCammelCase;
68     }
69
70     public String getLowerCaseCammelCase() {
71         return lowerCaseCammelCase;
72     }
73 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.