Merge "Added support for annotations in generated APIs."
[controller.git] / opendaylight / sal / yang-prototype / code-generator / binding-generator-impl / src / main / java / org / opendaylight / controller / sal / binding / generator / impl / 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.controller.sal.binding.generator.impl;
9
10 import org.opendaylight.controller.sal.binding.model.api.Type;
11 import org.opendaylight.controller.sal.binding.model.api.MethodSignature.Parameter;
12
13 final class MethodParameterImpl implements Parameter {
14
15     private final String name;
16     private final Type type;
17
18     public MethodParameterImpl(final String name, final Type type) {
19         super();
20         this.name = name;
21         this.type = type;
22     }
23
24     @Override
25     public String getName() {
26         return name;
27     }
28
29     @Override
30     public Type getType() {
31         return type;
32     }
33
34     /*
35      * (non-Javadoc)
36      * 
37      * @see java.lang.Object#hashCode()
38      */
39     @Override
40     public int hashCode() {
41         final int prime = 31;
42         int result = 1;
43         result = prime * result + ((name == null) ? 0 : name.hashCode());
44         result = prime * result + ((type == null) ? 0 : type.hashCode());
45         return result;
46     }
47
48     /*
49      * (non-Javadoc)
50      * 
51      * @see java.lang.Object#equals(java.lang.Object)
52      */
53     @Override
54     public boolean equals(Object obj) {
55         if (this == obj) {
56             return true;
57         }
58         if (obj == null) {
59             return false;
60         }
61         if (getClass() != obj.getClass()) {
62             return false;
63         }
64         MethodParameterImpl other = (MethodParameterImpl) obj;
65         if (name == null) {
66             if (other.name != null) {
67                 return false;
68             }
69         } else if (!name.equals(other.name)) {
70             return false;
71         }
72         if (type == null) {
73             if (other.type != null) {
74                 return false;
75             }
76         } else if (!type.equals(other.type)) {
77             return false;
78         }
79         return true;
80     }
81
82     /*
83      * (non-Javadoc)
84      * 
85      * @see java.lang.Object#toString()
86      */
87     @Override
88     public String toString() {
89         StringBuilder builder = new StringBuilder();
90         builder.append("MethodParameter [name=");
91         builder.append(name);
92         builder.append(", type=");
93         builder.append(type.getPackageName());
94         builder.append(".");
95         builder.append(type.getName());
96         builder.append("]");
97         return builder.toString();
98     }
99 }