BUG 3057 - notify added event source by topics created before
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / sal / binding / codegen / impl / RpcMetadata.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.codegen.impl;
9
10 import javassist.CtClass;
11 import javassist.CtMethod;
12
13 import org.opendaylight.yangtools.yang.binding.BaseIdentity;
14
15 import com.google.common.base.Objects;
16 import com.google.common.base.Preconditions;
17
18 final class RpcMetadata {
19     private final Class<? extends BaseIdentity> context;
20     private final CtMethod inputRouteGetter;
21     private final Boolean routeEncapsulated;
22     private final CtClass inputType;
23     private final String methodName;
24
25     public Class<? extends BaseIdentity> getContext() {
26         return context;
27     }
28
29     public CtMethod getInputRouteGetter() {
30         return inputRouteGetter;
31     }
32
33     public CtClass getInputType() {
34         return inputType;
35     }
36
37     public boolean isRouteEncapsulated() {
38         return routeEncapsulated;
39     }
40
41     public RpcMetadata(final String methodName, final Class<? extends BaseIdentity> context, final CtMethod inputRouteGetter, final boolean routeEncapsulated, final CtClass inputType) {
42         this.inputRouteGetter = Preconditions.checkNotNull(inputRouteGetter);
43         this.methodName = Preconditions.checkNotNull(methodName);
44         this.inputType = Preconditions.checkNotNull(inputType);
45         this.context = Preconditions.checkNotNull(context);
46         this.routeEncapsulated = routeEncapsulated;
47     }
48
49     @Override
50     public int hashCode() {
51         final int prime = 31;
52         int result = 1;
53         result = prime * result + methodName.hashCode();
54         result = prime * result + context.hashCode();
55         result = prime * result + inputRouteGetter.hashCode();
56         result = prime * result + routeEncapsulated.hashCode();
57         result = prime * result +  inputType.hashCode();
58         return result;
59     }
60
61     @Override
62     public boolean equals(final Object obj) {
63         if (this == obj) {
64             return true;
65         }
66         if (!(obj instanceof RpcMetadata)) {
67             return false;
68         }
69         final RpcMetadata other = (RpcMetadata) obj;
70         if (!methodName.equals(other.methodName)) {
71             return false;
72         }
73         if (!context.equals(other.context)) {
74             return false;
75         }
76         if (!inputRouteGetter.equals(other.inputRouteGetter)) {
77             return false;
78         }
79         if (!routeEncapsulated.equals(other.routeEncapsulated)) {
80             return false;
81         }
82         return inputType.equals(other.inputType);
83     }
84
85     @Override
86     public String toString() {
87         return Objects.toStringHelper(this)
88                 .add("context", context)
89                 .add("inputRouteGetter", inputRouteGetter)
90                 .add("inputType", inputType)
91                 .add("methodName", methodName)
92                 .add("routeEncapsulated", routeEncapsulated)
93                 .toString();
94     }
95 }