Add IfNewHostNotify to DeviceManager
[controller.git] / opendaylight / usermanager / api / src / main / java / org / opendaylight / controller / usermanager / ServerConfig.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  * and is available at http://www.eclipse.org/legal/epl-v10.html
8  */
9
10 package org.opendaylight.controller.usermanager;
11
12 import java.io.Serializable;
13
14 /**
15  * Configuration Java Object which represents a Remote AAA server configuration
16  * information for User Manager.
17  */
18 public class ServerConfig implements Serializable {
19     private static final long serialVersionUID = 1L;
20
21     // Order matters: JSP file expects following fields in the following order
22     private String ip;
23     private String secret;
24     private String protocol;
25
26     public ServerConfig() {
27     }
28
29     public ServerConfig(String ip, String secret, String protocol) {
30         this.ip = ip;
31         this.secret = secret;
32         this.protocol = protocol;
33     }
34
35     public String getAddress() {
36         return ip;
37     }
38
39     public String getSecret() {
40         return secret;
41     }
42
43     public String getProtocol() {
44         return protocol;
45     }
46
47     @Override
48     public int hashCode() {
49         final int prime = 31;
50         int result = 1;
51         result = prime * result + ((ip == null) ? 0 : ip.hashCode());
52         result = prime * result
53                 + ((protocol == null) ? 0 : protocol.hashCode());
54         result = prime * result + ((secret == null) ? 0 : secret.hashCode());
55         return result;
56     }
57
58     @Override
59     public boolean equals(Object obj) {
60         if (this == obj)
61             return true;
62         if (obj == null)
63             return false;
64         if (getClass() != obj.getClass())
65             return false;
66         ServerConfig other = (ServerConfig) obj;
67         if (ip == null) {
68             if (other.ip != null)
69                 return false;
70         } else if (!ip.equals(other.ip))
71             return false;
72         if (protocol == null) {
73             if (other.protocol != null)
74                 return false;
75         } else if (!protocol.equals(other.protocol))
76             return false;
77         if (secret == null) {
78             if (other.secret != null)
79                 return false;
80         } else if (!secret.equals(other.secret))
81             return false;
82         return true;
83     }
84
85     public boolean isValid() {
86         return (ip != null && !ip.isEmpty() && secret != null && !secret
87                 .isEmpty());
88     }
89 }