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.mdsal.binding.model.util.generated.type.builder;
10 import java.util.Objects;
11 import org.opendaylight.mdsal.binding.model.api.Constant;
12 import org.opendaylight.mdsal.binding.model.api.Type;
14 final class ConstantImpl implements Constant {
16 private final Type definingType;
17 private final Type type;
18 private final String name;
19 private final Object value;
21 public ConstantImpl(final Type definingType, final Type type, final String name, final Object value) {
23 this.definingType = definingType;
30 public Type getDefiningType() {
31 return this.definingType;
35 public Type getType() {
40 public String getName() {
45 public Object getValue() {
50 public String toFormattedString() {
51 final StringBuilder builder = new StringBuilder();
52 builder.append(this.type);
54 builder.append(this.name);
56 builder.append(this.value);
57 return builder.toString();
63 * @see java.lang.Object#hashCode()
66 public int hashCode() {
69 result = (prime * result) + Objects.hashCode(this.name);
70 result = (prime * result) + Objects.hashCode(this.type);
77 * @see java.lang.Object#equals(java.lang.Object)
80 public boolean equals(final Object obj) {
87 if (getClass() != obj.getClass()) {
90 final ConstantImpl other = (ConstantImpl) obj;
91 return Objects.equals(this.name, other.name) && Objects.equals(this.type, other.type) && Objects.equals(this.value, other.value);
95 public String toString() {
96 final StringBuilder builder = new StringBuilder();
97 builder.append("Constant [type=");
98 builder.append(this.type);
99 builder.append(", name=");
100 builder.append(this.name);
101 builder.append(", value=");
102 builder.append(this.value);
103 if (this.definingType != null) {
104 builder.append(", definingType=");
105 builder.append(this.definingType.getPackageName());
107 builder.append(this.definingType.getName());
109 builder.append(", definingType= null");
112 return builder.toString();