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.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;
21 class MethodSignatureImpl extends AbstractTypeMember implements MethodSignature {
22 private final List<Parameter> params;
23 private final @NonNull ValueMechanics mechanics;
24 private final boolean isAbstract;
25 private final boolean isDefault;
28 MethodSignatureImpl(final Type definingType, final String name, final List<AnnotationType> annotations,
29 final String comment, final AccessModifier accessModifier, final Type returnType,
30 final List<Parameter> params, final boolean isFinal, final boolean isAbstract, final boolean isStatic) {
31 this(definingType, name, annotations, comment, accessModifier, returnType, params, isFinal, isAbstract,
32 isStatic, false, ValueMechanics.NORMAL);
35 MethodSignatureImpl(final Type definingType, final String name, final List<AnnotationType> annotations,
36 final String comment, final AccessModifier accessModifier, final Type returnType,
37 final List<Parameter> params, final boolean isFinal, final boolean isAbstract, final boolean isStatic,
38 final boolean isDefault, final ValueMechanics mechanics) {
39 super(definingType, name, annotations, comment, accessModifier, returnType, isFinal, isStatic);
41 this.isAbstract = isAbstract;
42 this.isDefault = isDefault;
43 this.mechanics = requireNonNull(mechanics);
47 public boolean isAbstract() {
48 return this.isAbstract;
52 public boolean isDefault() {
57 public List<Parameter> getParameters() {
62 public ValueMechanics getMechanics() {
67 public int hashCode() {
70 result = prime * result + Objects.hashCode(getName());
71 result = prime * result + Objects.hashCode(this.params);
72 result = prime * result + Objects.hashCode(getReturnType());
77 public boolean equals(final Object obj) {
81 if (obj == null || getClass() != obj.getClass()) {
84 final MethodSignatureImpl other = (MethodSignatureImpl) obj;
85 return Objects.equals(getName(), other.getName())
86 && Objects.equals(this.params, other.params)
87 && Objects.equals(getReturnType(), other.getReturnType());
91 public String toString() {
92 final StringBuilder builder = new StringBuilder().append("MethodSignatureImpl [name=").append(getName())
93 .append(", comment=").append(getComment())
94 .append(", definingType=");
96 final Type defType = getDefiningType();
97 if (defType != null) {
98 builder.append(defType.getPackageName()).append('.').append(defType.getName());
100 builder.append(" null");
103 return builder.append(", returnType=").append(getReturnType())
104 .append(", params=").append(this.params)
105 .append(", annotations=").append(getAnnotations())
106 .append(']').toString();