eb1c9e41a6baf789b51a63a575e39cc9a16723ba
[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         if (o == null || getClass() != o.getClass())
46             return false;
47         if (!super.equals(o))
48             return false;
49
50         AbstractDependencyAttribute that = (AbstractDependencyAttribute) o;
51
52         if (dependency != null ? !dependency.equals(that.dependency)
53                 : that.dependency != null)
54             return false;
55         if (nullableDefault != null ? !nullableDefault
56                 .equals(that.nullableDefault) : that.nullableDefault != null)
57             return false;
58         if (nullableDescription != null ? !nullableDescription
59                 .equals(that.nullableDescription)
60                 : that.nullableDescription != null)
61             return false;
62
63         return true;
64     }
65
66     @Override
67     public int hashCode() {
68         int result = super.hashCode();
69         result = 31 * result + (dependency != null ? dependency.hashCode() : 0);
70         result = 31
71                 * result
72                 + (nullableDescription != null ? nullableDescription.hashCode()
73                         : 0);
74         result = 31 * result
75                 + (nullableDefault != null ? nullableDefault.hashCode() : 0);
76         return result;
77     }
78
79     @Override
80     public String toString() {
81         return getClass().getName() + "{" + getAttributeYangName() + ","
82                 + "dependency=" + dependency + '}';
83     }
84
85
86 }