Bug 7759 - TEST - Getter of BA object fails to construct class instance
[mdsal.git] / binding / mdsal-binding-generator-util / src / main / java / org / opendaylight / mdsal / binding / model / util / generated / type / builder / AbstractTypeMember.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.List;
11 import java.util.Objects;
12 import org.opendaylight.mdsal.binding.model.api.AccessModifier;
13 import org.opendaylight.mdsal.binding.model.api.AnnotationType;
14 import org.opendaylight.mdsal.binding.model.api.Type;
15 import org.opendaylight.mdsal.binding.model.api.TypeMember;
16
17 abstract class AbstractTypeMember implements TypeMember {
18
19     private final String name;
20     private final String comment;
21     private final Type definingType;
22     private final Type returnType;
23     private final List<AnnotationType> annotations;
24     private final boolean isFinal;
25     private final boolean isStatic;
26     private final AccessModifier accessModifier;
27
28     protected AbstractTypeMember(final Type definingType, final String name,  final List<AnnotationType> annotations,
29             final String comment, final AccessModifier accessModifier, final Type returnType,
30             final boolean isFinal, final boolean isStatic) {
31         super();
32         this.definingType = definingType;
33         this.name = name;
34         this.annotations = annotations;
35         this.comment = comment;
36         this.accessModifier = accessModifier;
37         this.returnType = returnType;
38         this.isFinal = isFinal;
39         this.isStatic = isStatic;
40     }
41
42     @Override
43     public List<AnnotationType> getAnnotations() {
44         return this.annotations;
45     }
46
47     @Override
48     public String getName() {
49         return this.name;
50     }
51
52     @Override
53     public String getComment() {
54         return this.comment;
55     }
56
57     @Override
58     public Type getDefiningType() {
59         return this.definingType;
60     }
61
62     @Override
63     public AccessModifier getAccessModifier() {
64         return this.accessModifier;
65     }
66
67     @Override
68     public Type getReturnType() {
69         return this.returnType;
70     }
71
72     @Override
73     public boolean isFinal() {
74         return this.isFinal;
75     }
76
77     @Override
78     public boolean isStatic() {
79         return this.isStatic;
80     }
81
82     @Override
83     public int hashCode() {
84         final int prime = 31;
85         int result = 1;
86         result = (prime * result) + Objects.hashCode(getName());
87         result = (prime * result) + Objects.hashCode(getReturnType());
88         return result;
89     }
90
91     @Override
92     public boolean equals(final Object obj) {
93         if (this == obj) {
94             return true;
95         }
96         if (obj == null) {
97             return false;
98         }
99         if (getClass() != obj.getClass()) {
100             return false;
101         }
102         final AbstractTypeMember other = (AbstractTypeMember) obj;
103         return Objects.equals(getName(), other.getName()) && Objects.equals(getReturnType(), other.getReturnType());
104     }
105
106     @Override
107     public String toString() {
108         final StringBuilder builder = new StringBuilder();
109         builder.append("MethodSignatureImpl [name=");
110         builder.append(getName());
111         builder.append(", comment=");
112         builder.append(getComment());
113         if (getDefiningType() != null) {
114             builder.append(", definingType=");
115             builder.append(getDefiningType().getPackageName());
116             builder.append(".");
117             builder.append(getDefiningType().getName());
118         } else {
119             builder.append(", definingType= null");
120         }
121         builder.append(", returnType=");
122         builder.append(getReturnType());
123         builder.append(", annotations=");
124         builder.append(getAnnotations());
125         builder.append("]");
126         return builder.toString();
127     }
128 }