Fix a few uint warnings
[neutron.git] / neutron-hostconfig / vpp / src / main / java / org / opendaylight / neutron / hostconfig / vpp / SocketInfo.java
1 /*
2  * Copyright (c) 2017 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
9 package org.opendaylight.neutron.hostconfig.vpp;
10
11 import com.google.common.base.Preconditions;
12
13 public class SocketInfo {
14
15     private final String socketPath;
16     private final String socketPrefix;
17     private final String vhostuserMode;
18     private static final String PORT_ID = "$PORT_ID";
19
20     public SocketInfo(String socketPath, String socketPrefix, String vhostuserMode) {
21         this.socketPath = Preconditions.checkNotNull(socketPath);
22         this.socketPrefix = Preconditions.checkNotNull(socketPrefix);
23         this.vhostuserMode = Preconditions.checkNotNull(vhostuserMode);
24     }
25
26     public String getSocketPath() {
27         return socketPath;
28     }
29
30     public String getSocketPrefix() {
31         return socketPrefix;
32     }
33
34     public String getVhostuserMode() {
35         return vhostuserMode;
36     }
37
38     public String getVhostUserSocket() {
39         return new StringBuilder().append(socketPath).append(socketPrefix).append(PORT_ID).toString();
40     }
41
42     @Override
43     public int hashCode() {
44         final int prime = 31;
45         int result = 1;
46         result = prime * result + ((socketPath == null) ? 0 : socketPath.hashCode());
47         result = prime * result + ((socketPrefix == null) ? 0 : socketPrefix.hashCode());
48         result = prime * result + ((vhostuserMode == null) ? 0 : vhostuserMode.hashCode());
49         return result;
50     }
51
52     @Override
53     public boolean equals(Object obj) {
54         if (this == obj) {
55             return true;
56         }
57         if (obj == null) {
58             return false;
59         }
60         if (getClass() != obj.getClass()) {
61             return false;
62         }
63         SocketInfo other = (SocketInfo) obj;
64         if (socketPath == null) {
65             if (other.socketPath != null) {
66                 return false;
67             }
68         } else if (!socketPath.equals(other.socketPath)) {
69             return false;
70         }
71         if (socketPrefix == null) {
72             if (other.socketPrefix != null) {
73                 return false;
74             }
75         } else if (!socketPrefix.equals(other.socketPrefix)) {
76             return false;
77         }
78         if (vhostuserMode == null) {
79             if (other.vhostuserMode != null) {
80                 return false;
81             }
82         } else if (!vhostuserMode.equals(other.vhostuserMode)) {
83             return false;
84         }
85         return true;
86     }
87 }