Checkstyle enforcer
[controller.git] / opendaylight / switchmanager / api / src / main / java / org / opendaylight / controller / switchmanager / SwitchConfig.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.switchmanager;
11
12 import java.io.Serializable;
13
14 /**
15  * The class describes a switch configuration including node identifier, node
16  * name, tier number and proactive/reactive mode.
17  */
18 public class SwitchConfig implements Serializable {
19     private static final long serialVersionUID = 1L;
20     String nodeId;
21     String description;
22     String tier;
23     String mode;
24
25     public SwitchConfig(String nodeId, String description, String tier, String mode) {
26         super();
27         this.nodeId = nodeId;
28         this.description = description;
29         this.tier = tier;
30         this.mode = mode;
31     }
32
33     public String getNodeId() {
34         return nodeId;
35     }
36
37     public String getNodeDescription() {
38         return description;
39     }
40
41     public String getTier() {
42         return tier;
43     }
44
45     public String getMode() {
46         return mode;
47     }
48
49     public boolean isProactive() {
50         return Integer.parseInt(mode) != 0;
51     }
52
53     public static long getSerialversionuid() {
54         return serialVersionUID;
55     }
56
57     @Override
58     public int hashCode() {
59         final int prime = 31;
60         int result = 1;
61         result = prime * result
62                 + ((description == null) ? 0 : description.hashCode());
63         result = prime * result + ((mode == null) ? 0 : mode.hashCode());
64         result = prime * result + ((nodeId == null) ? 0 : nodeId.hashCode());
65         result = prime * result + ((tier == null) ? 0 : tier.hashCode());
66         return result;
67     }
68
69     @Override
70     public boolean equals(Object obj) {
71         if (this == obj)
72             return true;
73         if (obj == null)
74             return false;
75         if (getClass() != obj.getClass())
76             return false;
77         SwitchConfig other = (SwitchConfig) obj;
78         if (description == null) {
79             if (other.description != null)
80                 return false;
81         } else if (!description.equals(other.description))
82             return false;
83         if (mode == null) {
84             if (other.mode != null)
85                 return false;
86         } else if (!mode.equals(other.mode))
87             return false;
88         if (nodeId == null) {
89             if (other.nodeId != null)
90                 return false;
91         } else if (!nodeId.equals(other.nodeId))
92             return false;
93         if (tier == null) {
94             if (other.tier != null)
95                 return false;
96         } else if (!tier.equals(other.tier))
97             return false;
98         return true;
99     }
100 }