Bug 6859: Cleanup package names for mdsal-binding-generator-util module
[mdsal.git] / binding / mdsal-binding-generator-util / src / main / java / org / opendaylight / yangtools / binding / generator / 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.yangtools.binding.generator.util.generated.type.builder;
9
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;
13
14 /**
15  * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.generated.type.builder.ConstantImpl} instead.
16  */
17 @Deprecated
18 final class ConstantImpl implements Constant {
19
20     private final Type definingType;
21     private final Type type;
22     private final String name;
23     private final Object value;
24
25     public ConstantImpl(final Type definingType, final Type type, final String name, final Object value) {
26         super();
27         this.definingType = definingType;
28         this.type = type;
29         this.name = name;
30         this.value = value;
31     }
32
33     @Override
34     public Type getDefiningType() {
35         return definingType;
36     }
37
38     @Override
39     public Type getType() {
40         return type;
41     }
42
43     @Override
44     public String getName() {
45         return name;
46     }
47
48     @Override
49     public Object getValue() {
50         return value;
51     }
52
53     @Override
54     public String toFormattedString() {
55         StringBuilder builder = new StringBuilder();
56         builder.append(type);
57         builder.append(" ");
58         builder.append(name);
59         builder.append(" ");
60         builder.append(value);
61         return builder.toString();
62     }
63
64     /*
65      * (non-Javadoc)
66      *
67      * @see java.lang.Object#hashCode()
68      */
69     @Override
70     public int hashCode() {
71         final int prime = 31;
72         int result = 1;
73         result = prime * result + Objects.hashCode(name);
74         result = prime * result + Objects.hashCode(type);
75         return result;
76     }
77
78     /*
79      * (non-Javadoc)
80      *
81      * @see java.lang.Object#equals(java.lang.Object)
82      */
83     @Override
84     public boolean equals(final Object obj) {
85         if (this == obj) {
86             return true;
87         }
88         if (obj == null) {
89             return false;
90         }
91         if (getClass() != obj.getClass()) {
92             return false;
93         }
94         ConstantImpl other = (ConstantImpl) obj;
95         return Objects.equals(name, other.name) && Objects.equals(type, other.type) && Objects.equals(value, other.value);
96     }
97
98     @Override
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());
110             builder.append(".");
111             builder.append(definingType.getName());
112         } else {
113             builder.append(", definingType= null");
114         }
115         builder.append("]");
116         return builder.toString();
117     }
118 }