cf0f7ea1d807ba2d89bb00be2c246361b603b186
[mdsal.git] / binding / mdsal-binding-generator-util / src / main / java / org / opendaylight / yangtools / binding / generator / util / generated / type / builder / MethodSignatureImpl.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.binding.generator.util.generated.type.builder;
9
10 import java.util.List;
11
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.MethodSignature;
15 import org.opendaylight.yangtools.sal.binding.model.api.Type;
16
17 class MethodSignatureImpl extends AbstractTypeMember implements MethodSignature {
18
19     private final List<Parameter> params;
20     private final boolean isAbstract;
21
22     public MethodSignatureImpl(final Type definingType, final String name,
23             final List<AnnotationType> annotations,
24             final String comment, final AccessModifier accessModifier,
25             final Type returnType, final List<Parameter> params, final boolean isFinal,
26             final boolean isAbstract, final boolean isStatic) {
27         super(definingType, name, annotations, comment, accessModifier, returnType, isFinal, isStatic);
28         this.params = params;
29         this.isAbstract = isAbstract;
30     }
31
32     @Override
33     public boolean isAbstract() {
34         return isAbstract;
35     }
36
37     @Override
38     public List<Parameter> getParameters() {
39         return params;
40     }
41
42     @Override
43     public int hashCode() {
44         final int prime = 31;
45         int result = 1;
46         result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
47         result = prime * result
48                 + ((params == null) ? 0 : params.hashCode());
49         result = prime * result
50                 + ((getReturnType() == null) ? 0 : getReturnType().hashCode());
51         return result;
52     }
53
54     @Override
55     public boolean equals(final Object obj) {
56         if (this == obj) {
57             return true;
58         }
59         if (obj == null) {
60             return false;
61         }
62         if (getClass() != obj.getClass()) {
63             return false;
64         }
65         MethodSignatureImpl other = (MethodSignatureImpl) obj;
66         if (getName() == null) {
67             if (other.getName() != null) {
68                 return false;
69             }
70         } else if (!getName().equals(other.getName())) {
71             return false;
72         }
73         if (params == null) {
74             if (other.params != null) {
75                 return false;
76             }
77         } else if (!params.equals(other.params)) {
78             return false;
79         }
80         if (getReturnType() == null) {
81             if (other.getReturnType() != null) {
82                 return false;
83             }
84         } else if (!getReturnType().equals(other.getReturnType())) {
85             return false;
86         }
87         return true;
88     }
89
90     @Override
91     public String toString() {
92         StringBuilder builder = new StringBuilder();
93         builder.append("MethodSignatureImpl [name=");
94         builder.append(getName());
95         builder.append(", comment=");
96         builder.append(getComment());
97         if (getDefiningType() != null) {
98             builder.append(", definingType=");
99             builder.append(getDefiningType().getPackageName());
100             builder.append(".");
101             builder.append(getDefiningType().getName());
102         } else {
103             builder.append(", definingType= null");
104         }
105         builder.append(", returnType=");
106         builder.append(getReturnType());
107         builder.append(", params=");
108         builder.append(params);
109         builder.append(", annotations=");
110         builder.append(getAnnotations());
111         builder.append("]");
112         return builder.toString();
113     }
114 }