Brian O'Connor | b7baf71 | 2015-07-28 23:27:03 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package org.onosproject.incubator.net.domain; |
| 17 | |
| 18 | import com.google.common.annotations.Beta; |
| 19 | import com.google.common.base.MoreObjects; |
| 20 | import org.onlab.graph.AbstractEdge; |
| 21 | import org.onosproject.net.ConnectPoint; |
| 22 | |
| 23 | import 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 |
| 31 | public class DomainEdge extends AbstractEdge<DomainVertex> { |
Aaron Kruglikov | c61d2d1 | 2015-09-01 11:10:48 -0700 | [diff] [blame] | 32 | |
Brian O'Connor | b7baf71 | 2015-07-28 23:27:03 -0700 | [diff] [blame] | 33 | 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 Yuta | ca9cc8e | 2015-10-29 23:26:51 -0700 | [diff] [blame] | 42 | return 43 * super.hashCode() + connectPoint.hashCode(); |
Brian O'Connor | b7baf71 | 2015-07-28 23:27:03 -0700 | [diff] [blame] | 43 | } |
| 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 Kruglikov | c61d2d1 | 2015-09-01 11:10:48 -0700 | [diff] [blame] | 66 | |
| 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'Connor | b7baf71 | 2015-07-28 23:27:03 -0700 | [diff] [blame] | 75 | } |