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.yangtools.binding.generator.util.generated.type.builder;
10 import java.util.Objects;
11 import org.opendaylight.yangtools.sal.binding.model.api.Constant;
12 import org.opendaylight.yangtools.sal.binding.model.api.Type;
15 * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.generated.type.builder.ConstantImpl} instead.
18 final class ConstantImpl implements Constant {
20 private final Type definingType;
21 private final Type type;
22 private final String name;
23 private final Object value;
25 public ConstantImpl(final Type definingType, final Type type, final String name, final Object value) {
27 this.definingType = definingType;
34 public Type getDefiningType() {
39 public Type getType() {
44 public String getName() {
49 public Object getValue() {
54 public String toFormattedString() {
55 StringBuilder builder = new StringBuilder();
60 builder.append(value);
61 return builder.toString();
67 * @see java.lang.Object#hashCode()
70 public int hashCode() {
73 result = prime * result + Objects.hashCode(name);
74 result = prime * result + Objects.hashCode(type);
81 * @see java.lang.Object#equals(java.lang.Object)
84 public boolean equals(final Object obj) {
91 if (getClass() != obj.getClass()) {
94 ConstantImpl other = (ConstantImpl) obj;
95 return Objects.equals(name, other.name) && Objects.equals(type, other.type) && Objects.equals(value, other.value);
99 public String toString() {
100 StringBuilder builder = new StringBuilder();
101 builder.append("Constant [type=");
102 builder.append(type);
103 builder.append(", name=");
104 builder.append(name);
105 builder.append(", value=");
106 builder.append(value);
107 if (definingType != null) {
108 builder.append(", definingType=");
109 builder.append(definingType.getPackageName());
111 builder.append(definingType.getName());
113 builder.append(", definingType= null");
116 return builder.toString();