2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.config.yangjmxgenerator.attribute;
10 import org.opendaylight.controller.config.yangjmxgenerator.ServiceInterfaceEntry;
11 import org.opendaylight.yangtools.binding.generator.util.Types;
12 import org.opendaylight.yangtools.sal.binding.model.api.Type;
13 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
15 import javax.management.ObjectName;
16 import javax.management.openmbean.SimpleType;
18 public class DependencyAttribute extends AbstractAttribute implements
21 private final Dependency dependency;
22 private final String nullableDescription, nullableDefault;
24 public DependencyAttribute(DataSchemaNode attrNode,
25 ServiceInterfaceEntry sie, boolean mandatory,
26 String nullableDescription) {
28 dependency = new Dependency(sie, mandatory);
29 this.nullableDescription = nullableDescription;
30 nullableDefault = null;
34 public Type getType() {
35 return Types.typeForClass(ObjectName.class);
38 public Dependency getDependency() {
43 public String getNullableDescription() {
44 return nullableDescription;
48 public String getNullableDefault() {
49 return nullableDefault;
53 public boolean equals(Object o) {
56 if (o == null || getClass() != o.getClass())
61 DependencyAttribute that = (DependencyAttribute) o;
63 if (dependency != null ? !dependency.equals(that.dependency)
64 : that.dependency != null)
66 if (nullableDefault != null ? !nullableDefault
67 .equals(that.nullableDefault) : that.nullableDefault != null)
69 if (nullableDescription != null ? !nullableDescription
70 .equals(that.nullableDescription)
71 : that.nullableDescription != null)
78 public int hashCode() {
79 int result = super.hashCode();
80 result = 31 * result + (dependency != null ? dependency.hashCode() : 0);
83 + (nullableDescription != null ? nullableDescription.hashCode()
86 + (nullableDefault != null ? nullableDefault.hashCode() : 0);
91 public String toString() {
92 return "DependencyAttribute{" + getAttributeYangName() + ","
93 + "dependency=" + dependency + '}';
97 public SimpleType<?> getOpenType() {
98 return SimpleType.OBJECTNAME;
101 public static class Dependency {
102 private final ServiceInterfaceEntry sie;
103 private final boolean mandatory;
105 public Dependency(ServiceInterfaceEntry sie, boolean mandatory) {
107 this.mandatory = mandatory;
110 public ServiceInterfaceEntry getSie() {
114 public boolean isMandatory() {
119 public boolean equals(Object o) {
122 if (o == null || getClass() != o.getClass())
125 Dependency that = (Dependency) o;
127 if (mandatory != that.mandatory)
129 if (!sie.equals(that.sie))
136 public int hashCode() {
137 int result = sie.hashCode();
138 result = 31 * result + (mandatory ? 1 : 0);