2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.mdsal.binding.model.util.generated.type.builder;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.annotations.VisibleForTesting;
13 import java.util.List;
14 import java.util.Objects;
15 import org.opendaylight.mdsal.binding.model.api.AccessModifier;
16 import org.opendaylight.mdsal.binding.model.api.AnnotationType;
17 import org.opendaylight.mdsal.binding.model.api.MethodSignature;
18 import org.opendaylight.mdsal.binding.model.api.Type;
20 class MethodSignatureImpl extends AbstractTypeMember implements MethodSignature {
21 private final List<Parameter> params;
22 private final ValueMechanics mechanics;
23 private final boolean isAbstract;
24 private final boolean isDefault;
27 MethodSignatureImpl(final Type definingType, final String name, final List<AnnotationType> annotations,
28 final String comment, final AccessModifier accessModifier, final Type returnType,
29 final List<Parameter> params, final boolean isFinal, final boolean isAbstract, final boolean isStatic) {
30 this(definingType, name, annotations, comment, accessModifier, returnType, params, isFinal, isAbstract,
31 isStatic, false, ValueMechanics.NORMAL);
34 MethodSignatureImpl(final Type definingType, final String name, final List<AnnotationType> annotations,
35 final String comment, final AccessModifier accessModifier, final Type returnType,
36 final List<Parameter> params, final boolean isFinal, final boolean isAbstract, final boolean isStatic,
37 final boolean isDefault, final ValueMechanics mechanics) {
38 super(definingType, name, annotations, comment, accessModifier, returnType, isFinal, isStatic);
40 this.isAbstract = isAbstract;
41 this.isDefault = isDefault;
42 this.mechanics = requireNonNull(mechanics);
46 public boolean isAbstract() {
47 return this.isAbstract;
51 public boolean isDefault() {
56 public List<Parameter> getParameters() {
61 public ValueMechanics getMechanics() {
66 public int hashCode() {
69 result = prime * result + Objects.hashCode(getName());
70 result = prime * result + Objects.hashCode(this.params);
71 result = prime * result + Objects.hashCode(getReturnType());
76 public boolean equals(final Object obj) {
80 if (obj == null || getClass() != obj.getClass()) {
83 final MethodSignatureImpl other = (MethodSignatureImpl) obj;
84 return Objects.equals(getName(), other.getName())
85 && Objects.equals(this.params, other.params)
86 && Objects.equals(getReturnType(), other.getReturnType());
90 public String toString() {
91 final StringBuilder builder = new StringBuilder().append("MethodSignatureImpl [name=").append(getName())
92 .append(", comment=").append(getComment())
93 .append(", definingType=");
95 final Type defType = getDefiningType();
96 if (defType != null) {
97 builder.append(defType.getPackageName()).append('.').append(defType.getName());
99 builder.append(" null");
102 return builder.append(", returnType=").append(getReturnType())
103 .append(", params=").append(this.params)
104 .append(", annotations=").append(getAnnotations())
105 .append(']').toString();