blob: ad5e5d18b5cd87052181e3fe302a5b5bd6088638 [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> {
Aaron Kruglikovc61d2d12015-09-01 11:10:48 -070032
Brian O'Connorb7baf712015-07-28 23:27:03 -070033 ConnectPoint connectPoint;
34
35 public DomainEdge(DomainVertex src, DomainVertex dst, ConnectPoint connectPoint) {
36 super(src, dst);
37 this.connectPoint = connectPoint;
38 }
39
40 @Override
41 public int hashCode() {
HIGUCHI Yutaca9cc8e2015-10-29 23:26:51 -070042 return 43 * super.hashCode() + connectPoint.hashCode();
Brian O'Connorb7baf712015-07-28 23:27:03 -070043 }
44
45 @Override
46 public boolean equals(Object obj) {
47 if (this == obj) {
48 return true;
49 }
50 if (obj instanceof DomainEdge) {
51 final DomainEdge other = (DomainEdge) obj;
52 return super.equals(other) &&
53 Objects.equals(this.connectPoint, other.connectPoint);
54 }
55 return false;
56 }
57
58 @Override
59 public String toString() {
60 return MoreObjects.toStringHelper(this)
61 .add("src", src())
62 .add("dst", dst())
63 .add("connectPoint", connectPoint)
64 .toString();
65 }
Aaron Kruglikovc61d2d12015-09-01 11:10:48 -070066
67 /**
68 * Returns the connect point associated with the domain edge.
69 *
70 * @return this edges connect point
71 */
72 public ConnectPoint connectPoint() {
73 return connectPoint;
74 }
Brian O'Connorb7baf712015-07-28 23:27:03 -070075}