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