06dda6e12811b697fd0f144646a9ea33650002ad
[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 import java.util.Objects;
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 + Objects.hashCode(getName());
47         result = prime * result + Objects.hashCode(params);
48         result = prime * result + Objects.hashCode(getReturnType());
49         return result;
50     }
51
52     @Override
53     public boolean equals(final Object obj) {
54         if (this == obj) {
55             return true;
56         }
57         if (obj == null) {
58             return false;
59         }
60         if (getClass() != obj.getClass()) {
61             return false;
62         }
63         MethodSignatureImpl other = (MethodSignatureImpl) obj;
64         if (getName() == null) {
65             if (other.getName() != null) {
66                 return false;
67             }
68         } else if (!getName().equals(other.getName())) {
69             return false;
70         }
71         if (params == null) {
72             if (other.params != null) {
73                 return false;
74             }
75         } else if (!params.equals(other.params)) {
76             return false;
77         }
78         if (getReturnType() == null) {
79             if (other.getReturnType() != null) {
80                 return false;
81             }
82         } else if (!getReturnType().equals(other.getReturnType())) {
83             return false;
84         }
85         return true;
86     }
87
88     @Override
89     public String toString() {
90         StringBuilder builder = new StringBuilder();
91         builder.append("MethodSignatureImpl [name=");
92         builder.append(getName());
93         builder.append(", comment=");
94         builder.append(getComment());
95         if (getDefiningType() != null) {
96             builder.append(", definingType=");
97             builder.append(getDefiningType().getPackageName());
98             builder.append(".");
99             builder.append(getDefiningType().getName());
100         } else {
101             builder.append(", definingType= null");
102         }
103         builder.append(", returnType=");
104         builder.append(getReturnType());
105         builder.append(", params=");
106         builder.append(params);
107         builder.append(", annotations=");
108         builder.append(getAnnotations());
109         builder.append("]");
110         return builder.toString();
111     }
112 }