Remove parent type references
[mdsal.git] / binding / mdsal-binding-generator-util / src / main / java / org / opendaylight / mdsal / binding / model / util / generated / type / builder / ConstantImpl.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.mdsal.binding.model.util.generated.type.builder;
9
10 import java.util.Objects;
11 import org.opendaylight.mdsal.binding.model.api.Constant;
12 import org.opendaylight.mdsal.binding.model.api.Type;
13
14 final class ConstantImpl implements Constant {
15     private final Type type;
16     private final String name;
17     private final Object value;
18
19     ConstantImpl(final Type type, final String name, final Object value) {
20         this.type = type;
21         this.name = name;
22         this.value = value;
23     }
24
25     @Override
26     public Type getType() {
27         return this.type;
28     }
29
30     @Override
31     public String getName() {
32         return this.name;
33     }
34
35     @Override
36     public Object getValue() {
37         return this.value;
38     }
39
40     @Override
41     public String toFormattedString() {
42         return type + " " + name + " " + value;
43     }
44
45     @Override
46     public int hashCode() {
47         final int prime = 31;
48         int result = 1;
49         result = prime * result + Objects.hashCode(this.name);
50         result = prime * result + Objects.hashCode(this.type);
51         return result;
52     }
53
54     @Override
55     public boolean equals(final Object obj) {
56         if (this == obj) {
57             return true;
58         }
59         if (obj == null || getClass() != obj.getClass()) {
60             return false;
61         }
62         final ConstantImpl other = (ConstantImpl) obj;
63         return Objects.equals(this.name, other.name) && Objects.equals(this.type, other.type)
64                 && Objects.equals(this.value, other.value);
65     }
66
67     @Override
68     public String toString() {
69         final StringBuilder builder = new StringBuilder();
70         builder.append("Constant [type=");
71         builder.append(this.type);
72         builder.append(", name=");
73         builder.append(this.name);
74         builder.append(", value=");
75         builder.append(this.value);
76         builder.append("]");
77         return builder.toString();
78     }
79 }