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;
11 import java.util.Collections;
12 import java.util.List;
14 import org.opendaylight.yangtools.sal.binding.model.api.AccessModifier;
15 import org.opendaylight.yangtools.sal.binding.model.api.AnnotationType;
16 import org.opendaylight.yangtools.sal.binding.model.api.Type;
17 import org.opendaylight.yangtools.sal.binding.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 public AbstractTypeMember(final Type definingType, final String name, final List<AnnotationType> annotations,
31 final String comment, final AccessModifier accessModifier, final Type returnType,
32 boolean isFinal, boolean isStatic) {
34 this.definingType = definingType;
36 this.annotations = Collections.unmodifiableList(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() {
88 result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
89 result = prime * result
90 + ((getReturnType() == null) ? 0 : getReturnType().hashCode());
95 public boolean equals(Object obj) {
102 if (getClass() != obj.getClass()) {
105 AbstractTypeMember other = (AbstractTypeMember) obj;
106 if (getName() == null) {
107 if (other.getName() != null) {
110 } else if (!getName().equals(other.getName())) {
113 if (getReturnType() == null) {
114 if (other.getReturnType() != null) {
117 } else if (!getReturnType().equals(other.getReturnType())) {
124 public String toString() {
125 StringBuilder builder = new StringBuilder();
126 builder.append("MethodSignatureImpl [name=");
127 builder.append(getName());
128 builder.append(", comment=");
129 builder.append(getComment());
130 if (getDefiningType() != null) {
131 builder.append(", definingType=");
132 builder.append(getDefiningType().getPackageName());
134 builder.append(getDefiningType().getName());
136 builder.append(", definingType= null");
138 builder.append(", returnType=");
139 builder.append(getReturnType());
140 builder.append(", annotations=");
141 builder.append(getAnnotations());
143 return builder.toString();