Introduce top-level pom file.
[mdsal.git] / code-generator / binding-generator-util / src / main / java / org / opendaylight / yangtools / binding / generator / 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.yangtools.binding.generator.util.generated.type.builder;
9
10 import java.util.List;
11
12 import org.opendaylight.yangtools.sal.binding.model.api.AccessModifier;
13 import org.opendaylight.yangtools.sal.binding.model.api.AnnotationType;
14 import org.opendaylight.yangtools.sal.binding.model.api.Type;
15 import org.opendaylight.yangtools.sal.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 annotations;
45     }
46
47     @Override
48     public String getName() {
49         return name;
50     }
51
52     @Override
53     public String getComment() {
54         return comment;
55     }
56
57     @Override
58     public Type getDefiningType() {
59         return definingType;
60     }
61
62     @Override
63     public AccessModifier getAccessModifier() {
64         return accessModifier;
65     }
66
67     @Override
68     public Type getReturnType() {
69         return returnType;
70     }
71
72     @Override
73     public boolean isFinal() {
74         return isFinal;
75     }
76
77     @Override
78     public boolean isStatic() {
79         return isStatic;
80     }
81
82     @Override
83     public int hashCode() {
84         final int prime = 31;
85         int result = 1;
86         result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
87         result = prime * result
88                 + ((getReturnType() == null) ? 0 : getReturnType().hashCode());
89         return result;
90     }
91
92     @Override
93     public boolean equals(final Object obj) {
94         if (this == obj) {
95             return true;
96         }
97         if (obj == null) {
98             return false;
99         }
100         if (getClass() != obj.getClass()) {
101             return false;
102         }
103         AbstractTypeMember other = (AbstractTypeMember) obj;
104         if (getName() == null) {
105             if (other.getName() != null) {
106                 return false;
107             }
108         } else if (!getName().equals(other.getName())) {
109             return false;
110         }
111         if (getReturnType() == null) {
112             if (other.getReturnType() != null) {
113                 return false;
114             }
115         } else if (!getReturnType().equals(other.getReturnType())) {
116             return false;
117         }
118         return true;
119     }
120
121     @Override
122     public String toString() {
123         StringBuilder builder = new StringBuilder();
124         builder.append("MethodSignatureImpl [name=");
125         builder.append(getName());
126         builder.append(", comment=");
127         builder.append(getComment());
128         if (getDefiningType() != null) {
129             builder.append(", definingType=");
130             builder.append(getDefiningType().getPackageName());
131             builder.append(".");
132             builder.append(getDefiningType().getName());
133         } else {
134             builder.append(", definingType= null");
135         }
136         builder.append(", returnType=");
137         builder.append(getReturnType());
138         builder.append(", annotations=");
139         builder.append(getAnnotations());
140         builder.append("]");
141         return builder.toString();
142     }
143 }