blob: 0eead313cf30be347d7f47ebdf32bc8903d598ff [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;
19import org.onosproject.net.PortNumber;
20
21import java.util.Objects;
22import java.util.Set;
23
24/**
25 * Xconnect description.
26 */
27public class XconnectDesc {
28 private XconnectKey key;
29 private Set<PortNumber> ports;
30
31 /**
32 * Constructs new Xconnect description with given device ID and VLAN ID.
33 *
34 * @param key Xconnect key
35 * @param ports set of ports
36 */
37 public XconnectDesc(XconnectKey key, Set<PortNumber> ports) {
38 this.key = key;
39 this.ports = ports;
40 }
41
42 /**
43 * Gets Xconnect key.
44 *
45 * @return Xconnect key
46 */
47 public XconnectKey key() {
48 return key;
49 }
50
51 /**
52 * Gets ports.
53 *
54 * @return set of ports
55 */
56 public Set<PortNumber> ports() {
57 return ports;
58 }
59
60 @Override
61 public boolean equals(final Object obj) {
62 if (this == obj) {
63 return true;
64 }
65 if (!super.equals(obj)) {
66 return false;
67 }
68 if (!(obj instanceof XconnectDesc)) {
69 return false;
70 }
71 final XconnectDesc other = (XconnectDesc) obj;
72 return Objects.equals(this.key, other.key) &&
73 Objects.equals(this.ports, other.ports);
74 }
75
76 @Override
77 public int hashCode() {
78 return Objects.hash(key, ports);
79 }
80
81 @Override
82 public String toString() {
83 return MoreObjects.toStringHelper(getClass())
84 .add("key", key)
85 .add("ports", ports)
86 .toString();
87 }
88}