blob: e94c1db3f62be2aa1a01041b36ea21b0f4e6c0de [file] [log] [blame]
Charles Chan8d316332018-06-19 20:31:57 -07001/*
2 * Copyright 2018-present Open Networking Foundation
3 *
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.segmentrouting.xconnect.api;
17
18import com.google.common.base.MoreObjects;
Charles Chan8d316332018-06-19 20:31:57 -070019
20import java.util.Objects;
21import java.util.Set;
22
23/**
24 * Xconnect description.
25 */
26public class XconnectDesc {
27 private XconnectKey key;
Charles Chan48df9ad2018-10-30 18:08:59 -070028 private Set<String> ports;
Charles Chan8d316332018-06-19 20:31:57 -070029
30 /**
31 * Constructs new Xconnect description with given device ID and VLAN ID.
32 *
33 * @param key Xconnect key
34 * @param ports set of ports
35 */
Charles Chan48df9ad2018-10-30 18:08:59 -070036 public XconnectDesc(XconnectKey key, Set<String> ports) {
Charles Chan8d316332018-06-19 20:31:57 -070037 this.key = key;
38 this.ports = ports;
39 }
40
41 /**
42 * Gets Xconnect key.
43 *
44 * @return Xconnect key
45 */
46 public XconnectKey key() {
47 return key;
48 }
49
50 /**
51 * Gets ports.
52 *
53 * @return set of ports
54 */
Charles Chan48df9ad2018-10-30 18:08:59 -070055 public Set<String> ports() {
Charles Chan8d316332018-06-19 20:31:57 -070056 return ports;
57 }
58
59 @Override
60 public boolean equals(final Object obj) {
61 if (this == obj) {
62 return true;
63 }
64 if (!super.equals(obj)) {
65 return false;
66 }
67 if (!(obj instanceof XconnectDesc)) {
68 return false;
69 }
70 final XconnectDesc other = (XconnectDesc) obj;
71 return Objects.equals(this.key, other.key) &&
72 Objects.equals(this.ports, other.ports);
73 }
74
75 @Override
76 public int hashCode() {
77 return Objects.hash(key, ports);
78 }
79
80 @Override
81 public String toString() {
82 return MoreObjects.toStringHelper(getClass())
83 .add("key", key)
84 .add("ports", ports)
85 .toString();
86 }
87}