Fix CS warnings in sal-remoterpc-connector and enable enforcement
[controller.git] / opendaylight / md-sal / sal-remoterpc-connector / src / main / java / org / opendaylight / controller / remote / rpc / RouteIdentifierImpl.java
1 /*
2  * Copyright (c) 2014 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.remote.rpc;
9
10 import com.google.common.base.Preconditions;
11 import java.io.Serializable;
12 import org.opendaylight.controller.sal.connector.api.RpcRouter;
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
15
16 public class RouteIdentifierImpl
17         implements RpcRouter.RouteIdentifier<QName, QName, YangInstanceIdentifier>, Serializable {
18     private static final long serialVersionUID = 1L;
19
20     private final QName context;
21     private final QName type;
22     private final YangInstanceIdentifier route;
23
24     public RouteIdentifierImpl(final QName context, final QName type, final YangInstanceIdentifier route) {
25         Preconditions.checkNotNull(type, "Rpc type should not be null");
26         this.context = context;
27         this.type = type;
28         this.route = route;
29     }
30
31     @Override
32     public QName getContext() {
33         return context;
34     }
35
36     @Override
37     public QName getType() {
38         return type;
39     }
40
41     @Override
42     public YangInstanceIdentifier getRoute() {
43         return route;
44     }
45
46     @Override
47     public boolean equals(final Object obj) {
48         if (this == obj) {
49             return true;
50         }
51         if (obj == null || getClass() != obj.getClass()) {
52             return false;
53         }
54
55         final RouteIdentifierImpl that = (RouteIdentifierImpl) obj;
56
57         if (context == null) {
58             if (that.getContext() != null) {
59                 return false;
60             }
61         } else if (!context.equals(that.context)) {
62             return false;
63         }
64
65         if (route == null) {
66             if (that.getRoute() != null) {
67                 return false;
68             }
69         } else if (!route.equals(that.route)) {
70             return false;
71         }
72
73         if (type == null) {
74             if (that.getType() != null) {
75                 return false;
76             }
77         } else if (!type.equals(that.type)) {
78             return false;
79         }
80
81         return true;
82     }
83
84     @Override
85     public int hashCode() {
86         final int prime = 31;
87         int result = 0;
88         result = prime * result + (context == null ? 0 : context.hashCode());
89         result = prime * result + (type == null ? 0 : type.hashCode());
90         result = prime * result + (route == null ? 0 : route.hashCode());
91         return result;
92     }
93
94     @Override
95     public String toString() {
96         return "RouteIdentifierImpl{" + "context=" + context + ", type=" + type + ", route=" + route + '}';
97     }
98 }