blob: a47823ab23dafad9506876e3c020fe42e9dddb6b [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 Chan445659f2019-01-02 13:46:16 -080028 private Set<XconnectEndpoint> endpoints;
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
Charles Chan445659f2019-01-02 13:46:16 -080034 * @param endpoints set of endpoints
Charles Chan8d316332018-06-19 20:31:57 -070035 */
Charles Chan445659f2019-01-02 13:46:16 -080036 public XconnectDesc(XconnectKey key, Set<XconnectEndpoint> endpoints) {
Charles Chan8d316332018-06-19 20:31:57 -070037 this.key = key;
Charles Chan445659f2019-01-02 13:46:16 -080038 this.endpoints = endpoints;
Charles Chan8d316332018-06-19 20:31:57 -070039 }
40
41 /**
42 * Gets Xconnect key.
43 *
44 * @return Xconnect key
45 */
46 public XconnectKey key() {
47 return key;
48 }
49
50 /**
Charles Chan445659f2019-01-02 13:46:16 -080051 * Gets endpoints.
Charles Chan8d316332018-06-19 20:31:57 -070052 *
Charles Chan445659f2019-01-02 13:46:16 -080053 * @return set of endpoints
Charles Chan8d316332018-06-19 20:31:57 -070054 */
Charles Chan445659f2019-01-02 13:46:16 -080055 public Set<XconnectEndpoint> endpoints() {
56 return endpoints;
Charles Chan8d316332018-06-19 20:31:57 -070057 }
58
59 @Override
60 public boolean equals(final Object obj) {
61 if (this == obj) {
62 return true;
63 }
Charles Chan8d316332018-06-19 20:31:57 -070064 if (!(obj instanceof XconnectDesc)) {
65 return false;
66 }
67 final XconnectDesc other = (XconnectDesc) obj;
68 return Objects.equals(this.key, other.key) &&
Charles Chan445659f2019-01-02 13:46:16 -080069 Objects.equals(this.endpoints, other.endpoints);
Charles Chan8d316332018-06-19 20:31:57 -070070 }
71
72 @Override
73 public int hashCode() {
Charles Chan445659f2019-01-02 13:46:16 -080074 return Objects.hash(key, endpoints);
Charles Chan8d316332018-06-19 20:31:57 -070075 }
76
77 @Override
78 public String toString() {
79 return MoreObjects.toStringHelper(getClass())
80 .add("key", key)
Charles Chan445659f2019-01-02 13:46:16 -080081 .add("endpoints", endpoints)
Charles Chan8d316332018-06-19 20:31:57 -070082 .toString();
83 }
84}