Merge "Cleanup RpcRoutingStrategy definition"
[controller.git] / opendaylight / config / yang-jmx-generator / src / main / java / org / opendaylight / controller / config / yangjmxgenerator / attribute / AbstractDependencyAttribute.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.ServiceInterfaceEntry;
11 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
12
13 public abstract class AbstractDependencyAttribute extends AbstractAttribute  implements TypedAttribute  {
14
15     protected final Dependency dependency;
16     protected final String nullableDescription, nullableDefault;
17
18     public AbstractDependencyAttribute(DataSchemaNode attrNode,
19                                        ServiceInterfaceEntry sie, boolean mandatory,
20                                        String nullableDescription) {
21         super(attrNode);
22         dependency = new Dependency(sie, mandatory);
23         this.nullableDescription = nullableDescription;
24         nullableDefault = null;
25     }
26
27     public Dependency getDependency() {
28         return dependency;
29     }
30
31     @Override
32     public String getNullableDescription() {
33         return nullableDescription;
34     }
35
36     @Override
37     public String getNullableDefault() {
38         return nullableDefault;
39     }
40
41     @Override
42     public boolean equals(Object o) {
43         if (this == o) {
44             return true;
45         }
46         if (o == null || getClass() != o.getClass()) {
47             return false;
48         }
49         if (!super.equals(o)) {
50             return false;
51         }
52
53         AbstractDependencyAttribute that = (AbstractDependencyAttribute) o;
54
55         if (dependency != null ? !dependency.equals(that.dependency)
56                 : that.dependency != null) {
57             return false;
58         }
59         if (nullableDefault != null ? !nullableDefault
60                 .equals(that.nullableDefault) : that.nullableDefault != null) {
61             return false;
62         }
63         if (nullableDescription != null ? !nullableDescription
64                 .equals(that.nullableDescription)
65                 : that.nullableDescription != null) {
66             return false;
67         }
68
69         return true;
70     }
71
72     @Override
73     public int hashCode() {
74         int result = super.hashCode();
75         result = 31 * result + (dependency != null ? dependency.hashCode() : 0);
76         result = 31
77                 * result
78                 + (nullableDescription != null ? nullableDescription.hashCode()
79                         : 0);
80         result = 31 * result
81                 + (nullableDefault != null ? nullableDefault.hashCode() : 0);
82         return result;
83     }
84
85     @Override
86     public String toString() {
87         return getClass().getName() + "{" + getAttributeYangName() + ","
88                 + "dependency=" + dependency + '}';
89     }
90
91
92 }