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.binding.generator.util.generated.type.builder;
10 import org.opendaylight.controller.sal.binding.model.api.Constant;
11 import org.opendaylight.controller.sal.binding.model.api.Type;
13 final class ConstantImpl implements Constant {
15 final Type definingType;
16 private final Type type;
17 private final String name;
18 private final Object value;
20 public ConstantImpl(final Type definingType, final Type type,
21 final String name, final Object value) {
23 this.definingType = definingType;
30 public Type getDefiningType() {
35 public Type getType() {
40 public String getName() {
45 public Object getValue() {
50 public String toFormattedString() {
51 StringBuilder builder = new StringBuilder();
56 builder.append(value);
57 return builder.toString();
63 * @see java.lang.Object#hashCode()
66 public int hashCode() {
69 result = prime * result + ((name == null) ? 0 : name.hashCode());
70 result = prime * result + ((type == null) ? 0 : type.hashCode());
77 * @see java.lang.Object#equals(java.lang.Object)
80 public boolean equals(Object obj) {
87 if (getClass() != obj.getClass()) {
90 ConstantImpl other = (ConstantImpl) obj;
92 if (other.name != null) {
95 } else if (!name.equals(other.name)) {
99 if (other.type != null) {
102 } else if (!type.equals(other.type)) {
106 if (other.value != null) {
109 } else if (!value.equals(other.value)) {
116 public String toString() {
117 StringBuilder builder = new StringBuilder();
118 builder.append("Constant [type=");
119 builder.append(type);
120 builder.append(", name=");
121 builder.append(name);
122 builder.append(", value=");
123 builder.append(value);
124 if (definingType != null) {
125 builder.append(", definingType=");
126 builder.append(definingType.getPackageName());
128 builder.append(definingType.getName());
130 builder.append(", definingType= null");
133 return builder.toString();