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