blob: 395981b1d6d2df0519abfefe9603f95dc0eb407b [file] [log] [blame]
Himal Kumarb43724d2016-04-29 14:15:57 +10001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Himal Kumarb43724d2016-04-29 14:15:57 +10003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.castor;
17
18import javax.xml.bind.annotation.XmlRootElement;
19
20/**
21 * POJO class for the Peer and the Route Servers.
22 */
23
24@XmlRootElement
25public class Peer {
26
27 private String name;
28 private String dpid;
29 private String ipAddress;
30 private String port;
31 private boolean l2;
32
33 public Peer() {}
34
35 public Peer(String name, String dpid, String ipAddress, String port) {
36 this.name = name;
37 this.dpid = dpid;
38 this.ipAddress = ipAddress;
39 this.port = port;
40 this.l2 = false;
41 }
42
43 public void setDpid(String dpid) {
44 this.dpid = dpid;
45 }
46
47 public void setIpAddress(String ipAddress) {
48 this.ipAddress = ipAddress;
49 }
50
51 public void setPort(String port) {
52 this.port = port;
53 }
54
55 /**
56 * The name of the Peer or Customer to be added.
57 *
58 * @param name A String name.
59 */
60 public void setName(String name) {
61 this.name = name;
62 }
63
64 /**
65 * Specifies if the layer two flows for this peer are configured or not.
66 *
67 * @param value True if layer two configured.
68 */
69 public void setL2(boolean value) {
70 this.l2 = value;
71 }
72
73 /**
74 * Returns the name of the Peer or the Customer.
75 *
76 * @return The String name.
77 */
78 public String getName() {
79 return name;
80 }
81
82 /**
83 * Returns the IP Address of the Peer.
84 *
85 * @return IP Address.
86 */
87 public String getIpAddress() {
88 return ipAddress;
89 }
90
91 /**
92 * Returns the port number where the Peer is attached.
93 *
94 * @return String Connect Point
95 */
96 public String getPort() {
97 return port;
98 }
99
100 /**
101 * Returns the layer two status of the Peer.
102 *
103 * @return True if layer two set.
104 */
105 public boolean getl2Status() {
106 return l2;
107 }
108
109 public String getDpid() {
110 return dpid;
111 }
112
113 @Override
114 public boolean equals(Object ob) {
115 if (ob == null) {
116 return false;
117 }
118 Peer other = (Peer) ob;
119 if (this.ipAddress.equals(other.ipAddress)) {
120 return true;
121 }
122 return false;
123 }
124
125 @Override
126 public int hashCode() {
127 int hash = 3;
128 hash = 53 * hash + (this.ipAddress != null ? this.ipAddress.hashCode() : 0);
129 return hash;
130 }
131}