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.yangtools.binding.generator.util.generated.type.builder;
10 import java.util.Collections;
11 import java.util.List;
12 import java.util.Objects;
13 import org.opendaylight.yangtools.sal.binding.model.api.AnnotationType;
14 import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature;
15 import org.opendaylight.yangtools.sal.binding.model.api.Type;
16 import org.opendaylight.yangtools.sal.binding.model.api.type.builder.MethodSignatureBuilder;
17 import org.opendaylight.yangtools.util.LazyCollections;
20 * @deprecated Use {@link org.opendaylight.mdsal.binding.generator.util.generated.type.builder.MethodSignatureBuilderImpl} instead.
23 final class MethodSignatureBuilderImpl extends AbstractTypeMemberBuilder<MethodSignatureBuilder> implements MethodSignatureBuilder {
25 private List<MethodSignature.Parameter> parameters = Collections.emptyList();
26 private List<MethodSignature.Parameter> unmodifiableParams = Collections.emptyList();
27 private boolean isAbstract;
29 public MethodSignatureBuilderImpl(final String name) {
34 public MethodSignatureBuilder setAbstract(final boolean isAbstract) {
35 this.isAbstract = isAbstract;
40 public MethodSignatureBuilder addParameter(final Type type, final String name) {
41 parameters = LazyCollections.lazyAdd(parameters, new MethodParameterImpl(name, type));
42 unmodifiableParams = Collections.unmodifiableList(parameters);
47 protected MethodSignatureBuilder thisInstance() {
52 public MethodSignature toInstance(final Type definingType) {
53 final List<AnnotationType> annotations = toAnnotationTypes();
54 return new MethodSignatureImpl(definingType, getName(), annotations, getComment(), getAccessModifier(),
55 getReturnType(), unmodifiableParams, isFinal(), isAbstract, isStatic());
59 public int hashCode() {
62 result = prime * result + Objects.hashCode(getName());
63 result = prime * result + Objects.hashCode(parameters);
64 result = prime * result + Objects.hashCode(getReturnType());
69 public boolean equals(final Object obj) {
76 if (getClass() != obj.getClass()) {
79 MethodSignatureBuilderImpl other = (MethodSignatureBuilderImpl) obj;
80 if (!Objects.equals(getName(), other.getName())) {
83 if (!Objects.equals(parameters, other.parameters)) {
86 if (!Objects.equals(getReturnType(), other.getReturnType())) {
93 public String toString() {
94 StringBuilder builder = new StringBuilder();
95 builder.append("MethodSignatureBuilderImpl [name=");
96 builder.append(getName());
97 builder.append(", returnType=");
98 builder.append(getReturnType());
99 builder.append(", parameters=");
100 builder.append(parameters);
101 builder.append(", annotationBuilders=");
102 builder.append(getAnnotationBuilders());
103 builder.append(", comment=");
104 builder.append(getComment());
106 return builder.toString();