blob: 787e46cc5bfdd9cca0b1e6cf82402c36902f3a04 [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;
Ray Milkey85dab422017-12-15 13:10:02 -080019import com.google.common.base.MoreObjects;
20import com.google.common.base.Objects;
Himal Kumarb43724d2016-04-29 14:15:57 +100021
22/**
23 * POJO class for the Peer and the Route Servers.
24 */
25
26@XmlRootElement
27public class Peer {
28
29 private String name;
30 private String dpid;
31 private String ipAddress;
32 private String port;
33 private boolean l2;
34
35 public Peer() {}
36
37 public Peer(String name, String dpid, String ipAddress, String port) {
38 this.name = name;
39 this.dpid = dpid;
40 this.ipAddress = ipAddress;
41 this.port = port;
42 this.l2 = false;
43 }
44
45 public void setDpid(String dpid) {
46 this.dpid = dpid;
47 }
48
49 public void setIpAddress(String ipAddress) {
50 this.ipAddress = ipAddress;
51 }
52
53 public void setPort(String port) {
54 this.port = port;
55 }
56
57 /**
58 * The name of the Peer or Customer to be added.
59 *
60 * @param name A String name.
61 */
62 public void setName(String name) {
63 this.name = name;
64 }
65
66 /**
67 * Specifies if the layer two flows for this peer are configured or not.
68 *
69 * @param value True if layer two configured.
70 */
71 public void setL2(boolean value) {
72 this.l2 = value;
73 }
74
75 /**
76 * Returns the name of the Peer or the Customer.
77 *
78 * @return The String name.
79 */
80 public String getName() {
81 return name;
82 }
83
84 /**
85 * Returns the IP Address of the Peer.
86 *
87 * @return IP Address.
88 */
89 public String getIpAddress() {
90 return ipAddress;
91 }
92
93 /**
94 * Returns the port number where the Peer is attached.
95 *
96 * @return String Connect Point
97 */
98 public String getPort() {
99 return port;
100 }
101
102 /**
103 * Returns the layer two status of the Peer.
104 *
105 * @return True if layer two set.
106 */
107 public boolean getl2Status() {
108 return l2;
109 }
110
111 public String getDpid() {
112 return dpid;
113 }
114
115 @Override
116 public boolean equals(Object ob) {
117 if (ob == null) {
118 return false;
119 }
Ray Milkey85dab422017-12-15 13:10:02 -0800120 if (getClass() != ob.getClass()) {
121 return false;
Himal Kumarb43724d2016-04-29 14:15:57 +1000122 }
Ray Milkey85dab422017-12-15 13:10:02 -0800123 Peer other = (Peer) ob;
124 return Objects.equal(this.ipAddress, other.ipAddress);
Himal Kumarb43724d2016-04-29 14:15:57 +1000125 }
126
127 @Override
128 public int hashCode() {
Ray Milkey85dab422017-12-15 13:10:02 -0800129 return Objects.hashCode(this.ipAddress);
130 }
131
132 @Override
133 public String toString() {
134
135 return MoreObjects.toStringHelper(this)
136 .add("ipAddress", ipAddress)
137 .add("name", name)
138 .add("dpid", dpid)
139 .add("port", port)
140 .toString();
141
Himal Kumarb43724d2016-04-29 14:15:57 +1000142 }
143}