blob: aa85d88d283e9c331008b32181c6b621f65c2c06 [file] [log] [blame]
tome3489412014-08-29 02:30:38 -07001package org.onlab.graph;
2
3import java.util.Objects;
4
tomeadbb462014-09-07 16:10:19 -07005import static com.google.common.base.MoreObjects.toStringHelper;
tom144de692014-08-29 11:38:44 -07006
tome3489412014-08-29 02:30:38 -07007/**
8 * Test edge.
9 */
10public class TestEdge extends AbstractEdge<TestVertex> {
11
12 private final double weight;
13
14 /**
15 * Creates a new edge between the specified source and destination vertexes.
16 *
17 * @param src source vertex
18 * @param dst destination vertex
19 * @param weight edge weight
20 */
21 public TestEdge(TestVertex src, TestVertex dst, double weight) {
22 super(src, dst);
23 this.weight = weight;
24 }
25
26 /**
27 * Returns the edge weight.
28 *
29 * @return edge weight
30 */
31 public double weight() {
32 return weight;
33 }
34
35 @Override
36 public int hashCode() {
37 return 31 * super.hashCode() + Objects.hash(weight);
38 }
39
40 @Override
41 public boolean equals(Object obj) {
tomfc9a4ff2014-09-22 18:22:47 -070042 if (this == obj) {
43 return true;
44 }
tome3489412014-08-29 02:30:38 -070045 if (obj instanceof TestEdge) {
46 final TestEdge other = (TestEdge) obj;
47 return super.equals(obj) && Objects.equals(this.weight, other.weight);
48 }
49 return false;
50 }
tom144de692014-08-29 11:38:44 -070051
52 @Override
53 public String toString() {
54 return toStringHelper(this).add("src", src()).add("dst", dst()).
55 add("weight", weight).toString();
56 }
57
tome3489412014-08-29 02:30:38 -070058}