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.mdsal.binding2.generator.util.generated.type.builder;
10 import com.google.common.annotations.Beta;
11 import java.util.List;
12 import java.util.Objects;
13 import org.opendaylight.mdsal.binding2.model.api.AccessModifier;
14 import org.opendaylight.mdsal.binding2.model.api.AnnotationType;
15 import org.opendaylight.mdsal.binding2.model.api.Type;
16 import org.opendaylight.mdsal.binding2.model.api.TypeMember;
19 abstract class AbstractTypeMember implements TypeMember {
21 private final String name;
22 private final String comment;
23 private final Type definingType;
24 private final Type returnType;
25 private final List<AnnotationType> annotations;
26 private final boolean isFinal;
27 private final boolean isStatic;
28 private final AccessModifier accessModifier;
30 protected AbstractTypeMember(final Type definingType, final String name, final List<AnnotationType> annotations,
31 final String comment, final AccessModifier accessModifier, final Type returnType,
32 final boolean isFinal, final boolean isStatic) {
34 this.definingType = definingType;
36 this.annotations = annotations;
37 this.comment = comment;
38 this.accessModifier = accessModifier;
39 this.returnType = returnType;
40 this.isFinal = isFinal;
41 this.isStatic = isStatic;
45 public List<AnnotationType> getAnnotations() {
50 public String getName() {
55 public String getComment() {
60 public Type getDefiningType() {
65 public AccessModifier getAccessModifier() {
66 return accessModifier;
70 public Type getReturnType() {
75 public boolean isFinal() {
80 public boolean isStatic() {
85 public int hashCode() {
86 return Objects.hash(name, returnType);
90 public boolean equals(final Object obj) {
97 if (getClass() != obj.getClass()) {
101 if (!(obj instanceof AbstractTypeMember)) {
105 AbstractTypeMember other = (AbstractTypeMember) obj;
106 return Objects.equals(getName(), other.getName()) && Objects.equals(getReturnType(), other.getReturnType());
110 public String toString() {
111 StringBuilder builder = new StringBuilder();
112 builder.append("MethodSignatureImpl [name=");
113 builder.append(getName());
114 builder.append(", comment=");
115 builder.append(getComment());
116 if (getDefiningType() != null) {
117 builder.append(", definingType=");
118 builder.append(getDefiningType().getPackageName());
120 builder.append(getDefiningType().getName());
122 builder.append(", definingType= null");
124 builder.append(", returnType=");
125 builder.append(getReturnType());
126 builder.append(", annotations=");
127 builder.append(getAnnotations());
129 return builder.toString();