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 javax.management.ObjectName;
11 import javax.management.openmbean.OpenType;
12 import javax.management.openmbean.SimpleType;
14 import org.opendaylight.controller.config.yangjmxgenerator.ServiceInterfaceEntry;
15 import org.opendaylight.yangtools.binding.generator.util.Types;
16 import org.opendaylight.yangtools.sal.binding.model.api.Type;
17 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
19 public class DependencyAttribute extends AbstractAttribute implements
22 private final Dependency dependency;
23 private final String nullableDescription, nullableDefault;
25 public DependencyAttribute(DataSchemaNode attrNode,
26 ServiceInterfaceEntry sie, boolean mandatory,
27 String nullableDescription) {
29 dependency = new Dependency(sie, mandatory);
30 this.nullableDescription = nullableDescription;
31 nullableDefault = null;
35 public Type getType() {
36 return Types.typeForClass(ObjectName.class);
39 public Dependency getDependency() {
44 public String getNullableDescription() {
45 return nullableDescription;
49 public String getNullableDefault() {
50 return nullableDefault;
54 public boolean equals(Object o) {
57 if (o == null || getClass() != o.getClass())
62 DependencyAttribute that = (DependencyAttribute) o;
64 if (dependency != null ? !dependency.equals(that.dependency)
65 : that.dependency != null)
67 if (nullableDefault != null ? !nullableDefault
68 .equals(that.nullableDefault) : that.nullableDefault != null)
70 if (nullableDescription != null ? !nullableDescription
71 .equals(that.nullableDescription)
72 : that.nullableDescription != null)
79 public int hashCode() {
80 int result = super.hashCode();
81 result = 31 * result + (dependency != null ? dependency.hashCode() : 0);
84 + (nullableDescription != null ? nullableDescription.hashCode()
87 + (nullableDefault != null ? nullableDefault.hashCode() : 0);
92 public String toString() {
93 return "DependencyAttribute{" + getAttributeYangName() + ","
94 + "dependency=" + dependency + '}';
98 public OpenType<?> getOpenType() {
99 return SimpleType.OBJECTNAME;
102 public static class Dependency {
103 private final ServiceInterfaceEntry sie;
104 private final boolean mandatory;
106 public Dependency(ServiceInterfaceEntry sie, boolean mandatory) {
108 this.mandatory = mandatory;
111 public ServiceInterfaceEntry getSie() {
115 public boolean isMandatory() {
120 public boolean equals(Object o) {
123 if (o == null || getClass() != o.getClass())
126 Dependency that = (Dependency) o;
128 if (mandatory != that.mandatory)
130 if (!sie.equals(that.sie))
137 public int hashCode() {
138 int result = sie.hashCode();
139 result = 31 * result + (mandatory ? 1 : 0);