Remove parent type references
[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 static java.util.Objects.requireNonNull;
11
12 import com.google.common.annotations.VisibleForTesting;
13 import java.util.List;
14 import java.util.Objects;
15 import org.eclipse.jdt.annotation.NonNull;
16 import org.opendaylight.mdsal.binding.model.api.AccessModifier;
17 import org.opendaylight.mdsal.binding.model.api.AnnotationType;
18 import org.opendaylight.mdsal.binding.model.api.MethodSignature;
19 import org.opendaylight.mdsal.binding.model.api.Type;
20 import org.opendaylight.mdsal.binding.model.api.TypeMemberComment;
21
22 class MethodSignatureImpl extends AbstractTypeMember implements MethodSignature {
23     private final List<Parameter> params;
24     private final @NonNull ValueMechanics mechanics;
25     private final boolean isAbstract;
26     private final boolean isDefault;
27
28     @VisibleForTesting
29     MethodSignatureImpl(final String name, final List<AnnotationType> annotations,
30             final TypeMemberComment comment, final AccessModifier accessModifier, final Type returnType,
31             final List<Parameter> params, final boolean isFinal, final boolean isAbstract, final boolean isStatic) {
32         this(name, annotations, comment, accessModifier, returnType, params, isFinal, isAbstract, isStatic, false,
33             ValueMechanics.NORMAL);
34     }
35
36     MethodSignatureImpl(final String name, final List<AnnotationType> annotations,
37             final TypeMemberComment comment, final AccessModifier accessModifier, final Type returnType,
38             final List<Parameter> params, final boolean isFinal, final boolean isAbstract, final boolean isStatic,
39             final boolean isDefault, final ValueMechanics mechanics) {
40         super(name, annotations, comment, accessModifier, returnType, isFinal, isStatic);
41         this.params = params;
42         this.isAbstract = isAbstract;
43         this.isDefault = isDefault;
44         this.mechanics = requireNonNull(mechanics);
45     }
46
47     @Override
48     public boolean isAbstract() {
49         return this.isAbstract;
50     }
51
52     @Override
53     public boolean isDefault() {
54         return isDefault;
55     }
56
57     @Override
58     public List<Parameter> getParameters() {
59         return this.params;
60     }
61
62     @Override
63     public ValueMechanics getMechanics() {
64         return mechanics;
65     }
66
67     @Override
68     public int hashCode() {
69         final int prime = 31;
70         int result = 1;
71         result = prime * result + Objects.hashCode(getName());
72         result = prime * result + Objects.hashCode(this.params);
73         result = prime * result + Objects.hashCode(getReturnType());
74         return result;
75     }
76
77     @Override
78     public boolean equals(final Object obj) {
79         if (this == obj) {
80             return true;
81         }
82         if (obj == null || getClass() != obj.getClass()) {
83             return false;
84         }
85         final MethodSignatureImpl other = (MethodSignatureImpl) obj;
86         return Objects.equals(getName(), other.getName())
87                 && Objects.equals(this.params, other.params)
88                 && Objects.equals(getReturnType(), other.getReturnType());
89     }
90
91     @Override
92     public String toString() {
93         return new StringBuilder()
94             .append("MethodSignatureImpl [name=").append(getName())
95             .append(", comment=").append(getComment())
96             .append(", returnType=").append(getReturnType())
97             .append(", params=").append(this.params)
98             .append(", annotations=").append(getAnnotations())
99             .append(']')
100             .toString();
101     }
102 }