blob: d13955acb004127a6c385ebc3693d1ff287a9f19 [file] [log] [blame]
Brian O'Connorb7baf712015-07-28 23:27:03 -07001/*
2 * Copyright 2015 Open Networking Laboratory
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.incubator.net.domain;
17
18import com.google.common.annotations.Beta;
19import com.google.common.base.MoreObjects;
20import org.onlab.graph.AbstractEdge;
21import org.onosproject.net.ConnectPoint;
22
23import java.util.Objects;
24
25/**
26 * Representation of a connection between an intent domain and a device. This
27 * must happen using a connect point that is part of both the domain and the
28 * device.
29 */
30@Beta
31public class DomainEdge extends AbstractEdge<DomainVertex> {
32 ConnectPoint connectPoint;
33
34 public DomainEdge(DomainVertex src, DomainVertex dst, ConnectPoint connectPoint) {
35 super(src, dst);
36 this.connectPoint = connectPoint;
37 }
38
39 @Override
40 public int hashCode() {
41 return 43 * super.hashCode() + Objects.hash(connectPoint);
42 }
43
44 @Override
45 public boolean equals(Object obj) {
46 if (this == obj) {
47 return true;
48 }
49 if (obj instanceof DomainEdge) {
50 final DomainEdge other = (DomainEdge) obj;
51 return super.equals(other) &&
52 Objects.equals(this.connectPoint, other.connectPoint);
53 }
54 return false;
55 }
56
57 @Override
58 public String toString() {
59 return MoreObjects.toStringHelper(this)
60 .add("src", src())
61 .add("dst", dst())
62 .add("connectPoint", connectPoint)
63 .toString();
64 }
65}