2 * Copyright (c) 2016 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
9 package org.opendaylight.mdsal.binding2.generator.util.generated.type.builder;
11 import com.google.common.annotations.Beta;
12 import java.util.Objects;
13 import org.opendaylight.mdsal.binding2.model.api.Constant;
14 import org.opendaylight.mdsal.binding2.model.api.Type;
17 final class ConstantImpl implements Constant {
19 private final Type definingType;
20 private final Type type;
21 private final String name;
22 private final Object value;
24 public ConstantImpl(final Type definingType, final Type type, final String name, final Object value) {
26 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();
65 public int hashCode() {
66 return Objects.hash(name, type);
70 public boolean equals(final Object obj) {
77 if (getClass() != obj.getClass()) {
81 if (!(obj instanceof ConstantImpl)) {
85 ConstantImpl other = (ConstantImpl) obj;
86 return Objects.equals(name, other.name) && Objects.equals(type, other.type) && Objects.equals(value, other.value);
90 public String toString() {
91 StringBuilder builder = new StringBuilder();
92 builder.append("Constant [type=");
94 builder.append(", name=");
96 builder.append(", value=");
97 builder.append(value);
98 if (definingType != null) {
99 builder.append(", definingType=");
100 builder.append(definingType.getPackageName());
102 builder.append(definingType.getName());
104 builder.append(", definingType= null");
107 return builder.toString();