Bug 6859: Binding generator v1 refactoring
[mdsal.git] / binding / mdsal-binding-generator-util / src / main / java / org / opendaylight / mdsal / binding / model / 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.binding.model.util.generated.type.builder;
9
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.MethodSignature;
15 import org.opendaylight.mdsal.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 this.isAbstract;
35     }
36
37     @Override
38     public List<Parameter> getParameters() {
39         return this.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(this.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         final MethodSignatureImpl other = (MethodSignatureImpl) obj;
64         if (!Objects.equals(getName(), other.getName())) {
65             return false;
66         }
67         if (!Objects.equals(this.params, other.params)) {
68             return false;
69         }
70         if (!Objects.equals(getReturnType(), other.getReturnType())) {
71             return false;
72         }
73         return true;
74     }
75
76     @Override
77     public String toString() {
78         final StringBuilder builder = new StringBuilder();
79         builder.append("MethodSignatureImpl [name=");
80         builder.append(getName());
81         builder.append(", comment=");
82         builder.append(getComment());
83         if (getDefiningType() != null) {
84             builder.append(", definingType=");
85             builder.append(getDefiningType().getPackageName());
86             builder.append(".");
87             builder.append(getDefiningType().getName());
88         } else {
89             builder.append(", definingType= null");
90         }
91         builder.append(", returnType=");
92         builder.append(getReturnType());
93         builder.append(", params=");
94         builder.append(this.params);
95         builder.append(", annotations=");
96         builder.append(getAnnotations());
97         builder.append("]");
98         return builder.toString();
99     }
100 }