Bug 6859: Binding generator v1 refactoring
[mdsal.git] / binding / mdsal-binding-generator-util / src / main / java / org / opendaylight / mdsal / binding / model / util / generated / type / builder / MethodParameterImpl.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.Objects;
11 import org.opendaylight.mdsal.binding.model.api.MethodSignature.Parameter;
12 import org.opendaylight.mdsal.binding.model.api.Type;
13
14 final class MethodParameterImpl implements Parameter {
15
16     private final String name;
17     private final Type type;
18
19     public MethodParameterImpl(final String name, final Type type) {
20         super();
21         this.name = name;
22         this.type = type;
23     }
24
25     @Override
26     public String getName() {
27         return this.name;
28     }
29
30     @Override
31     public Type getType() {
32         return this.type;
33     }
34
35     /*
36      * (non-Javadoc)
37      *
38      * @see java.lang.Object#hashCode()
39      */
40     @Override
41     public int hashCode() {
42         final int prime = 31;
43         int result = 1;
44         result = (prime * result) + Objects.hashCode(this.name);
45         result = (prime * result) + Objects.hashCode(this.type);
46         return result;
47     }
48
49     /*
50      * (non-Javadoc)
51      *
52      * @see java.lang.Object#equals(java.lang.Object)
53      */
54     @Override
55     public boolean equals(final Object obj) {
56         if (this == obj) {
57             return true;
58         }
59         if (obj == null) {
60             return false;
61         }
62         if (getClass() != obj.getClass()) {
63             return false;
64         }
65         final MethodParameterImpl other = (MethodParameterImpl) obj;
66         return Objects.equals(this.name, other.name) && Objects.equals(this.type, other.type);
67     }
68
69     /*
70      * (non-Javadoc)
71      *
72      * @see java.lang.Object#toString()
73      */
74     @Override
75     public String toString() {
76         final StringBuilder builder = new StringBuilder();
77         builder.append("MethodParameter [name=");
78         builder.append(this.name);
79         builder.append(", type=");
80         builder.append(this.type.getPackageName());
81         builder.append(".");
82         builder.append(this.type.getName());
83         builder.append("]");
84         return builder.toString();
85     }
86 }