2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
\r
4 * This program and the accompanying materials are made available under the
\r
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
\r
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
\r
8 package org.opendaylight.yangtools.binding.generator.util.generated.type.builder;
\r
11 import org.opendaylight.yangtools.sal.binding.model.api.AccessModifier;
\r
12 import org.opendaylight.yangtools.sal.binding.model.api.AnnotationType;
\r
13 import org.opendaylight.yangtools.sal.binding.model.api.Type;
\r
14 import org.opendaylight.yangtools.sal.binding.model.api.TypeMember;
\r
16 import java.util.Collections;
\r
17 import java.util.List;
\r
19 abstract class AbstractTypeMember implements TypeMember {
\r
21 private final String name;
\r
22 private final String comment;
\r
23 private final Type definingType;
\r
24 private final Type returnType;
\r
25 private final List<AnnotationType> annotations;
\r
26 private final boolean isFinal;
\r
27 private final AccessModifier accessModifier;
\r
29 public AbstractTypeMember(final Type definingType, final String name, final List<AnnotationType> annotations,
\r
30 final String comment, final AccessModifier accessModifier, final Type returnType,
\r
33 this.definingType = definingType;
\r
35 this.annotations = Collections.unmodifiableList(annotations);
\r
36 this.comment = comment;
\r
37 this.accessModifier = accessModifier;
\r
38 this.returnType = returnType;
\r
39 this.isFinal = isFinal;
\r
43 public List<AnnotationType> getAnnotations() {
\r
48 public String getName() {
\r
53 public String getComment() {
\r
58 public Type getDefiningType() {
\r
59 return definingType;
\r
63 public AccessModifier getAccessModifier() {
\r
64 return accessModifier;
\r
68 public Type getReturnType() {
\r
73 public boolean isFinal() {
\r
78 public int hashCode() {
\r
79 final int prime = 31;
\r
81 result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
\r
82 result = prime * result
\r
83 + ((getReturnType() == null) ? 0 : getReturnType().hashCode());
\r
88 public boolean equals(Object obj) {
\r
95 if (getClass() != obj.getClass()) {
\r
98 AbstractTypeMember other = (AbstractTypeMember) obj;
\r
99 if (getName() == null) {
\r
100 if (other.getName() != null) {
\r
103 } else if (!getName().equals(other.getName())) {
\r
106 if (getReturnType() == null) {
\r
107 if (other.getReturnType() != null) {
\r
110 } else if (!getReturnType().equals(other.getReturnType())) {
\r
117 public String toString() {
\r
118 StringBuilder builder = new StringBuilder();
\r
119 builder.append("MethodSignatureImpl [name=");
\r
120 builder.append(getName());
\r
121 builder.append(", comment=");
\r
122 builder.append(getComment());
\r
123 if (getDefiningType() != null) {
\r
124 builder.append(", definingType=");
\r
125 builder.append(getDefiningType().getPackageName());
\r
126 builder.append(".");
\r
127 builder.append(getDefiningType().getName());
\r
129 builder.append(", definingType= null");
\r
131 builder.append(", returnType=");
\r
132 builder.append(getReturnType());
\r
133 builder.append(", annotations=");
\r
134 builder.append(getAnnotations());
\r
135 builder.append("]");
\r
136 return builder.toString();
\r