2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.binding.generator.util.generated.type.builder;
10 import java.util.List;
11 import java.util.Objects;
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;
17 abstract class AbstractTypeMember implements TypeMember {
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;
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) {
32 this.definingType = definingType;
34 this.annotations = annotations;
35 this.comment = comment;
36 this.accessModifier = accessModifier;
37 this.returnType = returnType;
38 this.isFinal = isFinal;
39 this.isStatic = isStatic;
43 public List<AnnotationType> getAnnotations() {
48 public String getName() {
53 public String getComment() {
58 public Type getDefiningType() {
63 public AccessModifier getAccessModifier() {
64 return accessModifier;
68 public Type getReturnType() {
73 public boolean isFinal() {
78 public boolean isStatic() {
83 public int hashCode() {
86 result = prime * result + Objects.hashCode(getName());
87 result = prime * result + Objects.hashCode(getReturnType());
92 public boolean equals(final Object obj) {
99 if (getClass() != obj.getClass()) {
102 AbstractTypeMember other = (AbstractTypeMember) obj;
103 if (getName() == null) {
104 if (other.getName() != null) {
107 } else if (!getName().equals(other.getName())) {
110 if (getReturnType() == null) {
111 if (other.getReturnType() != null) {
114 } else if (!getReturnType().equals(other.getReturnType())) {
121 public String toString() {
122 StringBuilder builder = new StringBuilder();
123 builder.append("MethodSignatureImpl [name=");
124 builder.append(getName());
125 builder.append(", comment=");
126 builder.append(getComment());
127 if (getDefiningType() != null) {
128 builder.append(", definingType=");
129 builder.append(getDefiningType().getPackageName());
131 builder.append(getDefiningType().getName());
133 builder.append(", definingType= null");
135 builder.append(", returnType=");
136 builder.append(getReturnType());
137 builder.append(", annotations=");
138 builder.append(getAnnotations());
140 return builder.toString();