Remove parent type references
[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 import org.opendaylight.mdsal.binding.model.api.TypeMemberComment;
17
18 abstract class AbstractTypeMember implements TypeMember {
19
20     private final String name;
21     private final TypeMemberComment comment;
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 String name,  final List<AnnotationType> annotations,
29             final TypeMemberComment comment, final AccessModifier accessModifier, final Type returnType,
30             final boolean isFinal, final boolean isStatic) {
31         this.name = name;
32         this.annotations = annotations;
33         this.comment = comment;
34         this.accessModifier = accessModifier;
35         this.returnType = returnType;
36         this.isFinal = isFinal;
37         this.isStatic = isStatic;
38     }
39
40     @Override
41     public List<AnnotationType> getAnnotations() {
42         return this.annotations;
43     }
44
45     @Override
46     public String getName() {
47         return this.name;
48     }
49
50     @Override
51     public TypeMemberComment getComment() {
52         return comment;
53     }
54
55     @Override
56     public AccessModifier getAccessModifier() {
57         return this.accessModifier;
58     }
59
60     @Override
61     public Type getReturnType() {
62         return this.returnType;
63     }
64
65     @Override
66     public boolean isFinal() {
67         return this.isFinal;
68     }
69
70     @Override
71     public boolean isStatic() {
72         return this.isStatic;
73     }
74
75     @Override
76     public int hashCode() {
77         return Objects.hash(getName(), getReturnType());
78     }
79
80     @Override
81     public boolean equals(final Object obj) {
82         if (this == obj) {
83             return true;
84         }
85         if (obj == null || getClass() != obj.getClass()) {
86             return false;
87         }
88         final AbstractTypeMember other = (AbstractTypeMember) obj;
89         return Objects.equals(getName(), other.getName()) && Objects.equals(getReturnType(), other.getReturnType());
90     }
91
92     @Override
93     public String toString() {
94         return new StringBuilder()
95             .append("AbstractTypeMember [name=").append(getName())
96             .append(", comment=").append(getComment())
97             .append(", returnType=").append(getReturnType())
98             .append(", annotations=").append(getAnnotations())
99             .append(']')
100             .toString();
101     }
102 }