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.binding.model.util.generated.type.builder;
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;
18 abstract class AbstractTypeMember implements TypeMember {
20 private final String name;
21 private final TypeMemberComment comment;
22 private final Type definingType;
23 private final Type returnType;
24 private final List<AnnotationType> annotations;
25 private final boolean isFinal;
26 private final boolean isStatic;
27 private final AccessModifier accessModifier;
29 protected AbstractTypeMember(final Type definingType, final String name, final List<AnnotationType> annotations,
30 final TypeMemberComment comment, final AccessModifier accessModifier, final Type returnType,
31 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() {
44 return this.annotations;
48 public String getName() {
53 public TypeMemberComment getComment() {
58 public Type getDefiningType() {
59 return this.definingType;
63 public AccessModifier getAccessModifier() {
64 return this.accessModifier;
68 public Type getReturnType() {
69 return this.returnType;
73 public boolean isFinal() {
78 public boolean isStatic() {
83 public int hashCode() {
84 return Objects.hash(getName(), getReturnType());
88 public boolean equals(final Object obj) {
92 if (obj == null || getClass() != obj.getClass()) {
95 final AbstractTypeMember other = (AbstractTypeMember) obj;
96 return Objects.equals(getName(), other.getName()) && Objects.equals(getReturnType(), other.getReturnType());
100 public String toString() {
101 final StringBuilder builder = new StringBuilder()
102 .append("AbstractTypeMember [name=").append(getName())
103 .append(", comment=").append(getComment())
104 .append(", definingType=");
105 if (getDefiningType() != null) {
106 builder.append(getDefiningType().getPackageName()).append('.').append(getDefiningType().getName());
108 builder.append(" null");
110 return builder.append(", returnType=").append(getReturnType())
111 .append(", annotations=").append(getAnnotations())
112 .append(']').toString();