Bug 1411-3: MDSAL Binding2 Generator Util
[mdsal.git] / binding2 / mdsal-binding2-generator-util / src / main / java / org / opendaylight / mdsal / binding2 / 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.mdsal.binding2.generator.util.generated.type.builder;
9
10 import com.google.common.annotations.Beta;
11 import java.util.List;
12 import java.util.Objects;
13 import org.opendaylight.mdsal.binding2.model.api.AccessModifier;
14 import org.opendaylight.mdsal.binding2.model.api.AnnotationType;
15 import org.opendaylight.mdsal.binding2.model.api.MethodSignature;
16 import org.opendaylight.mdsal.binding2.model.api.Type;
17
18 @Beta
19 class MethodSignatureImpl extends AbstractTypeMember implements MethodSignature {
20
21     private final List<Parameter> params;
22     private final boolean isAbstract;
23
24     public MethodSignatureImpl(final Type definingType, final String name,
25             final List<AnnotationType> annotations,
26             final String comment, final AccessModifier accessModifier,
27             final Type returnType, final List<Parameter> params, final boolean isFinal,
28             final boolean isAbstract, final boolean isStatic) {
29         super(definingType, name, annotations, comment, accessModifier, returnType, isFinal, isStatic);
30         this.params = params;
31         this.isAbstract = isAbstract;
32     }
33
34     @Override
35     public boolean isAbstract() {
36         return isAbstract;
37     }
38
39     @Override
40     public List<Parameter> getParameters() {
41         return params;
42     }
43
44     @Override
45     public int hashCode() {
46         return Objects.hash(getName(), params, getReturnType());
47     }
48
49     @Override
50     public boolean equals(final Object obj) {
51         if (this == obj) {
52             return true;
53         }
54         if (obj == null) {
55             return false;
56         }
57         if (getClass() != obj.getClass()) {
58             return false;
59         }
60         MethodSignatureImpl other = (MethodSignatureImpl) obj;
61         if (!Objects.equals(getName(), other.getName())) {
62             return false;
63         }
64         if (!Objects.equals(params, other.params)) {
65             return false;
66         }
67         if (!Objects.equals(getReturnType(), other.getReturnType())) {
68             return false;
69         }
70         return true;
71     }
72
73     @Override
74     public String toString() {
75         StringBuilder builder = new StringBuilder();
76         builder.append("MethodSignatureImpl [name=");
77         builder.append(getName());
78         builder.append(", comment=");
79         builder.append(getComment());
80         if (getDefiningType() != null) {
81             builder.append(", definingType=");
82             builder.append(getDefiningType().getPackageName());
83             builder.append(".");
84             builder.append(getDefiningType().getName());
85         } else {
86             builder.append(", definingType= null");
87         }
88         builder.append(", returnType=");
89         builder.append(getReturnType());
90         builder.append(", params=");
91         builder.append(params);
92         builder.append(", annotations=");
93         builder.append(getAnnotations());
94         builder.append("]");
95         return builder.toString();
96     }
97 }