7d3b7a62f35be3fe22df1375c09ac7a1c29790b6
[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     private final boolean isDefault;
22
23     MethodSignatureImpl(final Type definingType, final String name, final List<AnnotationType> annotations,
24         final String comment, final AccessModifier accessModifier, final Type returnType,
25         final List<Parameter> params, final boolean isFinal, final boolean isAbstract, final boolean isStatic) {
26         this(definingType, name, annotations, comment, accessModifier, returnType, params, isFinal, isAbstract,
27             isStatic, false);
28     }
29
30     MethodSignatureImpl(final Type definingType, final String name, final List<AnnotationType> annotations,
31             final String comment, final AccessModifier accessModifier, final Type returnType,
32             final List<Parameter> params, final boolean isFinal, final boolean isAbstract, final boolean isStatic,
33             final boolean isDefault) {
34         super(definingType, name, annotations, comment, accessModifier, returnType, isFinal, isStatic);
35         this.params = params;
36         this.isAbstract = isAbstract;
37         this.isDefault = isDefault;
38     }
39
40     @Override
41     public boolean isAbstract() {
42         return this.isAbstract;
43     }
44
45     @Override
46     public boolean isDefault() {
47         return isDefault;
48     }
49
50     @Override
51     public List<Parameter> getParameters() {
52         return this.params;
53     }
54
55     @Override
56     public int hashCode() {
57         final int prime = 31;
58         int result = 1;
59         result = prime * result + Objects.hashCode(getName());
60         result = prime * result + Objects.hashCode(this.params);
61         result = prime * result + Objects.hashCode(getReturnType());
62         return result;
63     }
64
65     @Override
66     public boolean equals(final Object obj) {
67         if (this == obj) {
68             return true;
69         }
70         if (obj == null) {
71             return false;
72         }
73         if (getClass() != obj.getClass()) {
74             return false;
75         }
76         final MethodSignatureImpl other = (MethodSignatureImpl) obj;
77         if (!Objects.equals(getName(), other.getName())) {
78             return false;
79         }
80         if (!Objects.equals(this.params, other.params)) {
81             return false;
82         }
83         if (!Objects.equals(getReturnType(), other.getReturnType())) {
84             return false;
85         }
86         return true;
87     }
88
89     @Override
90     public String toString() {
91         final StringBuilder builder = new StringBuilder();
92         builder.append("MethodSignatureImpl [name=");
93         builder.append(getName());
94         builder.append(", comment=");
95         builder.append(getComment());
96         if (getDefiningType() != null) {
97             builder.append(", definingType=");
98             builder.append(getDefiningType().getPackageName());
99             builder.append(".");
100             builder.append(getDefiningType().getName());
101         } else {
102             builder.append(", definingType= null");
103         }
104         builder.append(", returnType=");
105         builder.append(getReturnType());
106         builder.append(", params=");
107         builder.append(this.params);
108         builder.append(", annotations=");
109         builder.append(getAnnotations());
110         builder.append("]");
111         return builder.toString();
112     }
113 }