Make sure invokeOperation is set once
[controller.git] / opendaylight / adsal / 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 import org.opendaylight.controller.configuration.ConfigurationObject;
15
16 /**
17  * Configuration Java Object which represents a Remote AAA server configuration
18  * information for User Manager.
19  */
20 public class ServerConfig extends ConfigurationObject implements Serializable {
21     private static final long serialVersionUID = 1L;
22
23     // Order matters: JSP file expects following fields in the following order
24     private String ip;
25     private String secret;
26     private String protocol;
27
28     public ServerConfig() {
29     }
30
31     public ServerConfig(String ip, String secret, String protocol) {
32         this.ip = ip;
33         this.secret = secret;
34         this.protocol = protocol;
35     }
36
37     public String getAddress() {
38         return ip;
39     }
40
41     public String getSecret() {
42         return secret;
43     }
44
45     public String getProtocol() {
46         return protocol;
47     }
48
49     @Override
50     public int hashCode() {
51         final int prime = 31;
52         int result = 1;
53         result = prime * result + ((ip == null) ? 0 : ip.hashCode());
54         result = prime * result
55                 + ((protocol == null) ? 0 : protocol.hashCode());
56         result = prime * result + ((secret == null) ? 0 : secret.hashCode());
57         return result;
58     }
59
60     @Override
61     public boolean equals(Object obj) {
62         if (this == obj) {
63             return true;
64         }
65         if (obj == null) {
66             return false;
67         }
68         if (getClass() != obj.getClass()) {
69             return false;
70         }
71         ServerConfig other = (ServerConfig) obj;
72         if (ip == null) {
73             if (other.ip != null) {
74                 return false;
75             }
76         } else if (!ip.equals(other.ip)) {
77             return false;
78         }
79         if (protocol == null) {
80             if (other.protocol != null) {
81                 return false;
82             }
83         } else if (!protocol.equals(other.protocol)) {
84             return false;
85         }
86         if (secret == null) {
87             if (other.secret != null) {
88                 return false;
89             }
90         } else if (!secret.equals(other.secret)) {
91             return false;
92         }
93         return true;
94     }
95
96     public boolean isValid() {
97         return (ip != null && !ip.isEmpty() && secret != null && !secret
98                 .isEmpty());
99     }
100 }